Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_checkout);

            ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);

            userName = pref.GetString("Username", String.Empty);

            controller         = new Controller();
            userInfo           = controller.RetreiveUser(userName);
            TotPrice           = (TextView)FindViewById(Resource.Id.checkoutListTPTextView);
            TotTax             = (TextView)FindViewById(Resource.Id.checkoutListTPTTextView);
            TotPriceAfTax      = (TextView)FindViewById(Resource.Id.checkoutListTPATTextView);
            otherLocation      = (EditText)FindViewById(Resource.Id.otherLocationEditText);
            spinner            = FindViewById <Spinner>(Resource.Id.payMethSpinner);
            confirmPurchaseBtn = FindViewById <Button>(Resource.Id.ConfirmPurchaseBtn);
            confirmPurchaseBtn = (Button)FindViewById(Resource.Id.ConfirmPurchaseBtn);
            locationRG         = (RadioGroup)FindViewById(Resource.Id.LocationRadioGrp);
            locationRG.Check(0);
            locationRG.CheckedChange += LocationRG_CheckedChange;
            spinner.ItemSelected     += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            var adapter = ArrayAdapter.CreateFromResource(
                this, Resource.Array.paymentMethArray, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = adapter;

            items  = MainActivity.CartItems;
            offers = MainActivity.CartOffers;
            for (int i = 0; i < offers.numoffers; i++)
            {
                Item item = new Item(3, 4, offers[i].offerName, "d", null, 4, offers[i].offerPrice, 1, " ", 1);             //Adding Offer as an Item
                items.Add(item);
            }
            mRecycleView   = FindViewById <RecyclerView>(Resource.Id.ItemsCheckoutRecyclerView);
            mLayoutManager = new LinearLayoutManager(this);
            mRecycleView.SetLayoutManager(mLayoutManager);
            mAdapter                  = new CheckoutListAdapter(items);
            mAdapter.ItemClick       += MAdapter_ItemClick;;
            confirmPurchaseBtn.Click += ConfirmPurchaseBtn_Click;
            mRecycleView.SetAdapter(mAdapter);
            TotPrice.Text      = items.CalcTotal().ToString();
            TotTax.Text        = items.CalcTax().ToString();
            TotPriceAfTax.Text = (items.CalcTotal() + items.CalcTax() + 10).ToString();
        }