protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activityManageCategories); _preferences = new PreferenceWrapper(this); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetTitle(Resource.String.categories); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_action_arrow_back); _rootLayout = FindViewById <RelativeLayout>(Resource.Id.layoutRoot); _addButton = FindViewById <FloatingActionButton>(Resource.Id.buttonAdd); _addButton.Click += OnAddClick; var connection = await Database.GetSharedConnection(); _categorySource = new CategorySource(connection); _categoryListAdapter = new ManageCategoriesListAdapter(_categorySource); _categoryListAdapter.MenuClick += OnMenuClick; _categoryListAdapter.HasStableIds = true; _categoryListAdapter.DefaultId = _preferences.DefaultCategory; _categoryList = FindViewById <RecyclerView>(Resource.Id.list); _emptyStateLayout = FindViewById <LinearLayout>(Resource.Id.layoutEmptyState); _categoryList.SetAdapter(_categoryListAdapter); _categoryList.HasFixedSize = true; var layout = new FixedGridLayoutManager(this, 1); _categoryList.SetLayoutManager(layout); var callback = new ReorderableListTouchHelperCallback(this, _categoryListAdapter, layout); var touchHelper = new ItemTouchHelper(callback); touchHelper.AttachToRecyclerView(_categoryList); var decoration = new DividerItemDecoration(this, layout.Orientation); _categoryList.AddItemDecoration(decoration); var layoutAnimation = AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fade_in); _categoryList.LayoutAnimation = layoutAnimation; await Refresh(); }
public override Android.App.Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.changeIcon); alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); alert.SetCancelable(false); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChangeIcon, null); _searchText = view.FindViewById <EditText>(Resource.Id.editSearch); _iconList = view.FindViewById <RecyclerView>(Resource.Id.list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); _searchText.TextChanged += OnSearchChanged; _iconListAdapter = new IconListAdapter(Context, _iconSource); _iconListAdapter.ItemClick += OnItemClick; _iconListAdapter.HasStableIds = true; _iconList.SetAdapter(_iconListAdapter); _iconList.HasFixedSize = true; _iconList.SetItemViewCacheSize(20); var layout = new FixedGridLayoutManager(Context, 6); _iconList.SetLayoutManager(layout); var cancelButton = dialog.GetButton((int)DialogButtonType.Negative); cancelButton.Click += (sender, e) => { dialog.Dismiss(); }; return(dialog); }