/** * PHR_AndroidNative * * Copyright (C) 1999-2014 Photon Infotech Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.photon.phresco.nativeapp.eshop.activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.TextView; import com.photon.phresco.nativeapp.R; import com.photon.phresco.nativeapp.eshop.logger.PhrescoLogger; import com.photon.phresco.nativeapp.eshop.model.mycart.MyCart; import com.photon.phresco.nativeapp.eshop.model.order.OrderStatus; /** * Show order status screen * * @author viral_b * */ public class OrderStatusActivity extends PhrescoActivity { private static final String TAG = "OrderStatusActivity ***** "; private ImageButton backButton, browseButton, offersButton, myCartButton; private TextView orderNo; private OrderStatus orderStatus = null; private String currActivity = "currentActivity"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.order_status); initEnvironment(); Intent orderDetailIntent = getIntent(); if (orderDetailIntent != null && orderDetailIntent.getExtras() != null) { orderStatus = (OrderStatus) orderDetailIntent.getSerializableExtra("orderStatus"); } PhrescoLogger.info(TAG + " - orderStatus : " + orderStatus); showOrderStatus(); backButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { startCategoryListActivity(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - backButton - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } }); browseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { startCategoryListActivity(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - browseButton - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } }); offersButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { startOffersActivity(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - offersButton - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } }); myCartButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { startMyCartActivity(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - myCartButton - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } }); clearMyCart(); } /** * start category list activity */ private void startCategoryListActivity() { try { Intent categoryListActivity = new Intent(getApplicationContext(), CategoryListActivity.class); categoryListActivity.putExtra(currActivity, "browse"); startActivity(categoryListActivity); finish(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - startCategoryListActivity - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } /** * start offers activity */ private void startOffersActivity() { try { Intent offersActivity = new Intent(getApplicationContext(), OffersActivity.class); offersActivity.putExtra(currActivity, "offers"); startActivity(offersActivity); finish(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - startOffersActivity - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } /** * start my cart activity */ private void startMyCartActivity() { try { Intent myCartActivity = new Intent(getApplicationContext(), MyCartActivity.class); myCartActivity.putExtra(currActivity, "mycart"); startActivity(myCartActivity); finish(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - startMyCartActivity - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } /** * Initialize all the controls for current screen */ private void initEnvironment() { try { backButton = (ImageButton) findViewById(R.id.back_btn); browseButton = (ImageButton) findViewById(R.id.tab_browse); offersButton = (ImageButton) findViewById(R.id.tab_specialoffer); myCartButton = (ImageButton) findViewById(R.id.tab_mycart); orderNo = (TextView) findViewById(R.id.order_no); browseButton.setBackgroundResource(R.drawable.browse_tab_normal); offersButton.setBackgroundResource(R.drawable.specialoffer_tab_normal); myCartButton.setBackgroundResource(R.drawable.mycart_tab_selected); } catch (Exception ex) { PhrescoLogger.info(TAG + " - initEnvironment - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } /** * Clear the cart object, once you are done with check out process */ private void clearMyCart() { try { PhrescoLogger.info(TAG + " - clearMyCart: " + MyCart.size()); MyCart.clear(); } catch (Exception ex) { PhrescoLogger.info(TAG + " - clearMyCart - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } /** * Show the order number in text view */ private void showOrderStatus() { PhrescoLogger.info(TAG + " - showOrderStatus: "); try { orderNo.setText(Integer.toString(orderStatus.getOrderId())); } catch (Exception ex) { PhrescoLogger.info(TAG + " - showOrderStatus - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } } }