Esempio n. 1
0
        private async Task LoadMostPopularAsync()
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.ArticlesList.Count;

                var(apiStatus, respond) = await RequestsAsync.Articles.Get_MostPopularArticles_Http();

                if (apiStatus != 200 || !(respond is GetUsersArticlesObject result) || result.ArticleList == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.ArticleList.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in from item in result.ArticleList let check = MAdapter.ArticlesList.FirstOrDefault(a => a.UserId == item.UserId) where check == null select item)
                            {
                                MAdapter.ArticlesList.Add(item);
                            }

                            Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.ArticlesList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.ArticlesList = new ObservableCollection <ArticleObject>(result.ArticleList);
                            Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter.ArticlesList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreArticle), 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;
        }
Esempio n. 2
0
        private async Task LoadDataAsync(string offset = "")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.NotificationsList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Common.GetNotificationsAsync("25", offset, UserDetails.DeviceId);

                if (apiStatus != 200 || !(respond is GetNotificationsObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        foreach (var item in result.Data)
                        {
                            item.Text = QuickDateTools.GetNotification(item);
                        }

                        Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                    else
                    {
                        if (MAdapter.NotificationsList.Count > 10 && !MRecycler.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;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
            }
        }
        private async Task LoadNotification()
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.NotificationsList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Common.GetNotificationsAsync();

                if (apiStatus == 200)
                {
                    if (respond is NotificationsObject result)
                    {
                        var respondList = result.Notifiations.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Notifiations let check = MAdapter.NotificationsList.FirstOrDefault(a => a.NId == item.NId) where check == null select item)
                                {
                                    MAdapter.NotificationsList.Add(item);
                                }

                                Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.NotificationsList.Count - countList); });
                            }
                            else
                            {
                                MAdapter.NotificationsList = new ObservableCollection <NotificationsObject.Notifiation>(result.Notifiations);
                                Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (MAdapter.NotificationsList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreNotificationsFound), 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();
            }
        }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.UserList.Count;

                var(apiStatus, respond) = await RequestsAsync.Chat.GetConversationListAsync("15", offset);

                if (apiStatus != 200 || !(respond is GetConversationListObject 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 <GetConversationListObject.DataConversation>(result.Data);
                            MAdapter.UserList  = new ObservableCollection <GetConversationListObject.DataConversation>(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();
                        }
                    }
                }

                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();
            }
        }
Esempio n. 8
0
        private async Task LoadGroupChatAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            MainScrollEvent.IsLoading = true;

            var countList = MAdapter.LastChatsList.Count;

            var(apiStatus, respond) = await RequestsAsync.GroupChat.GetGroupChatListAsync("20", offset);

            if (apiStatus.Equals(200))
            {
                if (respond is GroupListObject result)
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        foreach (var chatObject in from chatObject in result.Data let check = MAdapter?.LastChatsList.FirstOrDefault(a => a.LastChat?.GroupId == chatObject.GroupId) where check == null select chatObject)
                        {
                            chatObject.ChatType = "group";
                            var item = WoWonderTools.FilterDataLastChatNewV(chatObject);

                            MAdapter?.LastChatsList.Add(new Classes.LastChatsClass()
                            {
                                LastChat = item,
                                Type     = Classes.ItemType.LastChatNewV
                            });
                        }

                        if (countList > 0)
                        {
                            Activity?.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.LastChatsList.Count - countList); });
                        }
                        else
                        {
                            Activity?.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter?.LastChatsList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short)?.Show();
                        }
                    }
                }
            }
            else
            {
                Methods.DisplayReportResult(Activity, respond);
            }

            Activity?.RunOnUiThread(ShowEmptyPage);
        }
Esempio n. 9
0
        private async Task LoadMembersAsync(string offset = "")
        {
            switch (MainScrollEvent.IsLoading)
            {
            case true:
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;

                var countList = MAdapter.UserList.Count;
                var(apiStatus, respond) = await RequestsAsync.Group.GetGroupMembersAsync(GroupId, "10", offset);

                if (apiStatus != 200 || respond is not GetGroupMembersObject result || result.Users == null)
                {
                    MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Users.Count;
                    switch (respondList)
                    {
                    case > 0 when countList > 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(countList, MAdapter.UserList.Count - countList); });
                        break;
                    }

                    case > 0:
                        MAdapter.UserList = new ObservableCollection <UserDataObject>(result.Users);
                        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;
                    }
                    }
                }

                RunOnUiThread(ShowEmptyPage);
            }
        private async Task LoadShopsAsync(string offset = "0")
        {
            switch (MainScrollEvent.IsLoading)
            {
            case true:
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                var countList = MAdapter.NearbyBusinessList.Count;
                var(apiStatus, respond) = await RequestsAsync.Nearby.GetNearbyBusinessesAsync("10", offset, SearchText, UserDetails.NearbyBusinessDistanceCount);

                if (apiStatus != 200 || respond is not NearbyBusinessesObject result || result.Data == null)
                {
                    MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    switch (respondList)
                    {
                    case > 0 when countList > 0:
                    {
                        foreach (var item in from item in result.Data let check = MAdapter.NearbyBusinessList.FirstOrDefault(a => a.JobId == item.JobId) where check == null select item)
                        {
                            MAdapter.NearbyBusinessList.Add(item);
                        }

                        RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.NearbyBusinessList.Count - countList); });
                        break;
                    }

                    case > 0:
                        MAdapter.NearbyBusinessList = new ObservableCollection <NearbyBusinessesDataObject>(result.Data);
                        RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        break;

                    default:
                    {
                        switch (MAdapter.NearbyBusinessList.Count)
                        {
                        case > 10 when !MRecycler.CanScrollVertically(1):
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreProducts), ToastLength.Short)?.Show();
                            break;
                        }

                        break;
                    }
                    }
                }

                RunOnUiThread(ShowEmptyPage);
            }
Esempio n. 11
0
        private async Task LoadMembersAsync()
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.UserList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Page.GetNotInPageMembers(PageId);

                if (apiStatus != 200 || !(respond is GetPageMembersObject result) || result.Users == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Users.Count;
                    if (respondList > 0)
                    {
                        if (countList > 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(countList, MAdapter.UserList.Count - countList); });
                        }
                        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();
                        }
                    }
                }

                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();
            }
        }
Esempio n. 12
0
        private async Task LoadPageChatAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            MainScrollEvent.IsLoading = true;

            int countList = MAdapter.LastPageList.Count;

            (int apiStatus, var respond) = await RequestsAsync.PageChat.GetPageChatList("20", offset);

            if (apiStatus.Equals(200))
            {
                if (respond is PageListObject result)
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in result.Data)
                            {
                                var check = MAdapter?.LastPageList.FirstOrDefault(a => a.PageId == item.PageId);
                                if (check == null)
                                {
                                    MAdapter?.LastPageList.Add(item);
                                }
                            }

                            Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.LastPageList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.LastPageList = new ObservableCollection <PageClass>(result.Data);
                            Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter?.LastPageList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMorePage), ToastLength.Short)?.Show();
                        }
                    }
                }
            }
            else
            {
                Methods.DisplayReportResult(Activity, respond);
            }

            Activity.RunOnUiThread(ShowEmptyPage);
        }
Esempio n. 13
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.CommentList.Count;

                var(apiStatus, respond) = await RequestsAsync.Articles.Get_Articles_Comments_Http(ArticleId, "20", offset);

                if (apiStatus != 200 || !(respond is GetCommentsObject result) || result.ListComments == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.ListComments.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in from item in result.ListComments let check = MAdapter.CommentList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                            {
                                MAdapter.CommentList.Insert(0, item);
                            }

                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.CommentList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.CommentList = new ObservableCollection <CommentObject>(result.ListComments);
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else if (MAdapter.CommentList.Count > 10 && !MRecycler.CanScrollVertically(1))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreComment), 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();
            }
        }
Esempio n. 14
0
            public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
            {
                base.OnScrollStateChanged(recyclerView, newState);

                try
                {
                    if (newState == (int)Android.Widget.ScrollState.Idle)
                    {
                        //if (XRecyclerView.Thumbnail != null)
                        //    XRecyclerView.Thumbnail.Visibility = ViewStates.Visible;

                        //if (XRecyclerView.PlayControl != null)
                        //    XRecyclerView.PlayControl.Visibility = ViewStates.Visible;

                        XRecyclerView.PlayVideo(!recyclerView.CanScrollVertically(1));
                    }
                    else
                    {
                        var startPosition = LayoutManager.FindFirstVisibleItemPosition();
                        var endPosition   = LayoutManager.FindLastVisibleItemPosition();

                        var startPositionVideoHeight = XRecyclerView.GetVisibleVideoSurfaceHeight(startPosition);
                        var endPositionVideoHeight   = XRecyclerView.GetVisibleVideoSurfaceHeight(endPosition);
                        var targetPosition           = startPositionVideoHeight > endPositionVideoHeight;

                        if (endPositionVideoHeight - 230 > startPositionVideoHeight)
                        {
                            if (XRecyclerView.VideoPlayer.PlayWhenReady)
                            {
                                XRecyclerView.VideoPlayer.PlayWhenReady = false;
                            }
                        }
                        if (startPositionVideoHeight <= 60)
                        {
                            if (XRecyclerView.Thumbnail != null)
                            {
                                XRecyclerView.Thumbnail.Visibility = ViewStates.Visible;
                            }

                            if (XRecyclerView.PlayControl != null)
                            {
                                XRecyclerView.PlayControl.Visibility = ViewStates.Visible;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
Esempio n. 15
0
        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);
            }
Esempio n. 16
0
        private async Task LoadJobsAsync(string offset)
        {
            switch (MainScrollEvent.IsLoading)
            {
            case true:
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                // api get job by page
                var countList = MAdapter.JobList.Count;
                var(apiStatus, respond) = await RequestsAsync.Jobs.JobByPageAsync(PageId, "10", offset);

                if (apiStatus != 200 || respond is not JobByPageObject result || result.Data == null)
                {
                    MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    switch (respondList)
                    {
                    case > 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));
                            }
                        }

                        switch (countList)
                        {
                        case > 0:
                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.JobList.Count - countList); });
                            break;

                        default:
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                            break;
                        }

                        break;
                    }

                    default:
                    {
                        switch (MAdapter.JobList.Count)
                        {
                        case > 10 when !MRecycler.CanScrollVertically(1):
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreJobs), ToastLength.Short)?.Show();
                            break;
                        }

                        break;
                    }
                    }
                }

                RunOnUiThread(ShowEmptyPage);
            }
Esempio n. 17
0
        //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 GetPlaylist(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (ListUtils.PlaylistList.Count > 0)
            {
                PlaylistAdapter.PlaylistList = new ObservableCollection <PlaylistDataObject>(ListUtils.PlaylistList);
                Activity.RunOnUiThread(() => { PlaylistAdapter.NotifyDataSetChanged(); });
                offset = PlaylistAdapter.PlaylistList.LastOrDefault()?.Id.ToString() ?? "0";
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;

                int countList = PlaylistAdapter.PlaylistList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Playlist.GetPlaylistAsync(UserDetails.UserId.ToString(), "15", offset);

                if (apiStatus.Equals(200))
                {
                    if (respond is PlaylistObject result)
                    {
                        var respondList = result.Playlist.Count;
                        if (respondList > 0)
                        {
                            foreach (var item in from item in result.Playlist let check = PlaylistAdapter.PlaylistList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                            {
                                PlaylistAdapter.PlaylistList.Add(item);
                                ListUtils.PlaylistList.Add(item);
                            }

                            if (countList > 0)
                            {
                                Activity.RunOnUiThread(() => { PlaylistAdapter.NotifyItemRangeInserted(countList - 1, PlaylistAdapter.PlaylistList.Count - countList); });
                            }
                            else
                            {
                                Activity.RunOnUiThread(() => { PlaylistAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (PlaylistAdapter.PlaylistList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMorePlaylist), 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;
            }
            MainScrollEvent.IsLoading = false;
        }
        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;
        }
Esempio n. 20
0
        private async Task LoadData()
        {
            if (Methods.CheckConnectivity())
            {
                var countList = MAdapter.LinksList.Count;
                var(respondCode, respondString) = await RequestsAsync.Global.InvitationAsync();

                switch (respondCode)
                {
                case 200:
                {
                    switch (respondString)
                    {
                    case InvitationObject result:
                    {
                        RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        AvailableTextView.Text = result.AvailableLinks;

                                        if (result.GeneratedLinks != null)
                                        {
                                            GeneratedCount.Text = result.GeneratedLinks.Value.ToString();
                                        }

                                        if (result.UsedLinks != null)
                                        {
                                            UsedCount.Text = result.UsedLinks.Value.ToString();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                    }
                                });

                        var respondList = result.Data.Count;
                        switch (respondList)
                        {
                        case > 0 when countList > 0:
                        {
                            foreach (var item in from item in result.Data let check = MAdapter.LinksList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                            {
                                MAdapter.LinksList.Add(item);
                            }

                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.LinksList.Count - countList); });
                            break;
                        }

                        case > 0:
                            MAdapter.LinksList = new ObservableCollection <InvitationDataObject>(result.Data);
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                            break;

                        default:
                        {
                            switch (MAdapter.LinksList.Count)
                            {
                            case > 10 when !MRecycler.CanScrollVertically(1):
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreFunding), ToastLength.Short)?.Show();
                                break;
                            }

                            break;
                        }
                        }

                        break;
                    }
                    }

                    break;
                }

                default:
                    Methods.DisplayReportResult(this, respondString);
                    break;
                }

                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
            }
        }
        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;
        }
Esempio n. 22
0
        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;
            }
        }
Esempio n. 23
0
        private async Task LoadProUser()
        {
            var data = ListUtils.MyUserInfo?.FirstOrDefault(a => a.Id == UserDetails.UserId);

            if (data?.IsPro != "1")
            {
                if (!AppSettings.EnableAppFree)
                {
                    var dataOwner = ProUserAdapter.ProUserList.FirstOrDefault(a => a.Type == "Your");
                    if (dataOwner == null && data != null)
                    {
                        data.Type     = "Your";
                        data.Username = Context.GetText(Resource.String.Lbl_AddMe);
                        data.IsOwner  = true;
                        ProUserAdapter.ProUserList.Insert(0, data);

                        Activity.RunOnUiThread(() => { ProUserAdapter.NotifyItemInserted(0); });
                    }
                }
            }

            if (Methods.CheckConnectivity())
            {
                int countList = ProUserAdapter.ProUserList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Users.GetProAsync("25");

                if (apiStatus != 200 || !(respond is ListUsersObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in from item in result.Data let check = ProUserAdapter.ProUserList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                            {
                                ProUserAdapter.ProUserList.Add(item);
                            }

                            Activity.RunOnUiThread(() => { ProUserAdapter.NotifyItemRangeInserted(countList - 1, ProUserAdapter.ProUserList.Count - countList); });
                        }
                        else
                        {
                            ProUserAdapter.ProUserList = new ObservableCollection <UserInfoObject>(result.Data);
                            Activity.RunOnUiThread(() => { ProUserAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (ProUserAdapter.ProUserList.Count > 10 && !ProRecyclerView.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show();
                        }
                    }
                }

                MainScrollEvent.IsLoading = false;
            }
            else
            {
                Toast.MakeText(Context, Context.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("", "", "", "");
        }
Esempio n. 25
0
        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;
        }
Esempio n. 26
0
        private async Task LoadReviewsAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.UserList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Page.GetReviews(PageId, offset, "10");

                if (apiStatus == 200)
                {
                    if (respond is ReviewsPageObject result)
                    {
                        var respondList = result.Reviews.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Reviews let check = MAdapter.UserList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    MAdapter.UserList.Add(item);
                                }
                            }
                            else
                            {
                                MAdapter.UserList = new ObservableCollection <ReviewsPageObject.Datum>(result.Reviews);
                            }
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                        else
                        {
                            if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreReviews), ToastLength.Short)?.Show();
                            }
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(this, respond);
                }
                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;
            }
        }
Esempio n. 27
0
        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;
        }
Esempio n. 28
0
        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;
            }
        }
Esempio n. 30
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.VideoList.Count;

                var(apiStatus, respond) = await RequestsAsync.Video.Get_Liked_Videos_Http("25", offset);

                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);

                        if (countList > 0)
                        {
                            foreach (var item in from item in result.VideoList let check = MAdapter.VideoList.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item)
                            {
                                MAdapter.VideoList.Add(item);
                            }

                            Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.VideoList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.VideoList = new ObservableCollection <VideoObject>(result.VideoList);
                            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();
                        }
                    }
                }

                GlobalContext.LibrarySynchronizer.AddToLiked(MAdapter.VideoList.FirstOrDefault(), MAdapter.VideoList.Count);

                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;
        }