protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            traveLocation = new TravelingLocationDataBase(SharedHelper.DbPath);
            if (App.username == null)
            {
                Intent ints = new Intent(this, typeof(LoginActivity));
                StartActivity(ints);
            }
            SetContentView(Resource.Layout.cart);

            Button backCheckout = FindViewById <Button>(Resource.Id.btnCheckoutBack);

            backCheckout.Click += ONBackCheckout_Click;

            Button addCheckout = FindViewById <Button>(Resource.Id.btnCheckoutAdd);

            addCheckout.Click += OnAddCheckout_Click;
            // Give name in text box
            FindViewById <TextView>(Resource.Id.txtSelectedCity).Text = App.selectedLocation.Name;
            // Create your application here
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.checkout);
            // initialize databases
            trDb  = new TravelingLocationDataBase(SharedHelper.DbPath);
            locDb = new LocationDataBase(SharedHelper.DbPath);

            //  get resource variables
            listViewCheckout = FindViewById <ListView>(Resource.Id.listViewCheckout);
            txtTotalPrice    = FindViewById <TextView>(Resource.Id.txtTotalPrice);

            // add value to list adapter
            var travelLocation = trDb.GetTravelLocationByUserIdAsync(App.username).Result;

            if (travelLocation.Count <= 0)
            {
                new MessageHelper().alertFunction("Error", "Please select the locations", this);
                Intent ints = new Intent(this, typeof(LocationActivity));
                StartActivity(ints);
            }

            List <Location> selectedLoc = new List <Location>();

            for (int trvLoc = 0; trvLoc < travelLocation.Count; trvLoc++)
            {
                selectedLoc.Add(locDb.GetLocationAsync(travelLocation[trvLoc].LocationId).Result);
            }
            LocationAdapter lp = new LocationAdapter(this, selectedLoc);

            listViewCheckout.Adapter    = lp;
            listViewCheckout.ItemClick += OnListClicked;

            // calculate total price
            txtTotalPrice.Text = selectedLoc.Select(sa => sa.Price).Sum().ToString();
        }