private void OnSetDefaultClick(object item, int position) { var category = _categorySource.Get(position); if (category == null) { return; } var oldDefault = _preferences.DefaultCategory; var isDefault = oldDefault == category.Id; SetDefaultCategory(isDefault ? null : category.Id); if (oldDefault != null) { var oldDefaultPos = _categorySource.GetPosition(oldDefault); if (oldDefaultPos > -1) { _categoryListAdapter.NotifyItemChanged(oldDefaultPos); } } _categoryListAdapter.NotifyItemChanged(position); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.sheetMainMenu, container, false); SetupToolbar(view, Resource.String.mainMenu, true); _categoryListAdapter = new CategoriesListAdapter(Activity, _source) { HasStableIds = true }; _categoryList = view.FindViewById <RecyclerView>(Resource.Id.listCategories); _categoryList.SetAdapter(_categoryListAdapter); _categoryList.HasFixedSize = true; _categoryList.SetLayoutManager(new LinearLayoutManager(Activity)); var selectedCategoryPosition = _currCategoryId == null ? 0 : _source.GetPosition(_currCategoryId) + 1; _categoryListAdapter.SelectedPosition = selectedCategoryPosition; _categoryListAdapter.NotifyDataSetChanged(); _categoryListAdapter.CategorySelected += (_, id) => { CategoryClick?.Invoke(this, id); }; var backupButton = view.FindViewById <LinearLayout>(Resource.Id.buttonBackup); var manageCategoriesButton = view.FindViewById <LinearLayout>(Resource.Id.buttonManageCategories); var settingsButton = view.FindViewById <LinearLayout>(Resource.Id.buttonSettings); backupButton.Click += (_, _) => { BackupClick?.Invoke(this, null); Dismiss(); }; manageCategoriesButton.Click += (_, _) => { ManageCategoriesClick?.Invoke(this, null); Dismiss(); }; settingsButton.Click += (_, _) => { SettingsClick?.Invoke(this, null); Dismiss(); }; return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.sheetMainMenu, container, false); SetupToolbar(view, Resource.String.mainMenu, true); _categoryListAdapter = new CategoriesListAdapter(Activity, _source) { HasStableIds = true }; _categoryList = view.FindViewById <RecyclerView>(Resource.Id.listCategories); _categoryList.SetAdapter(_categoryListAdapter); _categoryList.HasFixedSize = true; _categoryList.SetLayoutManager(new LinearLayoutManager(Activity)); var selectedCategoryPosition = _currCategoryId == null ? 0 : _source.GetPosition(_currCategoryId) + 1; _categoryListAdapter.SelectedPosition = selectedCategoryPosition; _categoryListAdapter.NotifyDataSetChanged(); _categoryListAdapter.CategorySelected += (_, id) => { ClickCategory?.Invoke(this, id); }; var menu = view.FindViewById <RecyclerView>(Resource.Id.listMenu); SetupMenu(menu, new List <SheetMenuItem> { new(Resource.Drawable.ic_action_backup, Resource.String.backup, ClickBackup), new(Resource.Drawable.ic_action_category, Resource.String.manageCategories, ClickManageCategories), new(Resource.Drawable.ic_action_settings, Resource.String.settings, ClickSettings) });