コード例 #1
0
        private async Task GetMyGroups()
        {
            if (MAdapter is SearchGroupAdapter adapter1)
            {
                if (MainScrollEvent.IsLoading)
                {
                    return;
                }

                var lastIdGroup = adapter1.GroupList.LastOrDefault()?.GroupId ?? "0";
                if (Methods.CheckConnectivity())
                {
                    MainScrollEvent.IsLoading = true;
                    int countList = adapter1.GroupList.Count;

                    var(apiStatus, respond) = await RequestsAsync.Group.GetMyGroups(lastIdGroup, "10");

                    if (apiStatus != 200 || !(respond is ListGroupsObject result) || result.Data == null)
                    {
                        Methods.DisplayReportResult(this, respond);
                    }
                    else
                    {
                        var respondList = result.Data.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Data let check = adapter1.GroupList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item)
                                {
                                    adapter1.GroupList.Add(item);

                                    if (ListUtils.MyGroupList.FirstOrDefault(a => a.GroupId == item.GroupId) == null)
                                    {
                                        ListUtils.MyGroupList.Add(item);
                                    }
                                }

                                RunOnUiThread(() => { adapter1.NotifyItemRangeInserted(countList, adapter1.GroupList.Count - countList); });
                            }
                            else
                            {
                                adapter1.GroupList = new ObservableCollection <GroupClass>(result.Data);
                                RunOnUiThread(() => { adapter1.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (adapter1.GroupList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), 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();
                }
            }
        }
コード例 #2
0
        private async Task LoadRandomGroup(string offset)
        {
            if (Methods.CheckConnectivity())
            {
                var countList = RandomAdapter.GroupList.Count;

                var dictionary = new Dictionary <string, string>
                {
                    { "limit", "30" },
                    { "group_offset", offset },
                    { "search_key", "a" },
                };

                var(respondCode, respondString) = await RequestsAsync.Global.Get_Search(dictionary);

                if (respondCode.Equals(200))
                {
                    if (respondString is GetSearchObject result)
                    {
                        var respondList = result.Groups.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Groups let check = RandomAdapter.GroupList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    RandomAdapter.GroupList.Add(item);
                                }

                                RunOnUiThread(() => { RandomAdapter.NotifyItemRangeInserted(countList, RandomAdapter.GroupList.Count - countList); });
                            }
                            else
                            {
                                RandomAdapter.GroupList = new ObservableCollection <GroupClass>(result.Groups);

                                RunOnUiThread(() =>
                                {
                                    if (RandomGroupInflated == null)
                                    {
                                        RandomGroupInflated = RandomGroupViewStub.Inflate();
                                    }

                                    RecyclerInflaterRandomGroup = new TemplateRecyclerInflater();
                                    RecyclerInflaterRandomGroup.InflateLayout <GroupClass>(this, RandomGroupInflated, RandomAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerVertical, 0, true, GetString(Resource.String.Lbl_RandomGroups));
                                });
                            }
                        }
                        else
                        {
                            if (RecyclerInflaterRandomGroup?.Recyler != null && (RandomAdapter.GroupList.Count > 10 && !RecyclerInflaterRandomGroup.Recyler.CanScrollVertically(1)))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short).Show();
                            }
                        }
                    }
                }
                else
                {
                    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();
            }
        }
コード例 #3
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (Methods.CheckConnectivity())
            {
                if (UserDetails.IsLogin)
                {
                    if (MainScrollEvent.IsLoading)
                    {
                        return;
                    }

                    MainScrollEvent.IsLoading = true;

                    int countList = ReplyAdapter.ReplyList.Count;

                    using (var client = new System.Net.Http.HttpClient())
                    {
                        var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                        {
                            new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                            new KeyValuePair <string, string>("type", "fetch_replies"),
                            new KeyValuePair <string, string>("comment_id", Comment.Id.ToString()),
                            new KeyValuePair <string, string>("offset", offset),
                            new KeyValuePair <string, string>("limit", "20"),
                            new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                            new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                        });

                        //  send a Post request
                        //var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=get_response_video_comments&video_id=" + VideoId + "&limit=20&offset=" + offset;
                        var uri     = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments";
                        var result2 = await client.PostAsync(uri, formContent);

                        if (result2.IsSuccessStatusCode)
                        {
                            // handling the answer
                            var resultString = await result2.Content.ReadAsStringAsync();

                            var jObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                            if (jObject["api_status"].ToString() != "200" || jObject["data"] == null)
                            {
                                MainScrollEvent.IsLoading = false;
                                Methods.DisplayReportResult(Activity, jObject["errors"]["error_text"].ToString());
                            }
                            else
                            {
                                //List<CommentObject> ListComments = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CommentObject>>(jObject["data"].ToString());
                                List <ReplyObject> ListComments = (List <ReplyObject>)jObject["data"].ToObject(typeof(List <ReplyObject>));
                                var respondList = ListComments.Count;
                                if (respondList > 0)
                                {
                                    if (countList > 0)
                                    {
                                        foreach (var item in from item in ListComments let check = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                        {
                                            ReplyAdapter.ReplyList.Insert(0, item);
                                        }

                                        Activity.RunOnUiThread(() => { ReplyAdapter.NotifyItemRangeInserted(countList, ReplyAdapter.ReplyList.Count - countList); });
                                    }
                                    else
                                    {
                                        ReplyAdapter.ReplyList = new ObservableCollection <ReplyObject>(ListComments);
                                        Activity.RunOnUiThread(() => { ReplyAdapter.NotifyDataSetChanged(); });
                                    }
                                }
                                else if (ReplyAdapter.ReplyList.Count > 10 && !ReplyRecyclerView.CanScrollVertically(1))
                                {
                                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreComment), ToastLength.Short).Show();
                                }
                            }
                        }
                    }
                    //var (apiStatus, respond) = await RequestsAsync.Comments.Get_Replies_Http(Comment.Id.ToString(), "20", offset);
                    //if (apiStatus != 200 || !(respond is GetRepliesObject result) || result.Data == null)
                    //{
                    //    MainScrollEvent.IsLoading = false;
                    //    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 = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                    //            {
                    //                ReplyAdapter.ReplyList.Insert(0, item);
                    //            }

                    //            Activity.RunOnUiThread(() => { ReplyAdapter.NotifyItemRangeInserted(countList, ReplyAdapter.ReplyList.Count - countList); });
                    //        }
                    //        else
                    //        {
                    //            ReplyAdapter.ReplyList = new ObservableCollection<ReplyObject>(result.Data);
                    //            Activity.RunOnUiThread(() => { ReplyAdapter.NotifyDataSetChanged(); });
                    //        }
                    //    }
                    //    else if (ReplyAdapter.ReplyList.Count > 10 && !ReplyRecyclerView.CanScrollVertically(1))
                    //    {
                    //        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreComment), ToastLength.Short).Show();
                    //    }
                    //}

                    Activity.RunOnUiThread(ShowEmptyPage);
                }
                else
                {
                    Activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            ReplyRecyclerView.Visibility = ViewStates.Gone;

                            Inflated             = EmptyStateLayout.Inflate();
                            EmptyStateInflater x = new EmptyStateInflater();
                            x.InflateLayout(Inflated, EmptyStateInflater.Type.Login);
                            if (!x.EmptyStateButton.HasOnClickListeners)
                            {
                                x.EmptyStateButton.Click += null;
                                x.EmptyStateButton.Click += LoginButtonOnClick;
                            }

                            EmptyStateLayout.Visibility = ViewStates.Visible;
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    });
                }
            }
            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;
        }
コード例 #4
0
        private void ShowEmptyPage(string type)
        {
            try
            {
                if (type == "GetGames")
                {
                    GamesTab.MainScrollEvent.IsLoading     = false;
                    GamesTab.SwipeRefreshLayout.Refreshing = false;

                    if (GamesTab.MAdapter.GamesList.Count > 0)
                    {
                        GamesTab.MRecycler.Visibility        = ViewStates.Visible;
                        GamesTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        GamesTab.MRecycler.Visibility = ViewStates.Gone;

                        if (GamesTab.Inflated == null)
                        {
                            GamesTab.Inflated = GamesTab.EmptyStateLayout.Inflate();
                        }

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(GamesTab.Inflated, EmptyStateInflater.Type.NoGames);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        GamesTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }
                else if (type == "GetMyGames")
                {
                    MyGamesTab.MainScrollEvent.IsLoading     = false;
                    MyGamesTab.SwipeRefreshLayout.Refreshing = false;

                    if (MyGamesTab.MAdapter.GamesList.Count > 0)
                    {
                        MyGamesTab.MRecycler.Visibility        = ViewStates.Visible;
                        MyGamesTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        MyGamesTab.MRecycler.Visibility = ViewStates.Gone;

                        if (MyGamesTab.Inflated == null)
                        {
                            MyGamesTab.Inflated = MyGamesTab.EmptyStateLayout.Inflate();
                        }

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(MyGamesTab.Inflated, EmptyStateInflater.Type.NoGames);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        MyGamesTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }
            }
            catch (Exception e)
            {
                GamesTab.MainScrollEvent.IsLoading       = false;
                GamesTab.SwipeRefreshLayout.Refreshing   = false;
                MyGamesTab.MainScrollEvent.IsLoading     = false;
                MyGamesTab.SwipeRefreshLayout.Refreshing = false;
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #5
0
        private async Task LoadContactsAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.UserList.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 result.DataFriends.Following)
                            {
                                var check = MAdapter.UserList.FirstOrDefault(a => a.UserId == item.UserId);
                                if (check == null)
                                {
                                    MAdapter.UserList.Add(item);
                                }
                                else
                                {
                                    check      = item;
                                    check.Name = item.Name;
                                }
                            }

                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.UserList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Following);
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short).Show();
                        }
                    }
                }

                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;
            }
        }
コード例 #6
0
        private void SearchBoxOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            try
            {
                SearchBox.ClearFocus();
                SongsTab.MAdapter.SoundsList.Clear();
                SongsTab.MAdapter.NotifyDataSetChanged();

                AlbumsTab.MAdapter.AlbumsList.Clear();
                AlbumsTab.MAdapter.NotifyDataSetChanged();

                PlaylistTab.MAdapter.PlaylistList.Clear();
                PlaylistTab.MAdapter.NotifyDataSetChanged();

                ArtistsTab.MAdapter.UsersList.Clear();
                ArtistsTab.MAdapter.NotifyDataSetChanged();

                OffsetSongs    = "0";
                OffsetAlbums   = "0";
                OffsetPlaylist = "0";
                OffsetArtists  = "0";

                if (Methods.CheckConnectivity())
                {
                    if (SongsTab.MAdapter.SoundsList.Count > 0)
                    {
                        SongsTab.MAdapter.SoundsList.Clear();
                        SongsTab.MAdapter.NotifyDataSetChanged();
                    }

                    if (AlbumsTab.MAdapter.AlbumsList.Count > 0)
                    {
                        AlbumsTab.MAdapter.AlbumsList.Clear();
                        AlbumsTab.MAdapter.NotifyDataSetChanged();
                    }

                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                    StartApiService();
                }
                else
                {
                    if (SongsTab.Inflated == null)
                    {
                        SongsTab.Inflated = SongsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(SongsTab.Inflated, EmptyStateInflater.Type.NoConnection);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Visible;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
コード例 #7
0
        private void ShowEmptyPage()
        {
            try
            {
                SongsTab.ProgressBarLoader.Visibility = ViewStates.Gone;

                if (SongsTab.MAdapter.SoundsList.Count > 0)
                {
                    SongsTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    if (SongsTab.Inflated == null)
                    {
                        SongsTab.Inflated = SongsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(SongsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click            += TryAgainButton_Click;
                    SongsTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }


                if (AlbumsTab.MAdapter.AlbumsList.Count > 0)
                {
                    AlbumsTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    if (AlbumsTab.Inflated == null)
                    {
                        AlbumsTab.Inflated = AlbumsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(AlbumsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    AlbumsTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }

                if (PlaylistTab.MAdapter.PlaylistList.Count > 0)
                {
                    PlaylistTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    if (PlaylistTab.Inflated == null)
                    {
                        PlaylistTab.Inflated = PlaylistTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(PlaylistTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    PlaylistTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }

                if (ArtistsTab.MAdapter.UsersList.Count > 0)
                {
                    ArtistsTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    if (ArtistsTab.Inflated == null)
                    {
                        ArtistsTab.Inflated = ArtistsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(ArtistsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    ArtistsTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                //SwipeRefreshLayout.Refreshing = false;
                Console.WriteLine(e);
            }
        }
コード例 #8
0
        private void SetDataAlbums()
        {
            try
            {
                AlbumsId = Arguments.GetString("AlbumsId") ?? "";
                if (!string.IsNullOrEmpty(AlbumsId))
                {
                    AlbumsObject = JsonConvert.DeserializeObject <DataAlbumsObject>(Arguments.GetString("ItemData") ?? "");
                    if (AlbumsObject != null)
                    {
                        var d = AlbumsObject.Title.Replace("<br>", "");
                        AlbumName.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(d), 80);

                        var count = !string.IsNullOrEmpty(AlbumsObject.CountSongs) ? AlbumsObject.CountSongs : AlbumsObject.SongsCount ?? "0";

                        CountSoungAlbumText.Text = count + " " + Context.GetText(Resource.String.Lbl_Songs) + " - " + AlbumsObject.Purchases + " " + Context.GetText(Resource.String.Lbl_Purchases);
                        NameUserText.Text        = DeepSoundTools.GetNameFinal(AlbumsObject.Publisher ?? AlbumsObject.UserData);

                        var imageUrl = string.Empty;
                        if (!string.IsNullOrEmpty(AlbumsObject.ThumbnailOriginal))
                        {
                            if (!AlbumsObject.ThumbnailOriginal.Contains(DeepSoundClient.Client.WebsiteUrl))
                            {
                                imageUrl = DeepSoundClient.Client.WebsiteUrl + "/" + AlbumsObject.ThumbnailOriginal;
                            }
                            else
                            {
                                imageUrl = AlbumsObject.ThumbnailOriginal;
                            }
                        }

                        if (string.IsNullOrEmpty(imageUrl))
                        {
                            imageUrl = AlbumsObject.Thumbnail;
                        }

                        FullGlideRequestBuilder.Load(imageUrl).Into(ImageCover);
                        FullGlideRequestBuilder.Load(imageUrl).Into(ImageAlbum);

                        if (AlbumsObject.Publisher != null)
                        {
                            Glide.With(this).AsBitmap().Apply(GlideRequestOptions).Load(AlbumsObject.Publisher.Avatar).Into(ImageAvatar);
                        }
                        else
                        {
                            Glide.With(this).AsBitmap().Apply(GlideRequestOptions).Load(AlbumsObject.UserData.Avatar).Into(ImageAvatar);
                        }

                        if (AlbumsObject.IsOwner != null && Math.Abs(AlbumsObject.Price) > 0 && !AlbumsObject.IsOwner.Value && AlbumsObject.IsPurchased == 0)
                        {
                            BuyButton.Visibility = ViewStates.Visible;

                            MRecycler.Visibility = ViewStates.Gone;

                            Inflated ??= EmptyStateLayout.Inflate();

                            EmptyStateInflater x = new EmptyStateInflater();
                            x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSoundWithPaid);

                            EmptyStateLayout.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            BuyButton.Visibility = ViewStates.Gone;
                            StartApiService();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #9
0
        private async Task LoadAlbumsSongs()
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.SoundsList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Albums.GetAlbumSongsAsync(AlbumsId);

                if (apiStatus == 200)
                {
                    if (respond is GetAlbumSongsObject result)
                    {
                        var respondList = result.Songs?.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Songs let check = MAdapter.SoundsList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    MAdapter.SoundsList.Add(item);
                                }

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

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
コード例 #10
0
        private async Task LoadContactsAsync()
        {
            switch (MAdapter)
            {
            case ContactsAdapter adapter when MainScrollEvent.IsLoading:
                return;

            case ContactsAdapter adapter:
            {
                var lastIdUser = adapter.UserList.LastOrDefault()?.UserId ?? "0";
                if (Methods.CheckConnectivity())
                {
                    MainScrollEvent.IsLoading = true;

                    var countList = adapter.UserList.Count;
                    var(apiStatus, respond) = await RequestsAsync.Global.GetFriendsAsync(PassedId, "following", "10", lastIdUser);

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

                            RunOnUiThread(() => { adapter.NotifyItemRangeInserted(countList, adapter.UserList.Count - countList); });
                            break;
                        }

                        case > 0:
                            adapter.UserList = new ObservableCollection <UserDataObject>(result.DataFriends.Following);
                            RunOnUiThread(() => { adapter.NotifyDataSetChanged(); });
                            break;

                        default:
                        {
                            switch (adapter.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);
                }
                else
                {
                    Inflated = EmptyStateLayout.Inflate();
                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                    switch (x.EmptyStateButton.HasOnClickListeners)
                    {
                    case false:
                        x.EmptyStateButton.Click += null !;
                        x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                        break;
                    }

                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    MainScrollEvent.IsLoading = false;
                }
                MainScrollEvent.IsLoading = false;
                break;
            }
コード例 #11
0
        private async Task LoadDataAsync(string offset = "")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

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

                int    countList  = MAdapter.PixelNewsFeedList.Count;
                string decodeHash = HashName.Replace("#", "");
                var(apiStatus, respond) = await RequestsAsync.Post.FetchPostsByHashtag(decodeHash, offset, "25");

                if (apiStatus != 200 || !(respond is FetchPostsByHashTagObject result) || result.PostList == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.PostList.Count;
                    if (respondList > 0)
                    {
                        result.PostList.RemoveAll(a => a.MediaSet?.Count == 0 && a.MediaSet == null);

                        if (countList > 0)
                        {
                            foreach (var item in from item in result.PostList let check = MAdapter.PixelNewsFeedList.FirstOrDefault(a => a.PostId == item.PostId) where check == null select item)
                            {
                                item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4);
                                MAdapter.PixelNewsFeedList.Add(item);
                            }

                            Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.PixelNewsFeedList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.PixelNewsFeedList = new ObservableCollection <PostsObject>(result.PostList);
                            Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter.PixelNewsFeedList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMorePost), ToastLength.Short).Show();
                        }
                    }
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                MainScrollEvent.IsLoading = false;
            }
            MainScrollEvent.IsLoading = false;
        }
コード例 #12
0
        private async Task LoadData(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

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

                int countList = MAdapter.PlaylistList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Playlist.GetPlaylistAsync(UserId, "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 = MAdapter.PlaylistList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                            {
                                MAdapter.PlaylistList.Add(item);
                            }

                            if (countList > 0)
                            {
                                Activity.RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.PlaylistList.Count - countList); });
                            }
                            else
                            {
                                Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (MAdapter.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;
        }
コード例 #13
0
        private async Task LoadMyImage(string offset)
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.MyPhotosList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Album.GetPostByType(UserDetails.UserId, "photos", "10", offset);

                if (apiStatus != 200 || !(respond is PostObject result) || result.Data == null)
                {
                    MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data?.Count;
                    if (respondList > 0)
                    {
                        result.Data.RemoveAll(w => string.IsNullOrEmpty(w.PostFileFull));

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

                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.MyPhotosList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.MyPhotosList = new ObservableCollection <PostDataObject>(result.Data);
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter.MyPhotosList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMorePhoto), 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;
            }
        }
コード例 #14
0
        private void ShowEmptyPage()
        {
            try
            {
                if (LikeTab != null)
                {
                    LikeTab.MainScrollEvent.IsLoading = false;
                }
                if (LoveTab != null)
                {
                    LoveTab.MainScrollEvent.IsLoading = false;
                }
                if (WowTab != null)
                {
                    WowTab.MainScrollEvent.IsLoading = false;
                }
                if (HahaTab != null)
                {
                    HahaTab.MainScrollEvent.IsLoading = false;
                }
                if (SadTab != null)
                {
                    SadTab.MainScrollEvent.IsLoading = false;
                }
                if (AngryTab != null)
                {
                    AngryTab.MainScrollEvent.IsLoading = false;
                }

                if (Adapter.ItemCount != ViewPager.Adapter.ItemCount)
                {
                    ViewPager.CurrentItem = Adapter.ItemCount;
                    ViewPager.Adapter     = Adapter;
                    ViewPager.Adapter.NotifyDataSetChanged();
                }

                if (LikeTab != null)
                {
                    LikeTab.SwipeRefreshLayout.Refreshing = LikeTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => LikeTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (LikeTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        LikeTab.MRecycler.Visibility        = ViewStates.Visible;
                        LikeTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        LikeTab.MRecycler.Visibility = ViewStates.Gone;

                        LikeTab.Inflated = LikeTab.Inflated switch
                        {
                            null => LikeTab.EmptyStateLayout.Inflate(),
                            _ => LikeTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(LikeTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        LikeTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }

                if (LoveTab != null)
                {
                    LoveTab.SwipeRefreshLayout.Refreshing = LoveTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => LoveTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (LoveTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        LoveTab.MRecycler.Visibility        = ViewStates.Visible;
                        LoveTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        LoveTab.MRecycler.Visibility = ViewStates.Gone;

                        LoveTab.Inflated = LoveTab.Inflated switch
                        {
                            null => LoveTab.EmptyStateLayout.Inflate(),
                            _ => LoveTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(LoveTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        LoveTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }

                if (WowTab != null)
                {
                    WowTab.SwipeRefreshLayout.Refreshing = WowTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => WowTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (WowTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        WowTab.MRecycler.Visibility        = ViewStates.Visible;
                        WowTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        WowTab.MRecycler.Visibility = ViewStates.Gone;

                        WowTab.Inflated = WowTab.Inflated switch
                        {
                            null => WowTab.EmptyStateLayout.Inflate(),
                            _ => WowTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(WowTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        WowTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }

                if (HahaTab != null)
                {
                    HahaTab.SwipeRefreshLayout.Refreshing = HahaTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => HahaTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (HahaTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        HahaTab.MRecycler.Visibility        = ViewStates.Visible;
                        HahaTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        HahaTab.MRecycler.Visibility = ViewStates.Gone;

                        HahaTab.Inflated = HahaTab.Inflated switch
                        {
                            null => HahaTab.EmptyStateLayout.Inflate(),
                            _ => HahaTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(HahaTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        HahaTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }

                if (SadTab != null)
                {
                    SadTab.SwipeRefreshLayout.Refreshing = SadTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => SadTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (SadTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        SadTab.MRecycler.Visibility        = ViewStates.Visible;
                        SadTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        SadTab.MRecycler.Visibility = ViewStates.Gone;

                        SadTab.Inflated = SadTab.Inflated switch
                        {
                            null => SadTab.EmptyStateLayout.Inflate(),
                            _ => SadTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(SadTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        SadTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }

                if (AngryTab != null)
                {
                    AngryTab.SwipeRefreshLayout.Refreshing = AngryTab.SwipeRefreshLayout.Refreshing switch
                    {
                        true => false,
                        _ => AngryTab.SwipeRefreshLayout.Refreshing
                    };

                    switch (AngryTab.MAdapter.UserList.Count)
                    {
                    case > 0:
                        AngryTab.MRecycler.Visibility        = ViewStates.Visible;
                        AngryTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                        break;

                    default:
                    {
                        AngryTab.MRecycler.Visibility = ViewStates.Gone;

                        AngryTab.Inflated = AngryTab.Inflated switch
                        {
                            null => AngryTab.EmptyStateLayout.Inflate(),
                            _ => AngryTab.Inflated
                        };

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(AngryTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        switch (x.EmptyStateButton.HasOnClickListeners)
                        {
                        case false:
                            x.EmptyStateButton.Click += null !;
                            break;
                        }
                        AngryTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #15
0
        private async Task GetLikedPages(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

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

                var(apiStatus, respond) = await RequestsAsync.Page.GetLikedPages(UserDetails.UserId, offset, "10");

                if (apiStatus != 200 || !(respond is ListPagesObject 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.LikedPages);
                        if (checkList == null)
                        {
                            var section = new SocialModelsClass
                            {
                                Id        = 000001010101,
                                TitleHead = GetString(Resource.String.Lbl_Liked_Pages),
                                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.PageId)) where check == null select item)
                            {
                                item.IsLiked = new IsLiked
                                {
                                    Bool = true
                                };

                                MAdapter.SocialList.Add(new SocialModelsClass
                                {
                                    PageData = item,
                                    Id       = Convert.ToInt32(item.PageId),
                                    TypeView = SocialModelType.LikedPages
                                });
                            }
                        }
                        else
                        {
                            foreach (var item in from item in result.Data let check = MAdapter.SocialList.FirstOrDefault(a => a.Id == Convert.ToInt32(item.PageId)) where check == null select item)
                            {
                                item.IsLiked = new IsLiked
                                {
                                    Bool = true
                                };

                                MAdapter.SocialList.Add(new SocialModelsClass
                                {
                                    PageData = item,
                                    Id       = Convert.ToInt32(item.PageId),
                                    TypeView = SocialModelType.LikedPages
                                });
                            }
                        }
                    }
                    else
                    {
                        if (MAdapter.SocialList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMorePages), 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;
            }
        }
コード例 #16
0
        private void SearchViewOnQueryTextSubmit(string newText)
        {
            try
            {
                SearchText = newText;

                SearchView.ClearFocus();

                UserTab.MAdapter.UserList.Clear();
                UserTab.MAdapter.NotifyDataSetChanged();

                PagesTab.MAdapter.PageList.Clear();
                PagesTab.MAdapter.NotifyDataSetChanged();

                GroupsTab.MAdapter.GroupList.Clear();
                GroupsTab.MAdapter.NotifyDataSetChanged();

                OffsetUser  = "******";
                OffsetPage  = "0";
                OffsetGroup = "0";

                if (Methods.CheckConnectivity())
                {
                    if (UserTab.ProgressBarLoader != null)
                    {
                        UserTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    }

                    if (PagesTab.ProgressBarLoader != null)
                    {
                        PagesTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    }

                    if (GroupsTab.ProgressBarLoader != null)
                    {
                        GroupsTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    }

                    UserTab.EmptyStateLayout.Visibility   = ViewStates.Gone;
                    PagesTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                    GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone;


                    StartApiService();
                }
                else
                {
                    if (UserTab.Inflated == null)
                    {
                        UserTab.Inflated = UserTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoConnection);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                        x.EmptyStateButton.Click += null !;
                    }

                    x.EmptyStateButton.Click            += TryAgainButton_Click;
                    UserTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                    UserTab.EmptyStateLayout.Visibility  = ViewStates.Visible;
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
コード例 #17
0
        private async Task LoadJobsAsync(string offset)
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.JobList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Jobs.SearchJob(SearchText, UserDetails.FilterJobCategories, UserDetails.FilterJobType, UserDetails.FilterJobLocation, "10", offset);

                if (apiStatus != 200 || !(respond is SearchJobObject 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)
                        {
                            MAdapter.JobList.Add(WoWonderTools.ListFilterJobs(item));
                        }

                        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;
            }
        }
コード例 #18
0
        public void Search(string text)
        {
            try
            {
                SearchText = text;

                if (!string.IsNullOrEmpty(SearchText))
                {
                    if (Methods.CheckConnectivity())
                    {
                        UserTab.MAdapter?.UserList?.Clear();
                        UserTab.MAdapter?.NotifyDataSetChanged();

                        PagesTab.MAdapter?.PageList?.Clear();
                        PagesTab.MAdapter?.NotifyDataSetChanged();

                        GroupsTab.MAdapter?.GroupList?.Clear();
                        GroupsTab.MAdapter?.NotifyDataSetChanged();

                        if (UserTab.ProgressBarLoader != null)
                        {
                            UserTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                        }

                        if (PagesTab.ProgressBarLoader != null)
                        {
                            PagesTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                        }

                        if (GroupsTab.ProgressBarLoader != null)
                        {
                            GroupsTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                        }

                        UserTab.EmptyStateLayout.Visibility   = ViewStates.Gone;
                        PagesTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                        GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone;

                        StartApiService();
                    }
                }
                else
                {
                    if (UserTab.Inflated == null)
                    {
                        UserTab.Inflated = UserTab.EmptyStateLayout?.Inflate();
                    }

                    EmptyStateInflater x1 = new EmptyStateInflater();
                    x1.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x1.EmptyStateButton.HasOnClickListeners)
                    {
                        x1.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x1.EmptyStateButton.Click -= TryAgainButton_Click;
                        x1.EmptyStateButton.Click += null !;
                    }

                    x1.EmptyStateButton.Click += TryAgainButton_Click;
                    if (UserTab.EmptyStateLayout != null)
                    {
                        UserTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }

                    UserTab.ProgressBarLoader.Visibility = ViewStates.Gone;

                    //==============================================
                    if (PagesTab.Inflated == null)
                    {
                        PagesTab.Inflated = PagesTab.EmptyStateLayout?.Inflate();
                    }

                    EmptyStateInflater x2 = new EmptyStateInflater();
                    x2.InflateLayout(PagesTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x2.EmptyStateButton.HasOnClickListeners)
                    {
                        x2.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x2.EmptyStateButton.Click -= TryAgainButton_Click;
                        x2.EmptyStateButton.Click += null !;
                    }

                    x2.EmptyStateButton.Click += TryAgainButton_Click;
                    if (PagesTab.EmptyStateLayout != null)
                    {
                        PagesTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }

                    PagesTab.ProgressBarLoader.Visibility = ViewStates.Gone;

                    //==============================================
                    if (GroupsTab.Inflated == null)
                    {
                        GroupsTab.Inflated = GroupsTab.EmptyStateLayout?.Inflate();
                    }

                    EmptyStateInflater x3 = new EmptyStateInflater();
                    x3.InflateLayout(GroupsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x3.EmptyStateButton.HasOnClickListeners)
                    {
                        x3.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x3.EmptyStateButton.Click -= TryAgainButton_Click;
                        x3.EmptyStateButton.Click += null !;
                    }

                    x3.EmptyStateButton.Click += TryAgainButton_Click;
                    if (GroupsTab.EmptyStateLayout != null)
                    {
                        GroupsTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }

                    GroupsTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #19
0
        private void EmptyStateButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                SearchBox.ClearFocus();
                SongsTab.MAdapter.SoundsList.Clear();
                SongsTab.MAdapter.NotifyDataSetChanged();

                AlbumsTab.MAdapter.AlbumsList.Clear();
                AlbumsTab.MAdapter.NotifyDataSetChanged();

                PlaylistTab.MAdapter.PlaylistList.Clear();
                PlaylistTab.MAdapter.NotifyDataSetChanged();

                ArtistsTab.MAdapter.UsersList.Clear();
                ArtistsTab.MAdapter.NotifyDataSetChanged();


                OffsetSongs    = "0";
                OffsetAlbums   = "0";
                OffsetPlaylist = "0";
                OffsetArtists  = "0";

                if (string.IsNullOrEmpty(SearchText) || string.IsNullOrWhiteSpace(SearchText))
                {
                    SearchText = "a";
                }

                ViewPager.SetCurrentItem(0, true);

                if (Methods.CheckConnectivity())
                {
                    if (SongsTab.MAdapter.SoundsList.Count > 0)
                    {
                        SongsTab.MAdapter.SoundsList.Clear();
                        SongsTab.MAdapter.NotifyDataSetChanged();
                    }

                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    StartApiService();
                }
                else
                {
                    if (SongsTab.Inflated == null)
                    {
                        SongsTab.Inflated = SongsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(SongsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click             += TryAgainButton_Click;
                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Visible;
                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
コード例 #20
0
        private void ShowEmptyPage()
        {
            try
            {
                UserTab.ProgressBarLoader.Visibility   = ViewStates.Gone;
                PagesTab.ProgressBarLoader.Visibility  = ViewStates.Gone;
                GroupsTab.ProgressBarLoader.Visibility = ViewStates.Gone;

                if (UserTab.MAdapter.UserList.Count > 0)
                {
                    UserTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    UserTab.Inflated ??= UserTab.EmptyStateLayout.Inflate();

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click           += TryAgainButton_Click;
                    UserTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }


                if (PagesTab.MAdapter.PageList.Count > 0)
                {
                    PagesTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    PagesTab.Inflated ??= PagesTab.EmptyStateLayout.Inflate();

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(PagesTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click            += TryAgainButton_Click;
                    PagesTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }

                if (GroupsTab.MAdapter.GroupList.Count > 0)
                {
                    GroupsTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    GroupsTab.Inflated ??= GroupsTab.EmptyStateLayout.Inflate();

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(GroupsTab.Inflated, EmptyStateInflater.Type.NoSearchResult);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                        x.EmptyStateButton.Click += null !;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    GroupsTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                //SwipeRefreshLayout.Refreshing = false;
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #21
0
        public async Task SearchGames(string offset = "0")
        {
            if (GamesTab.MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                GamesTab.MainScrollEvent.IsLoading = true;
                var countList = GamesTab.MAdapter.GamesList.Count;

                var(respondCode, respondString) = await RequestsAsync.Games.SearchGames(SearchKey, "15", offset);

                if (respondCode.Equals(200))
                {
                    if (respondString is FetchGamesObject result)
                    {
                        var respondList = result.Data.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Data let check = GamesTab.MAdapter.GamesList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    GamesTab.MAdapter.GamesList.Add(item);
                                }

                                RunOnUiThread(() => { GamesTab.MAdapter.NotifyItemRangeInserted(countList, GamesTab.MAdapter.GamesList.Count - countList); });
                            }
                            else
                            {
                                GamesTab.MAdapter.GamesList = new ObservableCollection <GamesDataObject>(result.Data);
                                RunOnUiThread(() => { GamesTab.MAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (GamesTab.MAdapter.GamesList.Count > 10 && !GamesTab.MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGames), ToastLength.Short)?.Show();
                            }
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(this, respondString);
                }

                RunOnUiThread(() => ShowEmptyPage("GetGames"));
            }
            else
            {
                GamesTab.Inflated = GamesTab.EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(GamesTab.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();
                GamesTab.MainScrollEvent.IsLoading = false;
            }
        }
コード例 #22
0
        private void ShowEmptyPage()
        {
            try
            {
                if (LikeTab != null)
                {
                    LikeTab.MainScrollEvent.IsLoading = false;
                }
                if (LoveTab != null)
                {
                    LoveTab.MainScrollEvent.IsLoading = false;
                }
                if (WowTab != null)
                {
                    WowTab.MainScrollEvent.IsLoading = false;
                }
                if (HahaTab != null)
                {
                    HahaTab.MainScrollEvent.IsLoading = false;
                }
                if (SadTab != null)
                {
                    SadTab.MainScrollEvent.IsLoading = false;
                }
                if (AngryTab != null)
                {
                    AngryTab.MainScrollEvent.IsLoading = false;
                }

                if (Adapter.Count != ViewPager.Adapter.Count)
                {
                    ViewPager.CurrentItem = Adapter.Count;
                    ViewPager.Adapter     = Adapter;
                    ViewPager.Adapter.NotifyDataSetChanged();
                }

                if (LikeTab != null)
                {
                    if (LikeTab.SwipeRefreshLayout.Refreshing)
                    {
                        LikeTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (LikeTab.MAdapter.UserList.Count > 0)
                    {
                        LikeTab.MRecycler.Visibility        = ViewStates.Visible;
                        LikeTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        LikeTab.MRecycler.Visibility = ViewStates.Gone;

                        LikeTab.Inflated ??= LikeTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(LikeTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        LikeTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }

                if (LoveTab != null)
                {
                    if (LoveTab.SwipeRefreshLayout.Refreshing)
                    {
                        LoveTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (LoveTab.MAdapter.UserList.Count > 0)
                    {
                        LoveTab.MRecycler.Visibility        = ViewStates.Visible;
                        LoveTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        LoveTab.MRecycler.Visibility = ViewStates.Gone;

                        LoveTab.Inflated ??= LoveTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(LoveTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        LoveTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }

                if (WowTab != null)
                {
                    if (WowTab.SwipeRefreshLayout.Refreshing)
                    {
                        WowTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (WowTab.MAdapter.UserList.Count > 0)
                    {
                        WowTab.MRecycler.Visibility        = ViewStates.Visible;
                        WowTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        WowTab.MRecycler.Visibility = ViewStates.Gone;

                        WowTab.Inflated ??= WowTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(WowTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        WowTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }

                if (HahaTab != null)
                {
                    if (HahaTab.SwipeRefreshLayout.Refreshing)
                    {
                        HahaTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (HahaTab.MAdapter.UserList.Count > 0)
                    {
                        HahaTab.MRecycler.Visibility        = ViewStates.Visible;
                        HahaTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        HahaTab.MRecycler.Visibility = ViewStates.Gone;

                        HahaTab.Inflated ??= HahaTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(HahaTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        HahaTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }

                if (SadTab != null)
                {
                    if (SadTab.SwipeRefreshLayout.Refreshing)
                    {
                        SadTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (SadTab.MAdapter.UserList.Count > 0)
                    {
                        SadTab.MRecycler.Visibility        = ViewStates.Visible;
                        SadTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        SadTab.MRecycler.Visibility = ViewStates.Gone;

                        SadTab.Inflated ??= SadTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(SadTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        SadTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }

                if (AngryTab != null)
                {
                    if (AngryTab.SwipeRefreshLayout.Refreshing)
                    {
                        AngryTab.SwipeRefreshLayout.Refreshing = false;
                    }

                    if (AngryTab.MAdapter.UserList.Count > 0)
                    {
                        AngryTab.MRecycler.Visibility        = ViewStates.Visible;
                        AngryTab.EmptyStateLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        AngryTab.MRecycler.Visibility = ViewStates.Gone;

                        AngryTab.Inflated ??= AngryTab.EmptyStateLayout.Inflate();

                        EmptyStateInflater x = new EmptyStateInflater();
                        x.InflateLayout(AngryTab.Inflated, EmptyStateInflater.Type.NoUsersReaction);
                        if (!x.EmptyStateButton.HasOnClickListeners)
                        {
                            x.EmptyStateButton.Click += null !;
                        }
                        AngryTab.EmptyStateLayout.Visibility = ViewStates.Visible;
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #23
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (Methods.CheckConnectivity())
            {
                if (UserDetails.IsLogin)
                {
                    if (MainScrollEvent.IsLoading)
                    {
                        return;
                    }

                    MainScrollEvent.IsLoading = true;

                    int countList = ReplyAdapter.ReplyList.Count;

                    var(apiStatus, respond) = await RequestsAsync.Comments.Get_Replies_Http(Comment.Id.ToString(), "20", offset);

                    if (apiStatus != 200 || !(respond is GetRepliesObject result) || result.Data == null)
                    {
                        MainScrollEvent.IsLoading = false;
                        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 = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    ReplyAdapter.ReplyList.Insert(0, item);
                                }

                                Activity.RunOnUiThread(() => { ReplyAdapter.NotifyItemRangeInserted(countList, ReplyAdapter.ReplyList.Count - countList); });
                            }
                            else
                            {
                                ReplyAdapter.ReplyList = new ObservableCollection <ReplyObject>(result.Data);
                                Activity.RunOnUiThread(() => { ReplyAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else if (ReplyAdapter.ReplyList.Count > 10 && !ReplyRecyclerView.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreComment), ToastLength.Short).Show();
                        }
                    }

                    Activity.RunOnUiThread(ShowEmptyPage);
                }
                else
                {
                    Activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            ReplyRecyclerView.Visibility = ViewStates.Gone;

                            Inflated             = EmptyStateLayout.Inflate();
                            EmptyStateInflater x = new EmptyStateInflater();
                            x.InflateLayout(Inflated, EmptyStateInflater.Type.Login);
                            if (!x.EmptyStateButton.HasOnClickListeners)
                            {
                                x.EmptyStateButton.Click += null;
                                x.EmptyStateButton.Click += LoginButtonOnClick;
                            }

                            EmptyStateLayout.Visibility = ViewStates.Visible;
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    });
                }
            }
            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;
        }
コード例 #24
0
        private async Task LoadGroup(string offset)
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                var countList = MAdapter.GroupList.Count;
                var(respondCode, respondString) = await RequestsAsync.Group.GetGroupsByCategory(CategoryId, "10", offset);

                if (respondCode.Equals(200))
                {
                    if (respondString is ListGroupsObject result)
                    {
                        var respondList = result.Data.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Data let check = MAdapter.GroupList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    MAdapter.GroupList.Add(item);
                                }

                                RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.GroupList.Count - countList); });
                            }
                            else
                            {
                                MAdapter.GroupList = new ObservableCollection <GroupClass>(result.Data);
                                RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                            }
                        }
                        else
                        {
                            if (MAdapter.GroupList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short).Show();
                            }
                        }
                    }
                }
                else
                {
                    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;
            }
            MainScrollEvent.IsLoading = false;
        }
コード例 #25
0
        private async Task LoadGroup(string offset)
        {
            if (SuggestedGroupScrollEvent != null && SuggestedGroupScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                if (SuggestedGroupScrollEvent != null)
                {
                    SuggestedGroupScrollEvent.IsLoading = true;
                }
                var countList = MAdapter.GroupList.Count;

                var(respondCode, respondString) = await RequestsAsync.Group.GetRecommendedGroups("10", offset);

                if (respondCode.Equals(200))
                {
                    if (respondString is ListGroupsObject result)
                    {
                        var respondList = result.Data.Count;
                        if (respondList > 0)
                        {
                            if (countList > 0)
                            {
                                foreach (var item in from item in result.Data let check = MAdapter.GroupList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                                {
                                    MAdapter.GroupList.Add(item);
                                }

                                RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.GroupList.Count - countList); });
                            }
                            else
                            {
                                MAdapter.GroupList = new ObservableCollection <GroupClass>(result.Data);

                                RunOnUiThread(() =>
                                {
                                    if (SuggestedGroupInflated == null)
                                    {
                                        SuggestedGroupInflated = SuggestedGroupViewStub.Inflate();
                                    }

                                    RecyclerInflaterSuggestedGroup = new TemplateRecyclerInflater();
                                    RecyclerInflaterSuggestedGroup.InflateLayout <GroupClass>(this, SuggestedGroupInflated, MAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, GetString(Resource.String.Lbl_SuggestedForYou), "", true);

                                    RecyclerInflaterSuggestedGroup.MainLinear.Click += MainLinearSuggestedGroupOnClick;

                                    if (SuggestedGroupScrollEvent == null)
                                    {
                                        RecyclerViewOnScrollListener playlistRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(RecyclerInflaterSuggestedGroup.LayoutManager);
                                        SuggestedGroupScrollEvent = playlistRecyclerViewOnScrollListener;
                                        SuggestedGroupScrollEvent.LoadMoreEvent += SuggestedGroupScrollEventOnLoadMoreEvent;
                                        RecyclerInflaterSuggestedGroup.Recyler.AddOnScrollListener(playlistRecyclerViewOnScrollListener);
                                        SuggestedGroupScrollEvent.IsLoading = false;
                                    }
                                });
                            }
                        }
                        else
                        {
                            if (RecyclerInflaterSuggestedGroup?.Recyler != null && MAdapter.GroupList.Count > 10 && !RecyclerInflaterSuggestedGroup.Recyler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short).Show();
                            }
                        }
                    }
                }
                else
                {
                    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();
                if (SuggestedGroupScrollEvent != null)
                {
                    SuggestedGroupScrollEvent.IsLoading = false;
                }
            }
        }
コード例 #26
0
        private void ShowEmptyPage()
        {
            try
            {
                SwipeRefreshLayout.OnFinishFreshAndLoad();

                if (ProgressBar.Visibility == ViewStates.Visible)
                {
                    ProgressBar.Visibility = ViewStates.Gone;
                }

                if (RecommendedList?.Count > 0)
                {
                    if (ViewPagerView.Adapter == null)
                    {
                        ViewPagerView.Adapter     = new ImageCoursalViewPager(Activity, RecommendedList);
                        ViewPagerView.CurrentItem = 0;
                        ViewPagerCircleIndicator.SetViewPager(ViewPagerView);
                    }
                    ViewPagerView.Adapter.NotifyDataSetChanged();
                }

                if (NewReleasesSoundAdapter.SoundsList?.Count > 0)
                {
                    if (NewReleasesInflated == null)
                    {
                        NewReleasesInflated = NewReleasesViewStub.Inflate();
                    }

                    TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater();
                    recyclerInflater.InflateLayout <SoundDataObject>(Activity, NewReleasesInflated, NewReleasesSoundAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_LatestSongs_Title), Context.GetText(Resource.String.Lbl_LatestSongs_Description));
                    if (!recyclerInflater.MainLinear.HasOnClickListeners)
                    {
                        recyclerInflater.MainLinear.Click += null;
                        recyclerInflater.MainLinear.Click += NewReleasesMoreOnClick;
                    }
                }

                if (RecentlyPlayedSoundAdapter.SoundsList?.Count > 0)
                {
                    if (RecentlyPlayedInflated == null)
                    {
                        RecentlyPlayedInflated = RecentlyPlayedViewStub.Inflate();
                    }

                    TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater();
                    recyclerInflater.InflateLayout <SoundDataObject>(Activity, RecentlyPlayedInflated, RecentlyPlayedSoundAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_RecentlyPlayed));
                    if (!recyclerInflater.MainLinear.HasOnClickListeners)
                    {
                        recyclerInflater.MainLinear.Click += null;
                        recyclerInflater.MainLinear.Click += RecentlyPlayedMoreOnClick;
                    }

                    SqLiteDatabase dbDatabase = new SqLiteDatabase();
                    dbDatabase.InsertOrReplace_PublicRecentlyPlayedSoundList(RecentlyPlayedSoundAdapter.SoundsList);
                    dbDatabase.Dispose();
                }

                if (PopularSoundAdapter.SoundsList?.Count > 0)
                {
                    if (PopularInflated == null)
                    {
                        PopularInflated = PopularViewStub.Inflate();
                    }

                    TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater();
                    recyclerInflater.InflateLayout <SoundDataObject>(Activity, PopularInflated, PopularSoundAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_Popular_Title));
                    if (!recyclerInflater.MainLinear.HasOnClickListeners)
                    {
                        recyclerInflater.MainLinear.Click += null;
                        recyclerInflater.MainLinear.Click += PopularMoreOnClick;
                    }
                }

                if (GenresAdapter.GenresList.Count == 0)
                {
                    GenresAdapter.GenresList = ListUtils.GenresList;
                }

                if (GenresAdapter.GenresList.Count > 0)
                {
                    if (BrowseInflated == null)
                    {
                        BrowseInflated = BrowseViewStub.Inflate();
                    }

                    TemplateRecyclerInflater recyclerInflater = new TemplateRecyclerInflater();
                    recyclerInflater.InflateLayout <GenresObject.DataGenres>(Activity, BrowseInflated, GenresAdapter, TemplateRecyclerInflater.TypeLayoutManager.LinearLayoutManagerHorizontal, 0, true, Context.GetText(Resource.String.Lbl_Browse), Context.GetText(Resource.String.Lbl_Browse_Description));
                    if (!recyclerInflater.MainLinear.HasOnClickListeners)
                    {
                        recyclerInflater.MainLinear.Click += null;
                        recyclerInflater.MainLinear.Click += BrowseMoreOnClick;
                    }
                }

                if (RecommendedList?.Count == 0 && NewReleasesSoundAdapter?.SoundsList?.Count == 0 && RecentlyPlayedSoundAdapter?.SoundsList?.Count == 0 &&
                    PopularSoundAdapter?.SoundsList?.Count == 0 && GenresAdapter?.GenresList?.Count == 0 && ArtistsAdapter.ArtistsList?.Count == 0)
                {
                    if (Inflated == null)
                    {
                        Inflated = EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSound);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click += null;
                    }
                    EmptyStateLayout.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                SwipeRefreshLayout.OnFinishFreshAndLoad();
                if (ProgressBar.Visibility == ViewStates.Visible)
                {
                    ProgressBar.Visibility = ViewStates.Gone;
                }
                Console.WriteLine(e);
            }
        }
コード例 #27
0
ファイル: SearchFragment.cs プロジェクト: divitiae/playtube
        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.Search_Videos_Http(SearchKey, "25", offset, DateId);

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

                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;
        }
コード例 #28
0
        private async Task GetMyPages()
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Page.GetMyPages("0", "7");

                if (apiStatus != 200 || !(respond is ListPagesObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        result.Data.Reverse();

                        var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.MangedPages);
                        if (checkList == null)
                        {
                            var socialSection = new SocialModelsClass
                            {
                                Id = 0001111111,
                                PagesModelClass = new PagesModelClass
                                {
                                    PagesList = new List <PageClass>(),
                                    More      = "",
                                    TitleHead = GetString(Resource.String.Lbl_Manage_Pages)
                                },
                                TypeView = SocialModelType.MangedPages
                            };

                            foreach (var item in from item in result.Data let check = socialSection.PagesModelClass.PagesList.FirstOrDefault(a => a.PageId == item.PageId) where check == null select item)
                            {
                                socialSection.PagesModelClass.PagesList.Add(item);
                                ListUtils.MyPageList.Add(item);
                            }

                            MAdapter.SocialList.Insert(0, socialSection);
                        }
                        else
                        {
                            foreach (var item in from item in result.Data let check = checkList.PagesModelClass.PagesList.FirstOrDefault(a => a.PageId == item.PageId) where check == null select item)
                            {
                                checkList.PagesModelClass.PagesList.Add(item);
                                ListUtils.MyPageList.Add(item);
                            }
                        }

                        await GetLikedPages();

                        RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                }

                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated ??= EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null !;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
            }
        }
コード例 #29
0
        private async Task LoadArticlesAsync(string offset = "")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

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

                int countList = MAdapter.ArticlesList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Article.Get_Articles("10", offset, CategoryId, UserId);

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

                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.ArticlesList.Count - countList); });
                        }
                        else
                        {
                            MAdapter.ArticlesList = new ObservableCollection <ArticleDataObject>(result.Articles);
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (MAdapter.ArticlesList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreArticles), 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;
            }
        }
コード例 #30
0
        private async Task LoadNearByAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

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

                await GetPosition();

                var dictionary = new Dictionary <string, string>
                {
                    { "limit", "10" },
                    { "offset", offset },
                    { "gender", UserDetails.NearByGender },
                    //{"keyword", ""},
                    { "status", UserDetails.NearByStatus },
                    { "distance", UserDetails.NearByDistanceCount },
                    { "lat", UserDetails.Lat },
                    { "lng", UserDetails.Lng },
                    { "relship", UserDetails.NearByRelationship },
                };

                int countList = MAdapter.UserList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Nearby.Get_Nearby_Users(dictionary);

                if (apiStatus == 200)
                {
                    if (respond is GetNearbyUsersObject result)
                    {
                        var respondList = result.NearbyUsers.Count;
                        if (respondList > 0)
                        {
                            foreach (var item in from item in result.NearbyUsers 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
                        {
                            if (MAdapter.UserList.Count > 10 && !MRecycler.CanScrollVertically(1))
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_No_more_users), ToastLength.Short)?.Show();
                            }
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(this, respond);
                }

                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null !;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                MainScrollEvent.IsLoading = false;
            }
        }