public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater inflater = LayoutInflater.From(globalView.Context); view = (View)inflater.Inflate(Resource.Layout.CustomListLayout, null, false); } var item = items[position]; view.FindViewById <TextView>(Resource.Id.listName).Text = item.Name; view.FindViewById <RatingBar>(Resource.Id.listRate).Rating = item.Rate; view.FindViewById <TextView>(Resource.Id.listDate).Text = "" + MyUtil.GetType(item) + " " + item.CreateDate.ToString("yyyy-MM-dd"); if (isSelected[position] == true) { view.SetBackgroundColor(Color.Orange); } else { view.SetBackgroundColor(Color.Transparent); } return(view); }
private async void saveMealInfo(string name, int rate, int type, string comment, string createDate) { if (meal != null) { meal.Name = name; meal.Rate = rate; meal.Type = type; meal.Comments = comment; meal.CreateDate = DateTime.ParseExact(createDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);; if (uri != null) { meal.ImageName = saveImage(null); } } else { meal = new Meal(name, rate, type, saveImage(null), comment, createDate); } string message = await insertUpdateData(meal); if ("Success" == message) { Toast.MakeText(this.Context, "Saved successfully!", ToastLength.Short).Show(); MyUtil.GoHome(this); } else { Toast.MakeText(this.Context, message, ToastLength.Short).Show(); } }
public override bool OnOptionsItemSelected(IMenuItem item) { MyFragment fragement = FragmentManager.FindFragmentByTag <MyFragment>(MyFragment.PAGE_CONTENT); MyUtil.HideSoftKeyboard(this); switch (item.ItemId) { case Resource.Id.nav_home: MyUtil.GoPage(fragement, PAGE.HOME); return(true); case Resource.Id.nav_register: MyUtil.GoPage(fragement, PAGE.REGI); return(true); case Resource.Id.nav_list: MyUtil.GoPage(fragement, PAGE.LIST); return(true); default: if (drawerLayout.IsDrawerOpen(navigationView)) { drawerLayout.CloseDrawers(); } else { drawerLayout.OpenDrawer(navigationView); } return(true); } }
public async void DeleteCurrentItem(object sender, EventArgs e) { string result = await MyUtil.DeleteItem(meal.ID); Toast.MakeText(this.Context, "Delete successfully!", ToastLength.Short).Show(); dialog.Dismiss(); await GetList(); }
public override void OnBackPressed() { if (CURRENT_PAGE == PAGE.HOME) { base.OnBackPressed(); } else { MyUtil.GoPage(FragmentManager.FindFragmentByTag <MyFragment>(MyFragment.PAGE_CONTENT), PAGE.HOME); } }
public void cancelBtn_OnClick(object sender, EventArgs e) { if (fromList) { fromList = false; MyUtil.GoList(this); } else { MyUtil.GoHome(this); } }
private void ShowFrq5RecordsForOneMonth(List <PickedMeal> allList) { allList = allList.OrderByDescending(x => x.Count).ToList(); allList = allList.Count > 5 ? allList.GetRange(0, 5) : allList; ListView listView = FindViewById <ListView>(Resource.Id.mainList2); downList = MyUtil.GetDataWithNoDataProcessing(allList); MainListAdaptor adaptor = new MainListAdaptor(view, downList); adaptor.type = false; listView.Adapter = adaptor; listView.ItemClick += OnListItemClick2; UpdateLayout(para2, allList, listView); }
private void hideSoftKeyboard(object sender, View.TouchEventArgs e) { MyUtil.HideSoftKeyboard(Activity); }
protected void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { ListView listView = sender as ListView; listView.Focusable = true; listView.RequestFocusFromTouch(); for (int i = 0; i < listView.ChildCount; i++) { listView.GetChildAt(i).SetBackgroundColor(Color.Transparent); } e.View.SetBackgroundColor(Color.Orange); meal = list[e.Position]; // custom dialog if (dialog == null) { dialog = new Dialog(view.Context); } dialog.SetContentView(Resource.Layout.ViewInformation); dialog.FindViewById <TextView>(Resource.Id.viewComments).Text = meal.Comments; dialog.FindViewById <TextView>(Resource.Id.viewFoodName).Text = meal.Name; dialog.FindViewById <RatingBar>(Resource.Id.viewRatingBar).Rating = meal.Rate; dialog.FindViewById <TextView>(Resource.Id.viewMealType).Text = meal.CreateDate.ToString("yyyy-MM-dd") + " " + MyUtil.GetType(meal); if (!string.IsNullOrWhiteSpace(meal.ImageName)) { FFImageLoading.Views.ImageViewAsync imageView = dialog.FindViewById <FFImageLoading.Views.ImageViewAsync>(Resource.Id.viewImageView); ImageService.Instance .LoadFile(System.IO.Path.Combine(PageRegisterFragment.documentsDirectory, meal.ImageName)) .DownSampleInDip(width: 250) .LoadingPlaceholder("loading.png", FFImageLoading.Work.ImageSource.CompiledResource) .ErrorPlaceholder("error.png", FFImageLoading.Work.ImageSource.CompiledResource) .Into(imageView); } dialog.FindViewById <Button>(Resource.Id.goModifyBtn).Click += GoModifyPage; dialog.FindViewById <Button>(Resource.Id.deleteBtn).Click += DeleteCurrentItem; dialog.CancelEvent += closeDialog; dialog.Show(); }
public void GoModifyPage(object sender, EventArgs e) { fromList = true; MyUtil.GoPage(this, PAGE.REGI); dialog.Dismiss(); }
protected void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e, List <PickedMeal> list) { ListView listView = sender as ListView; for (int i = 0; i < listView.ChildCount; i++) { listView.GetChildAt(i).SetBackgroundColor(Color.Transparent); } e.View.SetBackgroundColor(Color.LightGray); meal = list[e.Position]; // custom dialog if (dialog == null) { dialog = new Dialog(view.Context, Resource.Style.Dialog); } dialog.SetContentView(Resource.Layout.ViewInformation); dialog.FindViewById <TextView>(Resource.Id.viewComments).Text = meal.Comments; dialog.FindViewById <TextView>(Resource.Id.viewFoodName).Text = meal.Name; dialog.FindViewById <RatingBar>(Resource.Id.viewRatingBar).Rating = meal.Rate; dialog.FindViewById <TextView>(Resource.Id.viewMealType).Text = meal.CreateDate.ToString("yyyy-MM-dd") + " / " + MyUtil.GetType(meal); FFImageLoading.Views.ImageViewAsync imageView = dialog.FindViewById <FFImageLoading.Views.ImageViewAsync>(Resource.Id.viewImageView); if (!string.IsNullOrWhiteSpace(meal.ImageName)) { ImageService.Instance .LoadFile(System.IO.Path.Combine(PageRegisterFragment.documentsDirectory, meal.ImageName)) .DownSampleInDip(width: 250) .LoadingPlaceholder("loading.png", FFImageLoading.Work.ImageSource.CompiledResource) .ErrorPlaceholder("error.png", FFImageLoading.Work.ImageSource.CompiledResource) .Into(imageView); } else { ImageService.Instance.LoadCompiledResource("noImage.png").Into(imageView); } dialog.FindViewById <LinearLayout>(Resource.Id.firstLineInViewInformation).LayoutParameters = new TableRow.LayoutParams(LinearLayout.LayoutParams.MatchParent, 0); dialog.CancelEvent += closeDialog; dialog.Show(); }