public void AddToShoppingCart(string guess, decimal price, int quantity = 1) { var preferences = new ActivityPreferences(context, prefsName); preferences.AddCartItem(guess, price.ToString(), quantity); //shoppingCartItemAddedMessageBar.Show(); }
protected override void OnCreate(Bundle savedInstanceState) { Window.SetSoftInputMode(SoftInput.StateHidden); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ShoppingList); voicePrefs = new ActivityPreferences(this, VOICE_PREFS_NAME); CheckVoicePrefs(); talkBackEnabled = IsTalkBackEnabled(); if (!talkBackEnabled) { InitiateNoTalkBackMode(); } listView = FindViewById <ListView>(Resource.Id.ShopListListView); addItemButton = FindViewById <Button>(Resource.Id.ShopListAddItemButton); addItemEditText = FindViewById <EditText>(Resource.Id.ShopListAddItemEditText); removeItemButton = FindViewById <Button>(Resource.Id.ShopListRemoveItemButton); removeAllItemsButton = FindViewById <Button>(Resource.Id.ShopListDeleteAllButton); prefs = new ActivityPreferences(this, PREFS_NAME); items = prefs.GetPreferencesToList(); gestureListener = new GestureListener(); gestureListener.LeftEvent += GestureLeft; gestureDetector = new GestureDetector(this, gestureListener); listAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItemChecked, items); listView.Adapter = listAdapter; listView.ChoiceMode = ChoiceMode.Multiple; addItemButton.Click += AddTextBoxProductToList; removeItemButton.Click += RemoveTextBoxProductFromList; removeAllItemsButton.Click += RemoveAllItems; drawerLayout = FindViewById <DrawerLayout>(Resource.Id.DrawerLayout); toolbar = FindViewById <SupportToolbar>(Resource.Id.Toolbar); navView = FindViewById <NavigationView>(Resource.Id.NavView); drawerToggle = new ActionBarDrawerToggle( this, drawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer ); drawerLayout.AddDrawerListener(drawerToggle); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); drawerToggle.SyncState(); navView.NavigationItemSelected += (sender, e) => { switch (e.MenuItem.ItemId) { case Resource.Id.NavItemShoppingCart: GoToShoppingCart(); break; case Resource.Id.NavItemShoppingList: OnOptionsItemSelected(e.MenuItem); break; } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current); DependencyInjection.RegisterInterfaces(); cmdOpenCamera = ConfigurationManager.AppSettings["CmdOpenCamera"]; cmdTakePhoto = ConfigurationManager.AppSettings["CmdTakePhoto"]; cmdOpenCart = ConfigurationManager.AppSettings["CmdOpenCart"]; cmdOpenList = ConfigurationManager.AppSettings["CmdOpenList"]; cmdHelp = ConfigurationManager.AppSettings["CmdHelp"]; cmdRemind = ConfigurationManager.AppSettings["CmdRemind"]; cmdTutorialRequest = ConfigurationManager.AppSettings["CmdTutorialRequest"]; cmdTutorialLikeShopLens = ConfigurationManager.AppSettings["CmdTutorialLikeShopLens"]; userGuidPrefKey = ConfigurationManager.AppSettings["UserGuidPrefKey"]; shopLensDbContext = ConnectToDatabase(); prefs = PreferenceManager.GetDefaultSharedPreferences(this); talkBackEnabledIntentKey = ConfigurationManager.AppSettings["TalkBackKey"]; voicePrefs = new ActivityPreferences(this, ConfigurationManager.AppSettings["VoicePrefs"]); CheckVoicePrefs(); talkBackEnabled = IsTalkBackEnabled(); if (!talkBackEnabled) { InitiateNoTalkBackMode(); } // Set our view from the "main" layout resource. SetContentView(Resource.Layout.Main); camera2Frag = Camera2Fragment.NewInstance(this, this); if (savedInstanceState == null) { new Thread(() => { FragmentManager.BeginTransaction().Replace(Resource.Id.container, camera2Frag).Commit(); } ).Start(); } drawerLayout = FindViewById <DrawerLayout>(Resource.Id.DrawerLayout); toolbar = FindViewById <SupportToolbar>(Resource.Id.Toolbar); navView = FindViewById <NavigationView>(Resource.Id.NavView); rootView = FindViewById <CoordinatorLayout>(Resource.Id.root_view); drawerToggle = new Android.Support.V7.App.ActionBarDrawerToggle( this, drawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer ); drawerLayout.AddDrawerListener(drawerToggle); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); drawerToggle.SyncState(); gestureListener = new GestureListener(); gestureListener.LeftEvent += GestureLeft; gestureDetector = new GestureDetector(this, gestureListener); navView.NavigationItemSelected += (sender, e) => { switch (e.MenuItem.ItemId) { case Resource.Id.NavItemShoppingCart: StartCartIntent(); break; case Resource.Id.NavItemShoppingList: StartListIntent(); break; } }; }