Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Console.WriteLine(SharedHelper.DbPath);

            locDB = new LocationDataBase(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "travel.db3"));

            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);


            btn_sign_in = FindViewById <Button>(Resource.Id.button_sign_in);
            btn_sign_up = FindViewById <Button>(Resource.Id.button_sign_up);

            btn_sign_in.Click += delegate
            {
                Intent signInScreen = new Intent(this, typeof(LoginActivity));
                StartActivity(signInScreen);
            };

            btn_sign_up.Click += delegate
            {
                Intent signUpScreen = new Intent(this, typeof(RegistrationActivity));
                StartActivity(signUpScreen);
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // check if user is login
            if (App.username == null)
            {
                Intent ints = new Intent(this, typeof(LoginActivity));
                StartActivity(ints);
            }

            SetContentView(Resource.Layout.locationPage);

            // on logout button click
            FindViewById <Button>(Resource.Id.btnLocationLogout)
            .Click += (s, arg) =>
            {
                App.username = null;
                Intent ints = new Intent(this, typeof(LoginActivity));
                StartActivity(ints);
            };

            // on checkout button click
            FindViewById <Button>(Resource.Id.btnLoactionCheckout)
            .Click += (s, arg) =>
            {
                Intent ints = new Intent(this, typeof(CheckoutActivity));
                StartActivity(ints);
            };

            // Create your application here
            locationDb = new LocationDataBase(SharedHelper.DbPath);

            //var checkout = FindViewById<>(Resource.Id.checkout);
            listView    = FindViewById <ListView>(Resource.Id.listView1);
            searchView1 = FindViewById <SearchView>(Resource.Id.searchView1);

            LocationAdapter lp = new LocationAdapter(this, locationDb.GetLocationsAsync().Result);

            listView.Adapter             = lp;
            listView.ItemClick          += OnListClicked;
            searchView1.QueryTextChange += OnSerachChange;
        }
Exemplo n.º 3
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();
        }