private void SetRecyclerViewAdapters() { try { MAdapter = new VideoRowAdapter(Activity) { VideoList = new ObservableCollection <VideoObject>() }; LayoutManager = new LinearLayoutManager(Context); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <VideoObject>(Activity, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager); MainScrollEvent = xamarinRecyclerViewOnScrollListener; MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent; MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener); MainScrollEvent.IsLoading = false; //======== Category ======= CatLayoutManager = new LinearLayoutManager(Activity); CatRecycler.SetLayoutManager(CatLayoutManager); MCatAdapter = new CategoryAdapter(Activity) { CategoryList = new ObservableCollection <Classes.Category>() }; CatRecycler.SetAdapter(MCatAdapter); if (MCatAdapter.CategoryList.Count == 0 && CategoriesController.ListCategories.Count > 0) { MCatAdapter.CategoryList = CategoriesController.ListCategories; MCatAdapter.NotifyDataSetChanged(); CatRecycler.Visibility = ViewStates.Visible; MRecycler.Visibility = ViewStates.Gone; } else { CatRecycler.Visibility = ViewStates.Gone; MRecycler.Visibility = ViewStates.Visible; Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; } } } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnResume() { base.OnResume(); adapter?.NotifyDataSetChanged(); // Highlights the last clicked idea if (Global.LoginData == null) { SetSubtitle("Not logged in"); } }
private async void AddDialogPositive(object sender, EventArgs e) { if (_addDialog.Name.Trim() == "") { _addDialog.Error = GetString(Resource.String.noCategoryName); return; } var category = new Category(_addDialog.Name.Truncate(32)); if (_categorySource.IsDuplicate(category)) { _addDialog.Error = GetString(Resource.String.duplicateCategory); return; } _addDialog.Dismiss(); await _connection.InsertAsync(category); await _categorySource.Update(); _categoryAdapter.NotifyDataSetChanged(); CheckEmptyState(); }
public override void OnResume() { categoryAdapter.NotifyDataSetChanged(); base.OnResume(); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activityEditCategories); var toolbar = FindViewById <Toolbar>(Resource.Id.activityEditCategories_toolbar); var progressBar = FindViewById <ProgressBar>(Resource.Id.activityEditCategories_progressBar); SetSupportActionBar(toolbar); SupportActionBar.SetTitle(Resource.String.editCategories); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_action_arrow_back); _addButton = FindViewById <FloatingActionButton>(Resource.Id.activityEditCategories_buttonAdd); _addButton.Click += OnAddClick; _connection = await Database.Connect(this); _categorySource = new CategorySource(_connection); _categoryAdapter = new CategoryAdapter(_categorySource); _categoryAdapter.RenameClick += OnRenameClick; _categoryAdapter.DeleteClick += OnDeleteClick; _categoryList = FindViewById <RecyclerView>(Resource.Id.activityEditCategories_list); _emptyState = FindViewById <LinearLayout>(Resource.Id.activityEditCategories_emptyState); _categoryList.SetAdapter(_categoryAdapter); _categoryList.HasFixedSize = true; _categoryList.SetItemViewCacheSize(20); var callback = new AuthListTouchHelperCallback(_categoryAdapter); var touchHelper = new ItemTouchHelper(callback); touchHelper.AttachToRecyclerView(_categoryList); var layout = new LinearLayoutManager(this); var decoration = new DividerItemDecoration(this, layout.Orientation); _categoryList.AddItemDecoration(decoration); _categoryList.SetLayoutManager(layout); var layoutAnimation = AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fade_in); _categoryList.LayoutAnimation = layoutAnimation; await _categorySource.UpdateTask; CheckEmptyState(); _categoryAdapter.NotifyDataSetChanged(); _categoryList.ScheduleLayoutAnimation(); var alphaAnimation = new AlphaAnimation(1.0f, 0.0f) { Duration = 200 }; alphaAnimation.AnimationEnd += (sender, e) => { progressBar.Visibility = ViewStates.Gone; }; progressBar.StartAnimation(alphaAnimation); }