public void FavoriteButtonClick(UsersClickEventArgs e) { try { if (e.UserClass == null) { e.UserClass = GetItem(e.Position); } if (e.UserClass != null) { var index = UserList.IndexOf(UserList.FirstOrDefault(a => a.Id == e.UserClass.Id)); if (index != -1) { UserList.Remove(e.UserClass); NotifyItemRemoved(index); NotifyItemRangeRemoved(0, ItemCount); } var sqlEntity = new SqLiteDatabase(); sqlEntity.Remove_Favorite(e.UserClass); sqlEntity.Dispose(); var countList = HomeActivity?.ProfileFragment?.FavoriteFragment?.MAdapter?.ItemCount; if (countList == 0) { HomeActivity?.ProfileFragment?.FavoriteFragment?.ShowEmptyPage(); } } } catch (Exception exception) { Console.WriteLine(exception); } }
public void FavoriteButtonClick(UsersClickEventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (e.UserClass == null) { e.UserClass = GetItem(e.Position); } if (e.UserClass != null) { var index = UserList.IndexOf(UserList.FirstOrDefault(a => a.Id == e.UserClass.Id)); if (index != -1) { UserList.Remove(e.UserClass); NotifyItemRemoved(index); NotifyItemRangeRemoved(0, ItemCount); } // Send Api Remove Favorite PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Favorites.DeleteFavoritesAsync(e.UserClass.UserId.ToString()) }); var countList = HomeActivity?.ProfileFragment?.FavoriteFragment?.MAdapter?.ItemCount; if (countList == 0) { HomeActivity?.ProfileFragment?.FavoriteFragment?.ShowEmptyPage(); } } } catch (Exception exception) { Console.WriteLine(exception); } }