/// <summary> /// Regsiters the lotted lunch menu. /// </summary> /// <param name="selectedItem">Selected item.</param> private void regsiterLottedLunchMenu(LunchMenuPickerItem selectedItem) { var newMenuLog = new MenuLog(selectedItem.id, selectedItem.calory, selectedItem.cost); // Dismiss dialog on succeeding insert. if (LunchMenuDao.getInstance().insertMenuLog((newMenuLog))) { // TODO /* * string successText = String.Format(Resources.GetString (Resource.String.success_add_log), name); * Toast.MakeText(Activity ,successText , ToastLength.Short).Show(); */ } else { // TODO // Show failure Toast and Highlight invalid field. /* * string successText = String.Format(Resources.GetString (Resource.String.fail_add_menu), name); * Toast.MakeText(Activity ,successText , ToastLength.Short).Show(); */ } Dismiss(); }
/// <summary> /// Show confirmation view to specify todays menu. /// </summary> /// <param name="selectedItem">Selected item.</param> private void showConfirmationView(LunchMenuPickerItem selectedItem) { var lottedView = view.FindViewById <LinearLayout>(Resource.Id.lotMenuLayoutView); lottedView.Visibility = ViewStates.Visible; var lottedItemValue = view.FindViewById <TextView>(Resource.Id.selectedMenuValue); lottedItemValue.Text = selectedItem.name; var confirmButton = view.FindViewById <Button>(Resource.Id.confirmButton); confirmButton.Click += delegate { regsiterLottedLunchMenu(selectedItem); }; var cancelButton = view.FindViewById <Button>(Resource.Id.cancelButton); cancelButton.Click += delegate { this.Dismiss(); }; }
/// <summary> /// Callback for picker stop. /// Update UI on UI thread. /// </summary> /// <param name="selectedItem">Selected item in picker.</param> private void stopPickerCallback(LunchMenuPickerItem selectedItem) { Application.SynchronizationContext.Post(_ => { showConfirmationView(selectedItem); }, null); }