private void CategoriesAdapterOnItemClick(object sender, CategoriesAdapterClickEventArgs e) { try { KeySearch = ""; MarketTab.MAdapter.MarketList.Clear(); MarketTab.MAdapter.NotifyDataSetChanged(); var item = CategoriesAdapter.GetItem(e.Position); if (item != null) { var check = CategoriesAdapter.MCategoriesList.Where(a => a.CategoriesColor == AppSettings.MainColor).ToList(); if (check.Count > 0) { foreach (var all in check) { all.CategoriesColor = "#ffffff"; } } var click = CategoriesAdapter.MCategoriesList.FirstOrDefault(a => a.CategoriesId == item.CategoriesId); if (click != null) { click.CategoriesColor = AppSettings.MainColor; } CategoriesAdapter.NotifyDataSetChanged(); MarketTab.SwipeRefreshLayout.Refreshing = true; MarketTab.SwipeRefreshLayout.Enabled = true; if (Methods.CheckConnectivity()) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => GetMarketByKey(KeySearch, item.CategoriesId) }); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show(); } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void SetRecyclerViewAdapters() { try { if (CategoriesController.ListCategoriesProducts.Count > 0) { var check = CategoriesController.ListCategoriesProducts.Where(a => a.CategoriesColor == AppSettings.MainColor).ToList(); if (check.Count > 0) { foreach (var all in check) { all.CategoriesColor = "#ffffff"; } } CatRecyclerView.HasFixedSize = true; CatRecyclerView.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false)); CategoriesAdapter = new CategoriesAdapter(this) { MCategoriesList = CategoriesController.ListCategoriesProducts, }; CatRecyclerView.SetAdapter(CategoriesAdapter); CatRecyclerView.NestedScrollingEnabled = false; CategoriesAdapter.NotifyDataSetChanged(); CatRecyclerView.Visibility = ViewStates.Visible; CategoriesAdapter.ItemClick += CategoriesAdapterOnItemClick; } else { CatRecyclerView.Visibility = ViewStates.Gone; } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }