private void StartApiService() { if (Methods.CheckConnectivity()) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { LoadDiscover, ApiRequest.GetGenres_Api, () => LoadArtists() }); } else { SwipeRefreshLayout.OnFinishFreshAndLoad(); 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, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } }
private void StartApiService(string offset = "0") { if (Methods.CheckConnectivity()) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => LoadGroupChatAsync(offset) }); } else { SwipeRefreshLayout.Refreshing = false; 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, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show(); } }
private void ShowEmptyPage() { try { MainScrollEvent.IsLoading = false; SwipeRefreshLayout.Refreshing = false; if (MAdapter.CommentList.Count > 0) { MRecycler.Visibility = ViewStates.Visible; EmptyStateLayout.Visibility = ViewStates.Gone; } else { MRecycler.Visibility = ViewStates.Gone; if (Inflated == null) { Inflated = EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoComments); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; } EmptyStateLayout.Visibility = ViewStates.Visible; } } catch (Exception e) { MainScrollEvent.IsLoading = false; SwipeRefreshLayout.Refreshing = false; Console.WriteLine(e); } }
//Get General Data Using Api >> notifications , pro_users , promoted_pages , trending_hashTag public async Task <(string, string, string, string)> LoadGeneralData(bool seenNotifications, string offset = "") { try { switch (MainScrollEvent.IsLoading) { case true: return("", "", "", ""); } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var(apiStatus, respond) = await RequestsAsync.Global.GetGeneralDataAsync(seenNotifications, UserDetails.OnlineUsers, UserDetails.DeviceId, UserDetails.DeviceMsgId, offset); switch (apiStatus) { case 200: { switch (respond) { case GetGeneralDataObject result: Activity?.RunOnUiThread(() => { try { // Notifications var countNotificationsList = MAdapter.NotificationsList.Count; var respondList = result.Notifications.Count; switch (respondList) { case > 0 when countNotificationsList > 0: { var listNew = result.Notifications?.Where(c => !MAdapter.NotificationsList.Select(fc => fc.Id).Contains(c.Id)).ToList(); switch (listNew.Count) { case > 0: { foreach (var notification in listNew) { MAdapter.NotificationsList.Insert(0, notification); } MAdapter.NotifyItemRangeInserted(countNotificationsList - 1, MAdapter.NotificationsList.Count - countNotificationsList); break; } } break; } case > 0: MAdapter.NotificationsList = new ObservableCollection <NotificationObject>(result.Notifications); MAdapter.NotifyDataSetChanged(); break; default: { switch (MAdapter.NotificationsList.Count) { case > 10 when !MRecycler.CanScrollVertically(1): Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreNotifications), ToastLength.Short)?.Show(); break; } break; } } switch (AppSettings.ShowTrendingPage) { case true when GlobalContext.TrendingTab != null: { // FriendRequests var respondListFriendRequests = result?.FriendRequests?.Count; switch (respondListFriendRequests) { case > 0: { ListUtils.FriendRequestsList = new ObservableCollection <UserDataObject>(result.FriendRequests); var checkList = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.FriendRequest); switch (checkList) { case null: { var friendRequests = new Classes.TrendingClass { Id = 400, UserList = new List <UserDataObject>(), Type = Classes.ItemType.FriendRequest }; var list = result.FriendRequests.TakeLast(4).ToList(); switch (list.Count) { case > 0: friendRequests.UserList.AddRange(list); break; } GlobalContext.TrendingTab.MAdapter.TrendingList.Add(friendRequests); GlobalContext.TrendingTab.MAdapter.TrendingList.Add(new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } default: { switch (checkList.UserList.Count) { case < 3: { var list = result.FriendRequests.TakeLast(4).ToList(); switch (list.Count) { case > 0: checkList.UserList.AddRange(list); break; } break; } } break; } } break; } } // TrendingHashtag var respondListHashTag = result?.TrendingHashtag?.Count; switch (respondListHashTag) { case > 0 when AppSettings.ShowTrendingHashTags: { ListUtils.HashTagList = new ObservableCollection <TrendingHashtag>(result.TrendingHashtag); var checkList = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.HashTag); switch (checkList) { case null: { GlobalContext.TrendingTab.MAdapter.TrendingList.Add(new Classes.TrendingClass { Id = 900, Title = Activity.GetText(Resource.String.Lbl_TrendingHashTags), SectionType = Classes.ItemType.HashTag, Type = Classes.ItemType.Section, }); var list = result.TrendingHashtag.Take(5).ToList(); foreach (var item in from item in list let check = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(a => a.HashTags?.Id == item.Id && a.Type == Classes.ItemType.HashTag) where check == null select item) { GlobalContext.TrendingTab.MAdapter.TrendingList.Add(new Classes.TrendingClass { Id = long.Parse(item.Id), HashTags = item, Type = Classes.ItemType.HashTag }); } GlobalContext.TrendingTab.MAdapter.TrendingList.Add(new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } } break; } } // PromotedPages var respondListPromotedPages = result.PromotedPages?.Count; switch (respondListPromotedPages) { case > 0 when AppSettings.ShowPromotedPages: { var checkList = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.ProPage); switch (checkList) { case null: { var proPage = new Classes.TrendingClass { Id = 200, PageList = new List <PageClass>(), Type = Classes.ItemType.ProPage }; foreach (var item in from item in result.PromotedPages let check = proPage.PageList.FirstOrDefault(a => a.PageId == item.PageId) where check == null select item) { proPage.PageList.Add(item); } GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(0, proPage); GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(1, new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } default: { foreach (var item in from item in result.PromotedPages let check = checkList.PageList.FirstOrDefault(a => a.PageId == item.PageId) where check == null select item) { checkList.PageList.Add(item); } break; } } break; } } // ProUsers var respondListProUsers = result?.ProUsers?.Count; switch (respondListProUsers) { case > 0 when AppSettings.ShowProUsersMembers: { var checkList = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.ProUser); switch (checkList) { case null: { var proUser = new Classes.TrendingClass { Id = 100, UserList = new List <UserDataObject>(), Type = Classes.ItemType.ProUser }; foreach (var item in from item in result.ProUsers let check = proUser.UserList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { proUser.UserList.Add(item); } GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(0, proUser); GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(1, new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } default: { foreach (var item in from item in result.ProUsers let check = checkList.UserList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { checkList.UserList.Add(item); } break; } } break; } } switch (AppSettings.ShowInfoCoronaVirus) { case true: { var check = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.CoronaVirus); switch (check) { case null: { var coronaVirus = new Classes.TrendingClass { Id = 20316, Type = Classes.ItemType.CoronaVirus }; GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(0, coronaVirus); GlobalContext.TrendingTab.MAdapter.TrendingList.Insert(1, new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } } break; } } GlobalContext.TrendingTab.MAdapter.NotifyDataSetChanged(); break; } } MainScrollEvent.IsLoading = false; ShowEmptyPage(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }); return(result.NewNotificationsCount, result.NewFriendRequestsCount, result.CountNewMessages, result.Announcement?.AnnouncementClass?.TextDecode); } break; } default: Methods.DisplayReportResult(Activity, respond); break; } Activity?.RunOnUiThread(ShowEmptyPage); MainScrollEvent.IsLoading = false; return("", "", "", ""); } 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(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } } catch (Exception e) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResultTrack(e); } MainScrollEvent.IsLoading = false; return("", "", "", ""); }
private async Task LoadContactsAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.MentionList.Count; (int apiStatus, var respond) = await RequestsAsync.Global.GetFriendsAsync(UserDetails.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 from item in result.DataFriends.Following let check = MAdapter.MentionList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { MAdapter.MentionList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.MentionList.Count - countList); }); } else { MAdapter.MentionList = new ObservableCollection <UserDataObject>(result.DataFriends.Following); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.MentionList.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; }
public async Task GetPost(string offset = "0") { if (PostTab.MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { PostTab.MainScrollEvent.IsLoading = true; int countList = PostTab.MAdapter.PostList.Count; (int apiStatus, var respond) = await RequestsAsync.Post.FetchUserPostsById(UserId, "24", offset); if (apiStatus.Equals(200)) { if (respond is FetchUserPostsByUserIdObject result) { var respondList = result.data.UserPosts.Count; if (respondList > 0) { result.data.UserPosts.RemoveAll(a => a.MediaSet?.Count == 0 && a.MediaSet == null); if (countList > 0) { foreach (var item in from item in result.data.UserPosts let check = PostTab.MAdapter.PostList.FirstOrDefault(a => a.PostId == item.PostId) where check == null select item) { item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4); PostTab.MAdapter.PostList.Add(item); } Activity.RunOnUiThread(() => { PostTab.MAdapter.NotifyItemRangeInserted(countList - 1, PostTab.MAdapter.PostList.Count - countList); }); } else { PostTab.MAdapter.PostList = new ObservableCollection <PostsObject>(result.data.UserPosts); Activity.RunOnUiThread(() => { PostTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (PostTab.MAdapter.PostList.Count > 10 && !PostTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_NoMorePost), ToastLength.Short).Show(); } } } } else { Methods.DisplayReportResult(Activity, respond); } Activity.RunOnUiThread(() => { ShowEmptyPage("GetPost"); }); } else { PostTab.Inflated = PostTab.EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(PostTab.Inflated, EmptyStateInflater.Type.NoConnection); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += EmptyStateButtonOnClick; } Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); PostTab.MainScrollEvent.IsLoading = false; } PostTab.MainScrollEvent.IsLoading = false; }
private async Task LoadUsersAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; if (UserDetails.Lat == "" && UserDetails.Lng == "") { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000)); Console.WriteLine("Position Status: {0}", position.Timestamp); Console.WriteLine("Position Latitude: {0}", position.Latitude); Console.WriteLine("Position Longitude: {0}", position.Longitude); UserDetails.Lat = position.Latitude.ToString(CultureInfo.InvariantCulture); UserDetails.Lng = position.Longitude.ToString(CultureInfo.InvariantCulture); } UserDetails.Location = ListUtils.MyUserInfo.FirstOrDefault()?.Location; var dictionary = new Dictionary <string, string> { { "limit", "35" }, { "offset", offset }, { "_gender", UserDetails.Gender }, { "_located", UserDetails.Located }, { "_location", UserDetails.Location }, { "_age_from", UserDetails.AgeMin.ToString() }, { "_age_to", UserDetails.AgeMax.ToString() }, { "_lat", UserDetails.Lat }, { "_lng", UserDetails.Lng }, { "_body", UserDetails.Body ?? "" }, { "_ethnicity", UserDetails.Ethnicity ?? "" }, { "_religion", UserDetails.Religion ?? "" }, { "_drink", UserDetails.Drink ?? "" }, { "_smoke", UserDetails.Smoke ?? "" }, { "_education", UserDetails.Education ?? "" }, { "_pets", UserDetails.Pets ?? "" }, { "_relationship", UserDetails.RelationShip ?? "" }, { "_language", UserDetails.Language ?? "english" }, { "_interest", UserDetails.Interest ?? "" }, { "_height_from", UserDetails.FromHeight ?? "139" }, { "_height_to", UserDetails.ToHeight ?? "220" }, }; int countList = AppSettings.ShowUsersAsCards ? CardDateAdapter2.UsersDateList.Count : NearByAdapter.NearByList.Count; var(apiStatus, respond) = await RequestsAsync.Users.SearchAsync(dictionary); if (apiStatus != 200 || !(respond is ListUsersObject result) || result.Data == null) { Methods.DisplayReportResult(Activity, respond); } else { var respondList = result.Data.Count; if (respondList > 0) { foreach (var item in from item in result.Data let check = AppSettings.ShowUsersAsCards ? CardDateAdapter2.UsersDateList.FirstOrDefault(a => a.Id == item.Id) : NearByAdapter.NearByList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { if (UserDetails.SwitchState) { var online = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online); if (!online) { continue; } if (AppSettings.ShowUsersAsCards) { CardDateAdapter2.UsersDateList.Add(item); } else { NearByAdapter.NearByList.Add(item); } } else { if (AppSettings.ShowUsersAsCards) { CardDateAdapter2.UsersDateList.Add(item); } else { NearByAdapter.NearByList.Add(item); } } } if (AppSettings.ShowUsersAsCards) { if (countList > 0) { Activity.RunOnUiThread(() => CardDateAdapter2.NotifyItemRangeInserted(countList - 1, CardDateAdapter2.UsersDateList.Count - countList)); } else { Activity.RunOnUiThread(() => CardDateAdapter2.NotifyDataSetChanged()); } } else { if (countList > 0) { Activity.RunOnUiThread(() => NearByAdapter.NotifyItemRangeInserted(countList - 1, NearByAdapter.NearByList.Count - countList)); } else { Activity.RunOnUiThread(() => NearByAdapter.NotifyDataSetChanged()); } } } else { if (AppSettings.ShowUsersAsCards) { if (CardDateAdapter2.UsersDateList.Count > 10 && !NearByRecyclerView.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show(); } } else { if (NearByAdapter.NearByList.Count > 10 && !NearByRecyclerView.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show(); } } } } 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(); MainScrollEvent.IsLoading = false; } MainScrollEvent.IsLoading = false; }
private void SetDataAlbums() { try { AlbumsId = Arguments.GetString("AlbumsId") ?? ""; if (!string.IsNullOrEmpty(AlbumsId)) { AlbumsObject = JsonConvert.DeserializeObject <DataAlbumsObject>(Arguments.GetString("ItemData") ?? ""); if (AlbumsObject != null) { var d = AlbumsObject.Title.Replace("<br>", ""); AlbumName.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(d), 80); var count = !string.IsNullOrEmpty(AlbumsObject.CountSongs) ? AlbumsObject.CountSongs : AlbumsObject.SongsCount ?? "0"; var text = count + " " + Context.GetText(Resource.String.Lbl_Songs); if (AppSettings.ShowCountPurchases) { text = text + " - " + AlbumsObject.Purchases + " " + Context.GetText(Resource.String.Lbl_Purchases); } CountSoungAlbumText.Text = text; NameUserText.Text = DeepSoundTools.GetNameFinal(AlbumsObject.Publisher ?? AlbumsObject.UserData); var imageUrl = AlbumsObject.Thumbnail; FullGlideRequestBuilder.Load(imageUrl).Into(ImageCover); FullGlideRequestBuilder.Load(imageUrl).Into(ImageAlbum); if (AlbumsObject.Publisher != null) { Glide.With(this).AsBitmap().Apply(GlideRequestOptions).Load(AlbumsObject.Publisher.Avatar).Into(ImageAvatar); } else { Glide.With(this).AsBitmap().Apply(GlideRequestOptions).Load(AlbumsObject.UserData.Avatar).Into(ImageAvatar); } if (AlbumsObject.IsOwner != null && Math.Abs(AlbumsObject.Price) > 0 && !AlbumsObject.IsOwner.Value && AlbumsObject.IsPurchased == 0) { BuyButton.Visibility = ViewStates.Visible; MRecycler.Visibility = ViewStates.Gone; Inflated ??= EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSoundWithPaid); EmptyStateLayout.Visibility = ViewStates.Visible; } else { BuyButton.Visibility = ViewStates.Gone; StartApiService(); } } } } catch (Exception e) { Console.WriteLine(e); } }
private async Task GetMyGroups() { if (Methods.CheckConnectivity()) { var(apiStatus, respond) = await RequestsAsync.Group.GetMyGroups("0", "7"); if (apiStatus != 200 || !(respond is ListGroupsObject result) || result.Data == null) { Methods.DisplayReportResult(this, respond); } else { var respondList = result.Data.Count; if (respondList > 0) { result.Data.Reverse(); var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.MangedGroups); if (checkList == null) { var socialSection = new SocialModelsClass { Id = 0001111111, MangedGroupsModel = new GroupsModelClass { GroupsList = new List <GroupClass>(), More = "", TitleHead = GetString(Resource.String.Lbl_Manage_Groups) }, TypeView = SocialModelType.MangedGroups }; foreach (var item in from item in result.Data let check = socialSection.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item) { socialSection.MangedGroupsModel.GroupsList.Add(item); ListUtils.MyGroupList.Add(item); } MAdapter.SocialList.Insert(0, socialSection); } else { foreach (var item in from item in result.Data let check = checkList.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item) { checkList.MangedGroupsModel.GroupsList.Add(item); ListUtils.MyGroupList.Add(item); } } await GetJoinedGroups(); 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 LoadDataAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var(apiStatus, respond) = await RequestsAsync.Video.Get_Subscriptions_VideosOrChannel_Http("false", offset, "20"); if (apiStatus != 200 || !(respond is GetVideosListObject result) || result.VideoList == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(Activity, respond); } else { var respondList = result.VideoList.Count; if (respondList > 0) { result.VideoList = AppTools.ListFilter(result.VideoList); foreach (var users in from item in result.VideoList let check = MAdapter.SubscriptionsList.FirstOrDefault(a => a.VideoData?.VideoId == item.VideoId) where check == null select new Classes.SubscriptionsClass() { Id = Convert.ToInt32(item.Id), VideoData = item, Type = ItemType.Video }) { MAdapter.SubscriptionsList.Add(users); } } else { if (MAdapter.SubscriptionsList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreVideos), ToastLength.Short).Show(); } } } 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(); } MainScrollEvent.IsLoading = false; }
private void ShowEmptyPage(string type) { try { if (type == "Event") { EventTab.MainScrollEvent.IsLoading = false; EventTab.SwipeRefreshLayout.Refreshing = false; if (EventTab.MAdapter.EventList.Count > 0) { EventTab.MRecycler.Visibility = ViewStates.Visible; EventTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { EventTab.MRecycler.Visibility = ViewStates.Gone; if (EventTab.Inflated == null) { EventTab.Inflated = EventTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(EventTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } EventTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "Going") { GoingTab.MainScrollEvent.IsLoading = false; GoingTab.SwipeRefreshLayout.Refreshing = false; if (GoingTab.MAdapter.EventList.Count > 0) { GoingTab.MRecycler.Visibility = ViewStates.Visible; GoingTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { GoingTab.MRecycler.Visibility = ViewStates.Gone; if (GoingTab.Inflated == null) { GoingTab.Inflated = GoingTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(GoingTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } GoingTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "Invited") { InvitedTab.MainScrollEvent.IsLoading = false; InvitedTab.SwipeRefreshLayout.Refreshing = false; if (InvitedTab.MAdapter.EventList.Count > 0) { InvitedTab.MRecycler.Visibility = ViewStates.Visible; InvitedTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { InvitedTab.MRecycler.Visibility = ViewStates.Gone; if (InvitedTab.Inflated == null) { InvitedTab.Inflated = InvitedTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(InvitedTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } InvitedTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "Interested") { InterestedTab.MainScrollEvent.IsLoading = false; InterestedTab.SwipeRefreshLayout.Refreshing = false; if (InterestedTab.MAdapter.EventList.Count > 0) { InterestedTab.MRecycler.Visibility = ViewStates.Visible; InterestedTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { InterestedTab.MRecycler.Visibility = ViewStates.Gone; if (InterestedTab.Inflated == null) { InterestedTab.Inflated = InterestedTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(InterestedTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } InterestedTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "Past") { PastTab.MainScrollEvent.IsLoading = false; PastTab.SwipeRefreshLayout.Refreshing = false; if (PastTab.MAdapter.EventList.Count > 0) { PastTab.MRecycler.Visibility = ViewStates.Visible; PastTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { PastTab.MRecycler.Visibility = ViewStates.Gone; if (PastTab.Inflated == null) { PastTab.Inflated = PastTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(PastTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } PastTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "MyEvent") { MyEventTab.MainScrollEvent.IsLoading = false; MyEventTab.SwipeRefreshLayout.Refreshing = false; if (MyEventTab.MAdapter.EventList.Count > 0) { MyEventTab.MRecycler.Visibility = ViewStates.Visible; MyEventTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { MyEventTab.MRecycler.Visibility = ViewStates.Gone; if (MyEventTab.Inflated == null) { MyEventTab.Inflated = MyEventTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(MyEventTab.Inflated, EmptyStateInflater.Type.NoEvent); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += BtnCreateEventsOnClick; } MyEventTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } } catch (Exception e) { Console.WriteLine(e); } }
private async Task GetEvent(string offset = "0", string typeEvent = "events") { if (typeEvent == "events" && EventTab.MainScrollEvent != null && EventTab.MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { var dictionary = new Dictionary <string, string>(); switch (typeEvent) { case "events": dictionary.Add("offset", offset); dictionary.Add("fetch", "events"); if (EventTab?.MainScrollEvent != null) { EventTab.MainScrollEvent.IsLoading = true; } break; case "going": dictionary.Add("going_offset", offset); dictionary.Add("fetch", "going"); if (AppSettings.ShowEventGoing && GoingTab?.MainScrollEvent != null) { GoingTab.MainScrollEvent.IsLoading = true; } break; case "past": dictionary.Add("past_offset", offset); dictionary.Add("fetch", "past"); if (AppSettings.ShowEventPast && PastTab?.MainScrollEvent != null) { PastTab.MainScrollEvent.IsLoading = true; } break; case "myEvent": dictionary.Add("my_offset", offset); dictionary.Add("fetch", "my_events"); if (MyEventTab?.MainScrollEvent != null) { MyEventTab.MainScrollEvent.IsLoading = true; } break; case "interested": dictionary.Add("interested_offset", offset); dictionary.Add("fetch", "interested"); if (AppSettings.ShowEventInterested && InterestedTab?.MainScrollEvent != null) { InterestedTab.MainScrollEvent.IsLoading = true; } break; case "invited": dictionary.Add("invited_offset", offset); dictionary.Add("fetch", "invited"); if (AppSettings.ShowEventInvited && InvitedTab?.MainScrollEvent != null) { InvitedTab.MainScrollEvent.IsLoading = true; } break; } (int apiStatus, var respond) = await RequestsAsync.Event.Get_Events(dictionary); if (apiStatus.Equals(200)) { if (respond is GetEventsObject result) { //Events //============================================================== if (typeEvent == "events" && EventTab != null) { int countList = EventTab.MAdapter.EventList.Count; var respondList = result.Events.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.Events let check = EventTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { EventTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { EventTab.MAdapter.NotifyItemRangeInserted(countList, EventTab.MAdapter.EventList.Count - countList); }); } else { EventTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.Events); RunOnUiThread(() => { EventTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (EventTab.MAdapter.EventList.Count > 10 && !EventTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("Event"); }); } //Going //============================================================== if (AppSettings.ShowEventGoing && typeEvent == "going" && GoingTab != null) { int countGoingList = GoingTab.MAdapter.EventList.Count; var respondGoingList = result.Going.Count; if (respondGoingList > 0) { if (countGoingList > 0) { foreach (var item in from item in result.Going let check = GoingTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { GoingTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { GoingTab.MAdapter.NotifyItemRangeInserted(countGoingList - 1, GoingTab.MAdapter.EventList.Count - countGoingList); }); } else { GoingTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.Going); RunOnUiThread(() => { GoingTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (GoingTab.MAdapter.EventList.Count > 10 && !GoingTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("Going"); }); } //Invited //============================================================== if (AppSettings.ShowEventInvited && typeEvent == "invited" && InvitedTab != null) { int countInvitedList = InvitedTab.MAdapter.EventList.Count; var respondInvitedList = result.Invited.Count; if (respondInvitedList > 0) { if (countInvitedList > 0) { foreach (var item in from item in result.Invited let check = InvitedTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { InvitedTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { InvitedTab.MAdapter.NotifyItemRangeInserted(countInvitedList - 1, InvitedTab.MAdapter.EventList.Count - countInvitedList); }); } else { InvitedTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.Invited); RunOnUiThread(() => { InvitedTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (InvitedTab.MAdapter.EventList.Count > 10 && !InvitedTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("Invited"); }); } //Interested //============================================================== if (AppSettings.ShowEventInterested && typeEvent == "interested" && InterestedTab != null) { int countInterestedList = InterestedTab.MAdapter.EventList.Count; var respondInterestedList = result.Interested.Count; if (respondInterestedList > 0) { if (countInterestedList > 0) { foreach (var item in from item in result.Interested let check = InterestedTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { InterestedTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { InterestedTab.MAdapter.NotifyItemRangeInserted(countInterestedList - 1, InterestedTab.MAdapter.EventList.Count - countInterestedList); }); } else { InterestedTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.Interested); RunOnUiThread(() => { InterestedTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (InterestedTab.MAdapter.EventList.Count > 10 && !InterestedTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("Interested"); }); } //Past //============================================================== if (AppSettings.ShowEventPast && typeEvent == "past" && PastTab != null) { int countPastList = PastTab.MAdapter.EventList.Count; var respondPastList = result.Past.Count; if (respondPastList > 0) { if (countPastList > 0) { foreach (var item in from item in result.Past let check = PastTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { PastTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { PastTab.MAdapter.NotifyItemRangeInserted(countPastList - 1, PastTab.MAdapter.EventList.Count - countPastList); }); } else { PastTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.Past); RunOnUiThread(() => { PastTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (PastTab.MAdapter.EventList.Count > 10 && !PastTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("Past"); }); } //My Event //============================================================== if (typeEvent == "myEvent" && MyEventTab != null) { int myEventsCountList = MyEventTab.MAdapter.EventList.Count; var myEventsList = result.MyEvents.Count; if (myEventsList > 0) { if (myEventsCountList > 0) { foreach (var item in from item in result.MyEvents let check = MyEventTab.MAdapter.EventList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MyEventTab.MAdapter.EventList.Add(item); } RunOnUiThread(() => { MyEventTab.MAdapter.NotifyItemRangeInserted(myEventsCountList - 1, MyEventTab.MAdapter.EventList.Count - myEventsCountList); }); } else { MyEventTab.MAdapter.EventList = new ObservableCollection <EventDataObject>(result.MyEvents); RunOnUiThread(() => { MyEventTab.MAdapter.NotifyDataSetChanged(); }); } } else { if (MyEventTab.MAdapter.EventList.Count > 10 && !MyEventTab.MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreEvent), ToastLength.Short).Show(); } } RunOnUiThread(() => { ShowEmptyPage("MyEvent"); }); } } } else { Methods.DisplayReportResult(this, respond); } } else { if (MyEventTab != null) { if (EventTab.Inflated == null) { EventTab.Inflated = EventTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(EventTab.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(); if (EventTab?.MainScrollEvent != null) { EventTab.MainScrollEvent.IsLoading = false; } } } }
private async Task GetCommunitiesListPageApi() { try { if (Methods.CheckConnectivity()) { var(apiStatus, respond) = await RequestsAsync.Global.Get_Community(UserId, "pages,liked_pages"); if (apiStatus != 200 || !(respond is GetCommunityObject result) || result.Pages == null) { Methods.DisplayReportResult(this, respond); } else { SwipeRefreshLayout.Refreshing = false; var checkModel = MAdapter.SocialList.FirstOrDefault(a => a.TypeView == SocialModelType.MangedPages); if (result.Pages.Count > 0) { if (checkModel == null) { var chkList = result.Pages.Where(a => a.UserId == UserDetails.UserId).ToList(); if (chkList.Count > 0) { ListUtils.MyPageList = new ObservableCollection <PageClass>(chkList); var socialSection = new SocialModelsClass { PagesModelClass = new PagesModelClass { PagesList = new List <PageClass>(chkList), More = "", TitleHead = GetString(Resource.String.Lbl_Manage_Pages) }, Id = 11111111, TypeView = SocialModelType.MangedPages }; MAdapter.SocialList.Add(socialSection); } } } var section = new SocialModelsClass { Id = 000001010101, TitleHead = GetString(Resource.String.Lbl_Liked_Pages), TypeView = SocialModelType.Section }; MAdapter.SocialList.Add(section); if (result.LikedPagesList.Count > 0) { foreach (var page in result.LikedPagesList) { if (page.UserId == UserDetails.UserId) { checkModel?.PagesModelClass.PagesList.Add(page); } else { var socialSection = new SocialModelsClass { PageData = page, Id = int.Parse(page.Id), TypeView = SocialModelType.LikedPages }; page.IsLiked = "true"; MAdapter.SocialList.Add(socialSection); } } } 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(); } } catch (Exception e) { Console.WriteLine(e); } }
private async Task LoadDataAsync(string offset = "0", string lastCount = "") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.ChannelList.Count; var(apiStatus, respond) = await RequestsAsync.Video.PopularChannels_Http("25", lastCount, offset, UserDetails.FilterTypeSortBy, UserDetails.FilterTime); if (apiStatus != 200 || !(respond is GetPopularChannelsObject result) || result.Channels == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(Activity, respond); } else { var respondList = result.Channels.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in result.Channels) { var check = MAdapter.ChannelList.FirstOrDefault(a => a.UserData?.Id == item.UserData?.Id); if (check == null) { MAdapter.ChannelList.Add(item); } } Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.ChannelList.Count - countList); }); } else { MAdapter.ChannelList = new ObservableCollection <GetPopularChannelsObject.Channel>(result.Channels); Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.ChannelList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreChannels), ToastLength.Short).Show(); } } } 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(); } MainScrollEvent.IsLoading = false; }
private async Task LoadOffers(string offset) { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var countList = MAdapter.OffersList.Count; var(respondCode, respondString) = await RequestsAsync.Offers.FetchOffersPost("15", offset); if (respondCode.Equals(200)) { if (respondString is FetchOffersObject result) { var respondList = result.Data.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.Data let check = MAdapter.OffersList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.OffersList.Add(item); } RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.OffersList.Count - countList); }); } else { MAdapter.OffersList = new ObservableCollection <OffersDataObject>(result.Data); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.OffersList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreOffers), ToastLength.Short).Show(); } } } } else { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respondString); } 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 LoadDataAsync(string topOffset = "0", string latestOffset = "0", string favOffset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.VideoList.Count; var(apiStatus, respond) = await RequestsAsync.Video.Get_Videos_Http("0", topOffset, latestOffset, favOffset, "25"); if (apiStatus != 200 || !(respond is GetVideosObject result) || result.DataResult == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(Activity, respond); } else { int respondList = 0; if (TypeVideo.Contains("Top")) { result.DataResult.Top = AppTools.ListFilter(new List <VideoObject>(result.DataResult.Top)); respondList = result.DataResult.Top.Count; } else if (TypeVideo.Contains("Latest")) { result.DataResult.Latest = AppTools.ListFilter(new List <VideoObject>(result.DataResult.Latest)); respondList = result.DataResult.Latest.Count; } else if (TypeVideo.Contains("Fav")) { result.DataResult.Fav = AppTools.ListFilter(new List <VideoObject>(result.DataResult.Fav)); respondList = result.DataResult.Fav.Count; } if (respondList > 0) { if (countList > 0) { if (TypeVideo.Contains("Top")) { foreach (var item in from item in result.DataResult.Top let check = MAdapter.VideoList.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item) { MAdapter.VideoList.Add(item); } } else if (TypeVideo.Contains("Latest")) { foreach (var item in from item in result.DataResult.Latest let check = MAdapter.VideoList.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item) { MAdapter.VideoList.Add(item); } } else if (TypeVideo.Contains("Fav")) { foreach (var item in from item in result.DataResult.Fav let check = MAdapter.VideoList.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item) { MAdapter.VideoList.Add(item); } } Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } else { if (TypeVideo.Contains("Top")) { MAdapter.VideoList = new ObservableCollection <VideoObject>(result.DataResult.Top); } else if (TypeVideo.Contains("Latest")) { MAdapter.VideoList = new ObservableCollection <VideoObject>(result.DataResult.Latest); } else if (TypeVideo.Contains("Fav")) { MAdapter.VideoList = new ObservableCollection <VideoObject>(result.DataResult.Fav); } Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.VideoList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreVideos), ToastLength.Short).Show(); } } } 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(); } MainScrollEvent.IsLoading = false; }
private async Task LoadDataAsync(string offset = "") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.FavoritesList.Count; (int apiStatus, var respond) = await RequestsAsync.Post.FetchFavoritePosts("24", offset); if (apiStatus != 200 || !(respond is FetchFavoritePostsObject 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); if (countList > 0) { foreach (var item in from item in result.Data let check = MAdapter.FavoritesList.FirstOrDefault(a => a.PostId == item.PostId) where check == null select item) { item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4); MAdapter.FavoritesList.Add(item); } Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.FavoritesList.Count - countList); }); } else { MAdapter.FavoritesList = new ObservableCollection <PostsObject>(result.Data); Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.FavoritesList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMorePost), ToastLength.Short).Show(); } } } 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(); MainScrollEvent.IsLoading = false; } MainScrollEvent.IsLoading = false; }
private async void Run() { try { if (Methods.CheckConnectivity()) { var(apiStatus, respond) = await RequestsAsync.User.ProfileAsync(UserId, "followers,following,albums,activities,latest_songs,top_songs,store").ConfigureAwait(false); if (apiStatus.Equals(200)) { if (respond is ProfileObject result) { if (result.Data != null) { DataUser = result.Data; Activity.RunOnUiThread(() => { try { LoadDataUser(); if (result.details != null) { DetailsCounter = result.details; TxtCountFollowers.Text = Methods.FunString.FormatPriceValue(result.details.Followers); TxtCountFollowing.Text = Methods.FunString.FormatPriceValue(result.details.Following); TxtCountTracks.Text = Methods.FunString.FormatPriceValue(result.details.TopSongs); } } catch (Exception e) { Console.WriteLine(e); } }); //Add Latest Songs if (result.Data?.Latestsongs?.Count > 0) { LatestSongsAdapter.SoundsList = new ObservableCollection <SoundDataObject>(result.Data?.Latestsongs); } //Add Latest Songs if (result.Data?.TopSongs?.Count > 0) { TopSongsAdapter.SoundsList = new ObservableCollection <SoundDataObject>(result.Data?.TopSongs); } //Add Albums if (result.Data?.Albums?.Count > 0) { AlbumsAdapter.AlbumsList = new ObservableCollection <DataAlbumsObject>(result.Data?.Albums); } //Add Store if (result.Data?.Store?.Count > 0) { StoreAdapter.SoundsList = new ObservableCollection <SoundDataObject>(result.Data?.Store); } //Add Activities if (result.Data?.Activities?.Count > 0) { ActivitiesAdapter.ActivityList = new ObservableCollection <ActivityDataObject>(result.Data.Activities); } //SqLiteDatabase dbDatabase = new SqLiteDatabase(); //dbDatabase.InsertOrUpdate_DataMyInfo(result.Data); //dbDatabase.Dispose(); } } } else { Methods.DisplayReportResult(Activity, respond); } Activity.RunOnUiThread(ShowEmptyPage); } else { Activity.RunOnUiThread(() => { 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(); }); } } catch (Exception e) { Console.WriteLine(e); } }
private async Task GetJoinedGroups(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var(apiStatus, respond) = await RequestsAsync.Group.GetJoinedGroups(UserDetails.UserId, offset, "10"); if (apiStatus != 200 || !(respond is ListGroupsObject result) || result.Data == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.Data.Count; if (respondList > 0) { var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.JoinedGroups); if (checkList == null) { var section = new SocialModelsClass { Id = 000001010101, TitleHead = GetString(Resource.String.Lbl_Joined_Groups), TypeView = SocialModelType.Section }; MAdapter.SocialList.Insert(1, section); foreach (var item in from item in result.Data let check = MAdapter.SocialList.FirstOrDefault(a => a.Id == Convert.ToInt32(item.GroupId)) where check == null select item) { item.IsJoined = new IsJoined { Bool = true }; MAdapter.SocialList.Add(new SocialModelsClass { GroupData = item, Id = Convert.ToInt32(item.GroupId), TypeView = SocialModelType.JoinedGroups }); } } else { foreach (var item in from item in result.Data let check = MAdapter.SocialList.FirstOrDefault(a => a.Id == Convert.ToInt32(item.GroupId)) where check == null select item) { item.IsJoined = new IsJoined { Bool = true }; MAdapter.SocialList.Add(new SocialModelsClass { GroupData = item, Id = Convert.ToInt32(item.GroupId), TypeView = SocialModelType.JoinedGroups }); } } } else { if (MAdapter.SocialList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short)?.Show(); } } } MainScrollEvent.IsLoading = false; 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 void ShowEmptyPage() { try { LoadingLayout.Visibility = ViewStates.Gone; if (LatestSongsAdapter.SoundsList?.Count > 0) { if (LatestSongsInflated == null) { LatestSongsInflated = LatestSongsViewStub.Inflate(); } TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater(); recyclerInflater.InflateLayout <SoundDataObject>(Activity, LatestSongsInflated, LatestSongsAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_LatestSongs_Title)); if (!recyclerInflater.MainLinear.HasOnClickListeners) { recyclerInflater.MainLinear.Click += null; recyclerInflater.MainLinear.Click += LatestSongsMoreOnClick; } } if (TopSongsAdapter.SoundsList?.Count > 0) { if (TopSongsInflated == null) { TopSongsInflated = TopSongsViewStub.Inflate(); } TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater(); recyclerInflater.InflateLayout <SoundDataObject>(Activity, TopSongsInflated, TopSongsAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_TopSongs_Title)); if (!recyclerInflater.MainLinear.HasOnClickListeners) { recyclerInflater.MainLinear.Click += null; recyclerInflater.MainLinear.Click += TopSongsMoreOnClick; } } if (AlbumsAdapter.AlbumsList?.Count > 0) { if (AlbumsInflated == null) { AlbumsInflated = AlbumsViewStub.Inflate(); } TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater(); recyclerInflater.InflateLayout <DataAlbumsObject>(Activity, AlbumsInflated, AlbumsAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_Albums)); if (!recyclerInflater.MainLinear.HasOnClickListeners) { recyclerInflater.MainLinear.Click += null; recyclerInflater.MainLinear.Click += AlbumsMoreOnClick; } } if (StoreAdapter.SoundsList?.Count > 0) { if (StoreInflated == null) { StoreInflated = StoreViewStub.Inflate(); } TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater(); recyclerInflater.InflateLayout <SoundDataObject>(Activity, StoreInflated, StoreAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_Store_Title)); if (!recyclerInflater.MainLinear.HasOnClickListeners) { recyclerInflater.MainLinear.Click += null; recyclerInflater.MainLinear.Click += StoreMoreOnClick; } } if (ActivitiesAdapter.ActivityList?.Count > 0) { if (ActivitiesInflated == null) { ActivitiesInflated = ActivitiesViewStub.Inflate(); } TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater(); recyclerInflater.InflateLayout <ActivityDataObject>(Activity, ActivitiesInflated, ActivitiesAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerVertical, 0, true, Context.GetText(Resource.String.Lbl_Activities_Title)); if (!recyclerInflater.MainLinear.HasOnClickListeners) { recyclerInflater.MainLinear.Click += null; recyclerInflater.MainLinear.Click += ActivitiesMoreOnClick; } } if (LatestSongsAdapter.SoundsList?.Count == 0 && TopSongsAdapter.SoundsList?.Count == 0 && AlbumsAdapter.AlbumsList?.Count == 0 && StoreAdapter.SoundsList?.Count == 0 && ActivitiesAdapter.ActivityList?.Count == 0) { if (Inflated == null) { Inflated = EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSound); if (x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; } EmptyStateLayout.Visibility = ViewStates.Visible; } } catch (Exception e) { LoadingLayout.Visibility = ViewStates.Gone; Console.WriteLine(e); } }
private async Task LoadAlbumsSongs() { if (Methods.CheckConnectivity()) { int countList = MAdapter.SoundsList.Count; (int apiStatus, var respond) = await RequestsAsync.Albums.GetAlbumSongsAsync(AlbumsId); if (apiStatus == 200) { if (respond is GetAlbumSongsObject result) { var respondList = result.Songs?.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.Songs let check = MAdapter.SoundsList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.SoundsList.Add(item); } Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.SoundsList.Count - countList); }); } else { MAdapter.SoundsList = new ObservableCollection <SoundDataObject>(result.Songs); Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.SoundsList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreSongs), ToastLength.Short).Show(); } } } } else { 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(); } }
private void SearchViewOnQueryTextSubmit(string newText) { try { SearchText = newText; SearchView.ClearFocus(); UserTab.MAdapter.UserList.Clear(); UserTab.MAdapter.NotifyDataSetChanged(); PagesTab.MAdapter.PageList.Clear(); PagesTab.MAdapter.NotifyDataSetChanged(); GroupsTab.MAdapter.GroupList.Clear(); GroupsTab.MAdapter.NotifyDataSetChanged(); OffsetUser = "******"; OffsetPage = "0"; OffsetGroup = "0"; if (Methods.CheckConnectivity()) { if (UserTab.ProgressBarLoader != null) { UserTab.ProgressBarLoader.Visibility = ViewStates.Visible; } if (PagesTab.ProgressBarLoader != null) { PagesTab.ProgressBarLoader.Visibility = ViewStates.Visible; } if (GroupsTab.ProgressBarLoader != null) { GroupsTab.ProgressBarLoader.Visibility = ViewStates.Visible; } UserTab.EmptyStateLayout.Visibility = ViewStates.Gone; PagesTab.EmptyStateLayout.Visibility = ViewStates.Gone; GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone; StartApiService(); } else { if (UserTab.Inflated == null) { UserTab.Inflated = UserTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoConnection); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click -= EmptyStateButtonOnClick; x.EmptyStateButton.Click -= TryAgainButton_Click; x.EmptyStateButton.Click += null; } x.EmptyStateButton.Click += TryAgainButton_Click; UserTab.ProgressBarLoader.Visibility = ViewStates.Gone; UserTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } catch (Exception exception) { Console.WriteLine(exception); } }
private async Task LoadComments(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.CommentList.Count; (int apiStatus, var respond) = await RequestsAsync.Comments.GetCommentAsync(DataObject.Id.ToString(), "20", offset); if (apiStatus == 200) { if (respond is CommentsObject result) { var respondList = result.dataComments?.Data?.Count; if (respondList > 0) { if (countList > 0) { foreach (var item in from item in result.dataComments?.Data let check = MAdapter.CommentList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.CommentList.Add(item); } ActivityContext.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.CommentList.Count - countList); }); } else { MAdapter.CommentList = new ObservableCollection <CommentsDataObject>(result.dataComments?.Data); ActivityContext.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.CommentList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_NoMoreComment), ToastLength.Short).Show(); } } } } else { Methods.DisplayReportResult(ActivityContext, respond); } ActivityContext.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(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); MainScrollEvent.IsLoading = false; } MainScrollEvent.IsLoading = false; }
public void Search(string text) { try { SearchText = text; if (!string.IsNullOrEmpty(SearchText)) { if (Methods.CheckConnectivity()) { UserTab.MAdapter?.UserList?.Clear(); UserTab.MAdapter?.NotifyDataSetChanged(); PagesTab.MAdapter?.PageList?.Clear(); PagesTab.MAdapter?.NotifyDataSetChanged(); GroupsTab.MAdapter?.GroupList?.Clear(); GroupsTab.MAdapter?.NotifyDataSetChanged(); if (UserTab.ProgressBarLoader != null) { UserTab.ProgressBarLoader.Visibility = ViewStates.Visible; } if (PagesTab.ProgressBarLoader != null) { PagesTab.ProgressBarLoader.Visibility = ViewStates.Visible; } if (GroupsTab.ProgressBarLoader != null) { GroupsTab.ProgressBarLoader.Visibility = ViewStates.Visible; } UserTab.EmptyStateLayout.Visibility = ViewStates.Gone; PagesTab.EmptyStateLayout.Visibility = ViewStates.Gone; GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone; StartApiService(); } } else { if (UserTab.Inflated == null) { UserTab.Inflated = UserTab.EmptyStateLayout?.Inflate(); } EmptyStateInflater x1 = new EmptyStateInflater(); x1.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x1.EmptyStateButton.HasOnClickListeners) { x1.EmptyStateButton.Click -= EmptyStateButtonOnClick; x1.EmptyStateButton.Click -= TryAgainButton_Click; x1.EmptyStateButton.Click += null; } x1.EmptyStateButton.Click += TryAgainButton_Click; if (UserTab.EmptyStateLayout != null) { UserTab.EmptyStateLayout.Visibility = ViewStates.Visible; } UserTab.ProgressBarLoader.Visibility = ViewStates.Gone; //============================================== if (PagesTab.Inflated == null) { PagesTab.Inflated = PagesTab.EmptyStateLayout?.Inflate(); } EmptyStateInflater x2 = new EmptyStateInflater(); x2.InflateLayout(PagesTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x2.EmptyStateButton.HasOnClickListeners) { x2.EmptyStateButton.Click -= EmptyStateButtonOnClick; x2.EmptyStateButton.Click -= TryAgainButton_Click; x2.EmptyStateButton.Click += null; } x2.EmptyStateButton.Click += TryAgainButton_Click; if (PagesTab.EmptyStateLayout != null) { PagesTab.EmptyStateLayout.Visibility = ViewStates.Visible; } PagesTab.ProgressBarLoader.Visibility = ViewStates.Gone; //============================================== if (GroupsTab.Inflated == null) { GroupsTab.Inflated = GroupsTab.EmptyStateLayout?.Inflate(); } EmptyStateInflater x3 = new EmptyStateInflater(); x3.InflateLayout(GroupsTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x3.EmptyStateButton.HasOnClickListeners) { x3.EmptyStateButton.Click -= EmptyStateButtonOnClick; x3.EmptyStateButton.Click -= TryAgainButton_Click; x3.EmptyStateButton.Click += null; } x3.EmptyStateButton.Click += TryAgainButton_Click; if (GroupsTab.EmptyStateLayout != null) { GroupsTab.EmptyStateLayout.Visibility = ViewStates.Visible; } GroupsTab.ProgressBarLoader.Visibility = ViewStates.Gone; } } catch (Exception e) { Console.WriteLine(e); } }
private void ShowEmptyPage(string type) { try { if (PostTab.SwipeRefreshLayout != null) { PostTab.SwipeRefreshLayout.Refreshing = false; } PostTab.MainScrollEvent.IsLoading = false; if (type == "GetPost") { if (PostTab.MAdapter.PostList.Count > 0) { PostTab.MRecycler.Visibility = ViewStates.Visible; PostTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { PostTab.MRecycler.Visibility = ViewStates.Gone; if (PostTab.Inflated == null) { PostTab.Inflated = PostTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(PostTab.Inflated, EmptyStateInflater.Type.NoPost); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; } PostTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } else if (type == "ProfilePrivate") { PostTab.MRecycler.Visibility = ViewStates.Gone; if (PostTab.Inflated == null) { PostTab.Inflated = PostTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(PostTab.Inflated, EmptyStateInflater.Type.ProfilePrivate); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += TryAgainButton_Click; } } } catch (Exception e) { if (PostTab.SwipeRefreshLayout != null) { PostTab.SwipeRefreshLayout.Refreshing = false; } PostTab.MainScrollEvent.IsLoading = false; Console.WriteLine(e); } }
private void ShowEmptyPage() { try { UserTab.ProgressBarLoader.Visibility = ViewStates.Gone; PagesTab.ProgressBarLoader.Visibility = ViewStates.Gone; GroupsTab.ProgressBarLoader.Visibility = ViewStates.Gone; if (UserTab.MAdapter.UserList.Count > 0) { UserTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { if (UserTab.Inflated == null) { UserTab.Inflated = UserTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click -= EmptyStateButtonOnClick; x.EmptyStateButton.Click -= TryAgainButton_Click; } x.EmptyStateButton.Click += TryAgainButton_Click; UserTab.EmptyStateLayout.Visibility = ViewStates.Visible; } if (PagesTab.MAdapter.PageList.Count > 0) { PagesTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { if (PagesTab.Inflated == null) { PagesTab.Inflated = PagesTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(PagesTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click -= EmptyStateButtonOnClick; x.EmptyStateButton.Click -= TryAgainButton_Click; } x.EmptyStateButton.Click += TryAgainButton_Click; PagesTab.EmptyStateLayout.Visibility = ViewStates.Visible; } if (GroupsTab.MAdapter.GroupList.Count > 0) { GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone; } else { if (GroupsTab.Inflated == null) { GroupsTab.Inflated = GroupsTab.EmptyStateLayout.Inflate(); } EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(GroupsTab.Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click -= EmptyStateButtonOnClick; x.EmptyStateButton.Click -= TryAgainButton_Click; x.EmptyStateButton.Click += null; } x.EmptyStateButton.Click += TryAgainButton_Click; GroupsTab.EmptyStateLayout.Visibility = ViewStates.Visible; } } catch (Exception e) { //SwipeRefreshLayout.Refreshing = false; Console.WriteLine(e); } }
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(); } }
//Get General Data Using Api >> notifications , pro_users , promoted_pages , trending_hashTag public async Task <(string, string, string, string)> LoadGeneralData(bool seenNotifications, string offset = "") { try { if (MainScrollEvent.IsLoading) { return("", "", "", ""); } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var countNotificationsList = MAdapter.NotificationsList?.Count ?? 0; var countPromotedPagesList = GlobalContext.ProPagesAdapter?.MProPagesList.Count ?? 0; (int apiStatus, var respond) = await RequestsAsync.Global.Get_General_Data(seenNotifications, TabbedMainActivity.OnlineUsers, UserDetails.DeviceId, offset); if (apiStatus == 200) { if (respond is GetGeneralDataObject result) { Activity.RunOnUiThread(() => { try { // Notifications var respondList = result.Notifications.Count; if (respondList > 0) { if (countNotificationsList > 0) { var listNew = result.Notifications?.Where(c => !MAdapter.NotificationsList.Select(fc => fc.Id).Contains(c.Id)).ToList(); if (listNew.Count > 0) { foreach (var notification in listNew) { MAdapter.NotificationsList.Insert(0, notification); } MAdapter.NotifyItemRangeInserted(countNotificationsList - 1, MAdapter.NotificationsList.Count - countNotificationsList); } } else { MAdapter.NotificationsList = new ObservableCollection <Notification>(result.Notifications); MAdapter.NotifyDataSetChanged(); } } else { if (MAdapter.NotificationsList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreNotifications), ToastLength.Short).Show(); } } // Friend Requests if (result.FriendRequests.Count > 0) { GlobalContext.FriendRequestsList = new ObservableCollection <UserDataObject>(result.FriendRequests); GlobalContext.TrendingTab.LayoutFriendRequest.Visibility = ViewStates.Visible; try { for (var i = 0; i < 4; i++) { switch (i) { case 0: GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i].Avatar, GlobalContext.TrendingTab.FriendRequestImage3, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; case 1: GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i].Avatar, GlobalContext.TrendingTab.FriendRequestImage2, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; case 2: GlideImageLoader.LoadImage(Activity, GlobalContext.FriendRequestsList[i].Avatar, GlobalContext.TrendingTab.FriendRequestImage1, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); break; } } } catch (Exception e) { Console.WriteLine(e); } } else { GlobalContext.TrendingTab.LayoutFriendRequest.Visibility = ViewStates.Gone; } if (AppSettings.ShowProUsersMembers) { var isPro = ListUtils.MyProfileList?.FirstOrDefault()?.IsPro ?? "0"; if (isPro == "0" && ListUtils.SettingsSiteList?.Pro == "1" && AppSettings.ShowGoPro) { var dataOwner = GlobalContext.ProUsersAdapter.MProUsersList.FirstOrDefault(a => a.Type == "Your"); if (dataOwner == null) { GlobalContext.ProUsersAdapter.MProUsersList.Insert(0, new UserDataObject { Avatar = UserDetails.Avatar, Type = "Your", Username = Context.GetText(Resource.String.Lbl_AddMe), }); GlobalContext.ProUsersAdapter.NotifyDataSetChanged(); if (GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Visible) { GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Visible; } } } // Pro Users var countProUsersList = GlobalContext.ProUsersAdapter.MProUsersList.Count; var respondListProUsers = result.ProUsers.Count; if (respondListProUsers > 0) { foreach (var item in from item in result.ProUsers let check = GlobalContext.ProUsersAdapter.MProUsersList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item) { GlobalContext.ProUsersAdapter.MProUsersList.Add(item); } if (countProUsersList > 0) { GlobalContext.ProUsersAdapter.NotifyItemRangeInserted(countProUsersList - 1, GlobalContext.ProUsersAdapter.MProUsersList.Count - countProUsersList); } else { GlobalContext.ProUsersAdapter.NotifyDataSetChanged(); } //Scroll Down >> GlobalContext.TrendingTab.ProUserRecyclerView.ScrollToPosition(0); if (GlobalContext.ProUsersAdapter.MProUsersList.Count > 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Visible) { GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Visible; } } else { if (GlobalContext.ProUsersAdapter.MProUsersList.Count == 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Gone) { GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Gone; } } } else { if (GlobalContext.ProUsersAdapter.MProUsersList.Count == 0 && GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility != ViewStates.Gone) { GlobalContext.TrendingTab.LayoutSuggestionProUsers.Visibility = ViewStates.Gone; } } if (AppSettings.ShowPromotedPages) { // Pro Pages var respondListPromotedPages = result.PromotedPages.Count; if (respondListPromotedPages > 0) { if (countPromotedPagesList > 0) { foreach (var item in from item in result.PromotedPages let check = GlobalContext.ProPagesAdapter.MProPagesList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { GlobalContext.ProPagesAdapter.MProPagesList.Add(item); } GlobalContext.ProPagesAdapter.NotifyItemRangeInserted(countPromotedPagesList - 1, GlobalContext.ProPagesAdapter.MProPagesList.Count - countPromotedPagesList); } else { GlobalContext.ProPagesAdapter.MProPagesList = new ObservableCollection <PageClass>(result.PromotedPages); GlobalContext.ProPagesAdapter.NotifyDataSetChanged(); } GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Visible; } else { GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Gone; } } else { GlobalContext.TrendingTab.LayoutSuggestionPromotedPage.Visibility = ViewStates.Gone; } if (AppSettings.ShowTrendingHashTags) { if (result.TrendingHashtag.Count > 0) { GlobalContext.HashTagUserAdapter.MHashtagList = new ObservableCollection <TrendingHashtag>(result.TrendingHashtag); } } MainScrollEvent.IsLoading = false; ShowEmptyPage(); } catch (Exception e) { Console.WriteLine(e); } }); return(result.NewNotificationsCount, result.NewFriendRequestsCount, result.CountNewMessages, result.Announcement?.AnnouncementClass?.TextDecode); } } else { Methods.DisplayReportResult(Activity, respond); } Activity.RunOnUiThread(ShowEmptyPage); MainScrollEvent.IsLoading = false; return("", "", "", ""); } 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(); } } catch (Exception e) { MainScrollEvent.IsLoading = false; Console.WriteLine(e); } MainScrollEvent.IsLoading = false; return("", "", "", ""); }
private async Task LoadDataAsync(string offset = "0") { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; int countList = MAdapter.UserList.Count; var(apiStatus, respond) = await RequestsAsync.Messages.GetChats("25", offset); if (apiStatus != 200 || !(respond is GetChatsObject result) || result.data == null) { Methods.DisplayReportResult(this, respond); } else { var respondList = result.data.Count; if (respondList > 0) { if (countList > 0) { LoadDataJsonLastChat(result); } else { ListUtils.ChatList = new ObservableCollection <GetChatsObject.Data>(result.data); MAdapter.UserList = new ObservableCollection <GetChatsObject.Data>(result.data); RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); SqLiteDatabase dbDatabase = new SqLiteDatabase(); dbDatabase.InsertOrReplaceLastChatTable(ListUtils.ChatList); dbDatabase.Dispose(); } } else { if (MAdapter.UserList.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(); MainScrollEvent.IsLoading = false; } MainScrollEvent.IsLoading = false; }
private async Task LoadJobsAsync(string offset) { if (MainScrollEvent.IsLoading) { return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; // api get job by page int countList = MAdapter.JobList.Count; (int apiStatus, var respond) = await RequestsAsync.Jobs.JobByPage(PageId, "10", offset); if (apiStatus != 200 || !(respond is JobByPageObject result) || result.Data == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.Data.Count; if (respondList > 0) { foreach (var item in from item in result.Data let check = MAdapter.JobList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { if (item.Job != null) { MAdapter.JobList.Add(WoWonderTools.ListFilterJobs(item.Job.Value.JobInfoClass)); } } if (countList > 0) { RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.JobList.Count - countList); }); } else { RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } else { if (MAdapter.JobList.Count > 10 && !MRecycler.CanScrollVertically(1)) { Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreJobs), 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; } }