private async Task LoadBlockedUser() { if (Methods.CheckConnectivity()) { var countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Global.GetBlockedUsersAsync(); if (apiStatus != 200 || respond is not GetBlockedUsersObject result || result.BlockedUsers == null) { Methods.DisplayReportResult(this, respond); } else { switch (countList) { case > 0: { foreach (var item in from item in result.BlockedUsers let check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { MAdapter.UserList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); break; } default: MAdapter.UserList = new ObservableCollection <UserDataObject>(result.BlockedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); break; } } RunOnUiThread(ShowEmptyPage); }
private async Task LoadDataAsync() { if (Methods.CheckConnectivity()) { int countList = MAdapter.BlockedUsersList.Count; (int apiStatus, var respond) = await RequestsAsync.Users.ProfileAsync(UserDetails.UserId.ToString(), "blocks"); if (apiStatus != 200 || !(respond is ProfileObject result) || result.Data == null) { Methods.DisplayReportResult(this, respond); } else { var respondList = result.Data.Blocks.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.Data.Blocks let check = MAdapter.BlockedUsersList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.BlockedUsersList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.BlockedUsersList.Count - countList); }); } else { MAdapter.BlockedUsersList = new ObservableCollection <Block>(result.Data.Blocks); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.BlockedUsersList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show(); } } } RunOnUiThread(ShowEmptyPage); } else { Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += EmptyStateButtonOnClick; } Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } }
private async Task LoadBlockedUser() { if (Methods.CheckConnectivity()) { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.Get_Blocked_Users(); if (apiStatus != 200 || !(respond is GetBlockedUsersObject result) || result.BlockedUsers == null) { Methods.DisplayReportResult(this, respond); } else { if (countList > 0) { foreach (var item in from item in result.BlockedUsers let check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { MAdapter.UserList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); } else { MAdapter.UserList = new ObservableCollection <UserDataObject>(result.BlockedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } RunOnUiThread(ShowEmptyPage); } else { Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null !; x.EmptyStateButton.Click += EmptyStateButtonOnClick; } Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } }
private async Task LoadBlocks(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.BlockedUsersList.Count; (int apiStatus, var respond) = await RequestsAsync.User.GetBlocksAsync(UserDetails.UserId.ToString(), "15", offset); if (apiStatus == 200) { if (respond is GetUserObject result) { var respondList = result.Data?.UserList?.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.Data?.UserList let check = MAdapter.BlockedUsersList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.BlockedUsersList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.BlockedUsersList.Count - countList); }); } else { MAdapter.BlockedUsersList = new ObservableCollection <UserDataObject>(result.Data?.UserList); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.BlockedUsersList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoBlockUsers), ToastLength.Short).Show(); } } } } else { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } RunOnUiThread(ShowEmptyPage); } else { Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += EmptyStateButtonOnClick; } Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); MainScrollEvent.IsLoading = false; } MainScrollEvent.IsLoading = false; }