private async Task LoadUserFollowingAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } MainScrollEvent.IsLoading = true; int countList = MAdapter.UsersList.Count; (int apiStatus, var respond) = await RequestsAsync.User.GetFollowingAsync(UserId, "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.UsersList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.UsersList.Add(item); } Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UsersList.Count - countList); }); } else { MAdapter.UsersList = new ObservableCollection <UserDataObject>(result.Data?.UserList); Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UsersList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUser), ToastLength.Short).Show(); } } } } else { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(Activity, respond); } Activity.RunOnUiThread(ShowEmptyPage); }
private async Task LoadDataAsync(string offset = "") { if (Methods.CheckConnectivity()) { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Post.FetchLikes(PostId, offset, "35"); if (apiStatus != 200 || !(respond is FetchLikesObject result) || result.Data == null) { Methods.DisplayReportResult(Activity, respond); } else { var respondList = result.Data.Count; if (respondList > 0) { result.Data.RemoveAll(a => a.MediaSet?.Count == 0 && a.MediaSet == null); foreach (var item in from item in result.Data let check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId.ToString()) where check == null select item) { item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4); MAdapter.UserList.Add(item.UserData); } if (countList > 0) { Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.UserList.Count - countList); }); } else { Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show(); } } } MainScrollEvent.IsLoading = false; Activity.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(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } }
private async Task LoadContactsAsync() { var lastIdUser = MAdapter.UserList.LastOrDefault()?.UserId ?? "0"; if (Methods.CheckConnectivity()) { var countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Global.GetFriendsAsync(UserDetails.UserId, "following", "35", lastIdUser); if (apiStatus != 200 || (respond is not GetFriendsObject result) || result.DataFriends == null) { Methods.DisplayReportResult(this, respond); } else { var respondList = result.DataFriends.Following.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in result.DataFriends.Following) { var check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId); if (check == null) { MAdapter.UserList.Add(item); } } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); } else { MAdapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Following); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); } } } MainScrollEvent.IsLoading = false; RunOnUiThread(ShowEmptyPage); }
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 LoadPostDataAsync() { if (Methods.CheckConnectivity()) { if (TypePost == "post_likes") { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.Get_Post_Data(IdPost, "post_liked_users"); if (apiStatus == 200) { if (respond is GetPostDataObject result) { var respondList = result.PostLikedUsers.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.PostLikedUsers 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.PostLikedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); } } } } else { Methods.DisplayReportResult(this, respond); } } else if (TypePost == "post_wonders") { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.Get_Post_Data(IdPost, "post_wondered_users"); if (apiStatus == 200) { if (respond is GetPostDataObject result) { var respondList = result.PostWonderedUsers.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.PostWonderedUsers 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.PostWonderedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); } } } } else { 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(); } }
private async Task LoadContactsAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; if (TypeContacts == "Following") { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.GetFriendsAsync(UserId, "following", "10", offset); if (apiStatus != 200 || !(respond is GetFriendsObject result) || result.DataFriends == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.DataFriends.Following.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in result.DataFriends.Following) { var check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId); if (check == null) { MAdapter.UserList.Add(item); } else { check = item; check.Name = item.Name; } } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); } else { MAdapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Following); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short).Show(); } } } } else { int countList = MAdapter.UserList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.GetFriendsAsync(UserId, "followers", "10", "", offset); if (apiStatus != 200 || !(respond is GetFriendsObject result) || result.DataFriends == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.DataFriends.Followers.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in result.DataFriends.Followers) { var check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId); if (check == null) { MAdapter.UserList.Add(item); } else { check = item; check.Name = item.Name; } } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); } else { MAdapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Followers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), 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(); MainScrollEvent.IsLoading = false; } }
private async Task LoadContactsAsync(string offset = "0") { switch (MainScrollEvent.IsLoading) { case true: return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; switch (TypeContacts) { case "Following": { var countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Global.GetFriendsAsync(UserId, "following", "10", offset); if (apiStatus != 200 || respond is not GetFriendsObject result || result.DataFriends == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.DataFriends.Following.Count; switch (respondList) { case > 0 when countList > 0: { foreach (var item in result.DataFriends.Following) { var check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId); switch (check) { case null: MAdapter.UserList.Add(item); break; default: check = item; check.Name = item.Name; break; } } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); }); break; } case > 0: MAdapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Following); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); break; default: { switch (MAdapter.UserList.Count) { case > 10 when !MRecycler.CanScrollVertically(1): Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); break; } break; } } } break; }
private async Task LoadPostDataAsync() { if (Methods.CheckConnectivity()) { switch (TypePost) { case "post_likes": { var countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Posts.GetPostDataAsync(IdPost, "post_liked_users"); switch (apiStatus) { case 200: { switch (respond) { case GetPostDataObject result: { var respondList = result.PostLikedUsers.Count; switch (respondList) { case > 0 when countList > 0: { foreach (var item in from item in result.PostLikedUsers 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; } case > 0: MAdapter.UserList = new ObservableCollection <UserDataObject>(result.PostLikedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); break; default: { switch (MAdapter.UserList.Count) { case > 10 when !MRecycler.CanScrollVertically(1): Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); break; } break; } } break; } } break; } default: Methods.DisplayReportResult(this, respond); break; } break; } case "post_wonders": { var countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Posts.GetPostDataAsync(IdPost, "post_wondered_users"); switch (apiStatus) { case 200: { switch (respond) { case GetPostDataObject result: { var respondList = result.PostWonderedUsers.Count; switch (respondList) { case > 0 when countList > 0: { foreach (var item in from item in result.PostWonderedUsers 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; } case > 0: MAdapter.UserList = new ObservableCollection <UserDataObject>(result.PostWonderedUsers); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); break; default: { switch (MAdapter.UserList.Count) { case > 10 when !MRecycler.CanScrollVertically(1): Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show(); break; } break; } } break; } } break; } default: Methods.DisplayReportResult(this, respond); break; } break; } } RunOnUiThread(ShowEmptyPage); } else { Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection); switch (x.EmptyStateButton.HasOnClickListeners) { case false: x.EmptyStateButton.Click += null !; x.EmptyStateButton.Click += EmptyStateButtonOnClick; break; } Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } }
private async Task LoadArtists(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.UsersList.Count; (int apiStatus, var respond) = await RequestsAsync.User.GetArtistsAsync("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.UsersList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.UsersList.Add(item); } Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UsersList.Count - countList); }); } else { MAdapter.UsersList = new ObservableCollection <UserDataObject>(result.Data?.UserList); Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UsersList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreArtists), ToastLength.Short).Show(); } } } } else { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(Activity, respond); } Activity.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(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); MainScrollEvent.IsLoading = false; } }
private async Task StartSearchRequest() { if (MainScrollEvent.IsLoading) { return; } MainScrollEvent.IsLoading = true; int countUserList = MAdapter.UserList.Count; var dictionary = new Dictionary <string, string> { { "user_id", UserDetails.UserId }, { "limit", "30" }, { "user_offset", OffsetUser }, { "gender", UserDetails.SearchGender }, { "search_key", SearchText }, { "country", UserDetails.SearchCountry }, { "status", UserDetails.SearchStatus }, { "verified", UserDetails.SearchVerified }, { "filterbyage", UserDetails.SearchFilterByAge }, { "age_from", UserDetails.SearchAgeFrom }, { "age_to", UserDetails.SearchAgeTo }, { "image", UserDetails.SearchProfilePicture }, }; (int apiStatus, var respond) = await RequestsAsync.Global.Get_Search(dictionary); if (apiStatus == 200) { if (respond is GetSearchObject result) { var respondUserList = result.Users?.Count; if (respondUserList > 0) { if (countUserList > 0) { foreach (var item in from item in result.Users let check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { MAdapter.UserList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countUserList, MAdapter.UserList.Count - countUserList); }); } else { MAdapter.UserList = new ObservableCollection <UserDataObject>(result.Users); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short).Show(); } } } } else { Methods.DisplayReportResult(this, respond); } RunOnUiThread(ShowEmptyPage); }