Ejemplo n.º 1
0
 public void ResetCache()
 {
     try
     {
         Items.Clear();
         ItemsX.Clear();
         HasMoreItems = true;
         IsLoading    = true;
         FirstRun     = true;
         Pagination   = PaginationParameters.MaxPagesToLoad(2);
     }
     catch { }
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
0
 public void ResetCache()
 {
     try
     {
         ClusterId    = "explore_all:0";
         clusterName_ = "";
         Channel      = null;
         FirstRun     = true;
         Items.Clear();
         ItemsX.Clear();
         Clusters.Clear();
         Pagination   = PaginationParameters.MaxPagesToLoad(1);
         HasMoreItems = true;
         IsLoading    = true;
     }
     catch { }
 }
Ejemplo n.º 4
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!HasMoreItems && !refresh)
            {
                IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    PageCount  = 1;
                    Pagination = PaginationParameters.MaxPagesToLoad(1);
                    try
                    {
                        Views.Main.ExploreView.Current?.ShowTopLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Main.ExploreClusterView.Current?.ShowTopLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableExplorePostView.Current?.ShowTopLoading();
                    //}
                    //catch { }
                }
                else
                {
                    try
                    {
                        Views.Main.ExploreView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Main.ExploreClusterView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableExplorePostView.Current?.ShowBottomLoading();
                    //}
                    //catch { }
                }

                var result = await InstaApi.FeedProcessor.GetTopicalExploreFeedAsync(Pagination, ClusterId);

                //if (DeviceUtil.IsMobile)
                Pagination.MaximumPagesToLoad = 2;
                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();
                    ItemsX.Clear();
                }
                if (result.Value.Medias?.Count > 0)
                {
                    //Items.AddRange(result.Value.Medias);
                    //ItemsX.AddRange(result.Value.Medias);
                    for (int i = 0; i < result.Value.Medias.Count; i++)
                    {
                        var l = result.Value.Medias[i];
                        if (!Items.Any(x => x.InstaIdentifier == l.InstaIdentifier))
                        {
                            Items.Add(l);
                            //ItemsX.Add(l);
                        }
                    }
                }
                if (result.Value.Clusters?.Count > 0)
                {
                    Clusters.Clear();
                    if (result.Value.Clusters[0].Title.ToLower() == "for you")
                    {
                        result.Value.Clusters.RemoveAt(0);
                    }
                    Clusters.AddRange(result.Value.Clusters);
                }
                if (result.Value.Channel != null)
                {
                    Channel = result.Value.Channel;
                }
                await Task.Delay(1000);

                IsLoading = false;
                if (refresh /*&& DeviceUtil.IsMobile*/)
                {
                    RunLoadMore();
                }
            }
            catch (Exception ex)
            {
                ex.PrintException("ExploreClusterGenerator.LoadMoreItemsAsync");
            }
            FirstRun = IsLoading = false;
            Hide(refresh);
        }
Ejemplo n.º 5
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!HasMoreItems && !refresh)
            {
                IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    PageCount  = 1;
                    Pagination = PaginationParameters.MaxPagesToLoad(2);
                    try
                    {
                        Views.Infos.UserDetailsView.Current?.ShowTopLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Infos.ProfileDetailsView.Current?.ShowTopLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableUserPostView.Current?.ShowTopLoading();
                    //}
                    //catch { }
                }
                else
                {
                    try
                    {
                        Views.Infos.UserDetailsView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Infos.ProfileDetailsView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    //try
                    //{
                    //    Views.Posts.ScrollableUserPostView.Current?.ShowBottomLoading();
                    //}
                    //catch { }
                }
                var result = await InstaApi.BusinessProcessor.GetUserShoppableMediaByIdAsync(UserId, Pagination);

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

                HasMoreItems = result.Value.NextMaxId != null;

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

                IsLoading = false;
            }
            catch (Exception ex)
            {
                FirstRun      =
                    IsLoading = false;
                ex.PrintException("UserDetailsShopMediasGenerator.LoadMoreItemsAsync");
            }
            Hide(refresh);
        }
Ejemplo n.º 6
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!HasMoreItems && !refresh)
            {
                IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    PageCount  = 1;
                    Pagination = PaginationParameters.MaxPagesToLoad(1);
                    try
                    {
                        Views.Infos.ArchiveView.Current?.ShowTopLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Infos.ArchiveView.Current?.ScrollableArchivePostUc.ShowTopLoading();
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        Views.Infos.ArchiveView.Current?.ShowBottomLoading();
                    }
                    catch { }
                    try
                    {
                        Views.Infos.ArchiveView.Current?.ScrollableArchivePostUc.ShowBottomLoading();
                    }
                    catch { }
                }

                var result = await InstaApi.MediaProcessor.GetArchivedMediaAsync(Pagination);

                Pagination.MaximumPagesToLoad = 1;
                PageCount++;
                FirstRun = false;
                if (!result.Succeeded)
                {
                    IsLoading = false;
                    if (result.Value == null || result.Value?.Count == 0)
                    {
                        Hide(refresh);
                        if (Items.Count == 0)
                        {
                            NoArchivedPostsVisibility = Visibility.Visible;
                        }
                        else
                        {
                            NoArchivedPostsVisibility = Visibility.Collapsed;
                        }
                        return;
                    }
                }

                HasMoreItems = !string.IsNullOrEmpty(result.Value.NextMaxId);

                Pagination.NextMaxId = result.Value.NextMaxId;
                if (refresh)
                {
                    Items.Clear();
                    ItemsX.Clear();
                }
                if (result.Value?.Count > 0)
                {
                    Items.AddRange(result.Value);
                }
                if (Items.Count == 0)
                {
                    NoArchivedPostsVisibility = Visibility.Visible;
                }
                else
                {
                    NoArchivedPostsVisibility = Visibility.Collapsed;
                }
                await Task.Delay(1000);

                IsLoading = false;
                if (refresh /*&& DeviceUtil.IsMobile*/)
                {
                    RunLoadMore();
                }
            }
            catch (Exception ex)
            {
                ex.PrintException("ArchiveViewModel.LoadMoreItemsAsync");
            }
            FirstRun = IsLoading = false;
            Hide(refresh);
        }