async void Increment(CravingsClass craving) { string action = await DisplayActionSheet("Change Value", "Cancel", null, "Increase By 1", "Decrease By 1", "Reset Value"); if (action == "Increase By 1") craving.Count++; if (action == "Decrease By 1" && craving.Count > 0) craving.Count--; if (action == "Reset Value") craving.Count = 0; DB.conn2.Update(craving); pieChart.InvalidateSurface(); ResetListViewSources(); }
public Cravings() { InitializeComponent(); if (!Preferences.ContainsKey("CravingsCreated")) { Preferences.Set("CravingsCreated", true); int i = 0; foreach (string craving in cravingsString) { CravingsClass newCraving = new CravingsClass { DisplayName = craving, Hex = "#" + string.Format("{0:X2}{1:X2}{2:X2}", colors[i].Red, colors[i].Green, colors[i].Blue), Count = 0 }; DB.conn2.Insert(newCraving); i++; } } ResetListViewSources(); }
void cravingsListView_ItemTapped(System.Object sender, Xamarin.Forms.ItemTappedEventArgs e) { CravingsClass cravingTapped = (CravingsClass)((ListView)sender).SelectedItem; Increment(cravingTapped); }