コード例 #1
0
ファイル: Cart.cs プロジェクト: babs375/Anndroid_project
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ISharedPreferences pref     = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
            string             userName = pref.GetString("Usermail", String.Empty);

            try
            {
                //string user = Intent.GetStringExtra("usrID").Trim();

                //bool res = int.TryParse(user, out uid);

                //if (string.IsNullOrEmpty(user))
                //{
                var query  = db.selectallUser();
                var query1 = query.Where(x => x.Email == userName).FirstOrDefault();

                uid = query1.Uid;

                //}
            }

            catch (Exception ex)
            {
                Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show();
            }



            mUserCartObject = new UserCartObject(uid);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_cart);

            mResultReceiver = new AddressResultReceiver(new Handler())
            {
                Activity = this
            };

            mLocationAddressTextView = FindViewById <EditText>(Resource.Id.mLocationAddressTextView);
            mProgressBar             = FindViewById <ProgressBar>(Resource.Id.mProgressBar);
            crtAmt = FindViewById <TextView>(Resource.Id.cAmount);
            odrBtn = FindViewById <Button>(Resource.Id.btnPlaceOrder);
            mFetchAddressButton        = FindViewById <ImageButton>(Resource.Id.mFetchAddressButton);
            mFetchAddressButton.Click += FetchAddressButtonHandler;

            mAddressRequested = false;
            mAddressOutput    = string.Empty;
            UpdateValuesFromBundle(savedInstanceState);

            mFusedLocationClient = LocationServices.GetFusedLocationProviderClient(this);

            UpdateUiWidgets();

            tcost          = FindViewById <TextView>(Resource.Id.total);
            mRecycleView   = FindViewById <RecyclerView>(Resource.Id.listCart);
            mLayoutManager = new LinearLayoutManager(this);
            mRecycleView.SetLayoutManager(mLayoutManager);
            mAdapter = new UserCartObjectAdapter(mUserCartObject);

            int tot = 0;

            for (int i = 0; i < mUserCartObject.numPhoto; i++)
            {
                tot += mUserCartObject[i].mPrice;
            }
            crtAmt.Text         = tot.ToString();
            totAmt              = (tot * 113 / 100);
            tcost.Text          = totAmt.ToString();
            totAmt              = (float)(System.Math.Truncate((double)totAmt * 100.0) / 100.0);
            mAdapter.ItemClick += MAdapter_ItemClick;
            mRecycleView.SetAdapter(mAdapter);

            odrBtn.Click += PlaceOrder_Click;

            CreateNotificationChannel();
        }
コード例 #2
0
 public UserCartObjectAdapter(UserCartObject usrcrt)
 {
     mUserCartObject = usrcrt;
 }