private void OnDeleteClick(object item, int position) { var builder = new MaterialAlertDialogBuilder(this); builder.SetMessage(Resource.String.confirmCategoryDelete); builder.SetTitle(Resource.String.warning); builder.SetCancelable(true); builder.SetPositiveButton(Resource.String.delete, async delegate { try { await _categorySource.Delete(position); } catch { ShowSnackbar(Resource.String.genericError, Snackbar.LengthShort); return; } RunOnUiThread(delegate { _categoryListAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); }); builder.SetNegativeButton(Resource.String.cancel, delegate { }); var dialog = builder.Create(); dialog.Show(); }
private void OnDeleteClick(object item, int position) { var builder = new MaterialAlertDialogBuilder(this); builder.SetMessage(Resource.String.confirmCategoryDelete); builder.SetTitle(Resource.String.warning); builder.SetCancelable(true); builder.SetPositiveButton(Resource.String.delete, async delegate { var category = _categorySource.Get(position); if (category == null) { return; } if (_preferences.DefaultCategory == category.Id) { SetDefaultCategory(null); } try { await _categorySource.Delete(position); } catch (Exception e) { Logger.Error(e); ShowSnackbar(Resource.String.genericError, Snackbar.LengthShort); return; } RunOnUiThread(delegate { _categoryListAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); }); builder.SetNegativeButton(Resource.String.cancel, delegate { }); var dialog = builder.Create(); dialog.Show(); }
private void OnDeleteClick(object item, int position) { var builder = new MaterialAlertDialogBuilder(this); builder.SetMessage(Resource.String.confirmCategoryDelete); builder.SetTitle(Resource.String.warning); builder.SetCancelable(true); builder.SetPositiveButton(Resource.String.delete, async(sender, args) => { await _categorySource.Delete(position); _categoryListAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); var dialog = builder.Create(); dialog.Show(); }