コード例 #1
0
 public void ResetCache()
 {
     Hashtag      = null;
     PageCount    = 1;
     Pagination   = PaginationParameters.MaxPagesToLoad(1);
     IsLoading    = true;
     Channel      = null;
     HasMoreItems = true;
     Items.Clear();
     ItemsX.Clear();
     FirstRun = true;
     IsMine   = false;
     RelatedHashtags.Clear();
 }
コード例 #2
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!IsMine)
            {
                return;
            }
            if (!HasMoreItems && !refresh)
            {
                IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    PageCount   = 1;
                    Pagination  = PaginationParameters.MaxPagesToLoad(1);
                    HashtagType = InstaHashtagSectionType.All;
                    try
                    {
                        Views.Infos.HashtagView.Current?.ShowTopLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableHashtagPostView.Current?.ShowTopLoading();
                    //}
                    //catch { }
                }
                else
                {
                    try
                    {
                        Views.Infos.HashtagView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableHashtagPostView.Current?.ShowBottomLoading();
                    //}
                    //catch { }
                }
                var result = await InstaApi.HashtagProcessor.GetHashtagsSectionsAsync(Hashtag, Pagination, HashtagType);

                PageCount++;
                FirstRun = false;
                if (!result.Succeeded)
                {
                    IsLoading = false;
                    if (result.Value == null || result.Value.Medias?.Count == 0)
                    {
                        Hide(refresh);
                        return;
                    }
                }

                HasMoreItems = result.Value.MoreAvailable;

                Pagination.NextMaxId = result.Value.NextMaxId;
                if (refresh)
                {
                    Items.Clear();
                }
                if (result.Value.Medias?.Count > 0)
                {
                    Items.AddRange(result.Value.Medias);
                    ItemsX.AddRange(result.Value.Medias);
                }
                if (result.Value.RelatedHashtags?.Count > 0)
                {
                    RelatedHashtags.Clear();
                    RelatedHashtags.AddRange(result.Value.RelatedHashtags);
                }
                if (result.Value.Channel != null)
                {
                    Channel = result.Value.Channel;
                }
                await Task.Delay(1000);

                IsLoading = false;
            }
            catch (Exception ex)
            {
                FirstRun      =
                    IsLoading = false;
                ex.PrintException("HashtagsRecentGenerator.LoadMoreItemsAsync");
            }
            HashtagType = InstaHashtagSectionType.Top;
            Hide(refresh);
        }