예제 #1
0
        private async void OnAddDialogSubmit(object sender, EditCategoryBottomSheet.EditCategoryEventArgs args)
        {
            var dialog   = (EditCategoryBottomSheet)sender;
            var category = new Category(args.Name);

            if (_categorySource.Exists(category))
            {
                dialog.NameError = GetString(Resource.String.duplicateCategory);
                return;
            }

            try
            {
                await _categorySource.Add(category);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                ShowSnackbar(Resource.String.genericError, Snackbar.LengthShort);
                return;
            }
            finally
            {
                RunOnUiThread(dialog.Dismiss);
            }

            RunOnUiThread(delegate
            {
                _categoryListAdapter.NotifyDataSetChanged();
                CheckEmptyState();
            });
        }