Пример #1
0
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = Utils.GetRecentItemsQuery(SelectedTvSeries.Id, new[] { "Season" });

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await ApiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException("GetRecentItems()", ex, NavigationService, Log);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
 private void ClearAllCollections()
 {
     try
     {
         if (MyMaps != null)
         {
             MyMaps.Clear();
         }
         if (FeaturedItems != null)
         {
             FeaturedItems.Clear();
         }
         if (RecentItems != null)
         {
             RecentItems.Clear();
         }
         if (MostPopularItems != null)
         {
             MostPopularItems.Clear();
         }
         if (FavoriteItems != null && (FavoriteItems.Items != null && FavoriteItems.Items.Count > 0))
         {
             FavoriteItems.Items.Clear();
         }
         if (PortalGroups != null)
         {
             PortalGroups.Clear();
         }
     }
     catch (Exception ex)
     {
         var _ = App.ShowExceptionDialog(ex);
     }
 }
        private async Task SortRecent(BaseItemDto[] items)
        {
            RecentItems.Clear();

            var recent = await Utils.SortRecentItems(items, App.SpecificSettings.IncludeTrailersInRecent);

            recent.Take(6).ToList().ForEach(recentItem => RecentItems.Add(recentItem));
        }
        private void Reset()
        {
            AuthenticationService.Current.Logout();

            _hasLoaded = false;
            Folders.Clear();
            RecentItems.Clear();
            Messenger.Default.Send(new NotificationMessage(Constants.Messages.ResetAppMsg));
        }
 private void Reset()
 {
     TileService.Current.ResetWideTile(App.SpecificSettings.UseTransparentTile);
     _hasLoaded = false;
     Folders.Clear();
     UserViews.Clear();
     RecentItems.Clear();
     FavouriteItems.Clear();
     InProgressItems.Clear();
 }
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = new ItemQuery
                {
                    UserId           = AuthenticationService.Current.LoggedInUser.Id,
                    ParentId         = SelectedTvSeries.Id,
                    Filters          = new[] { ItemFilter.IsRecentlyAdded },
                    ExcludeItemTypes = new [] { "Season" },
                    Fields           = new[]
                    {
                        ItemFields.ParentId
                    },
                    Recursive = true,
                    IsMissing = App.SpecificSettings.ShowMissingEpisodes,
                    IsUnaired = App.SpecificSettings.ShowUnairedEpisodes
                };

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await _apiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Log.ErrorException("GetRecentItems()", ex);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
        public async Task Initialize()
        {
            RecentItems.Clear();
            ShouldShowRecent = true;
            var result = await recentManager.GetCollection <RecentItemViewModel>();

            var partial    = result.OrderByDescending(x => x.LastUsedDate);
            var showRecent = settings.Get <string>("RecentItemsShown").GetOrDefault();
            int takeFirst;

            if (string.IsNullOrEmpty(showRecent) || showRecent.Equals("No limit"))
            {
                RecentItems.AddRange(partial);
            }
            else if (int.TryParse(showRecent, out takeFirst))
            {
                RecentItems.AddRange(partial.Take(takeFirst));
            }
            else
            {
                ShouldShowRecent = false;
            }
        }
Пример #8
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!HasMoreItems && !refresh)
            {
                //IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    Pagination = PaginationParameters.MaxPagesToLoad(1);
                    Views.Main.ActivitiesView.Current?.ShowTopLoadingYou();
                }
                else
                {
                    Views.Main.ActivitiesView.Current?.ShowBottomLoadingYou();
                }
                Views.Main.ActivitiesView.Current?.HideComments();
                CommentFeed = null;
                var result = await InstaApi.UserProcessor.GetRecentActivityFeedAsync(Pagination);

                FirstRun = false;
                Pagination.MaximumPagesToLoad = 1;
                if (!result.Succeeded)
                {
                    //IsLoading = false;
                    if (result.Value == null || result.Value?.Items?.Count == 0)
                    {
                        if (refresh)
                        {
                            Views.Main.ActivitiesView.Current?.HideTopLoadingYou();
                        }
                        else
                        {
                            Views.Main.ActivitiesView.Current?.HideBottomLoadingYou();
                        }
                        return;
                    }
                }
                MainPage.Current?.ShowActivityNotify(result.Value.Counts);
                if (string.IsNullOrEmpty(result.Value.NextMaxId))
                {
                    HasMoreItems = false;
                }

                if (result.Value?.Items?.Count > 0)
                {
                    if (refresh)
                    {
                        RecentItems.Clear();
                        RecentItems.CurrentList = null;
                    }

                    result.Value.Items.ForEach(item => RecentItems.AddWithColumns(item.ToRecentActivityFeed()));
                }
                await Task.Delay(1000);

                //IsLoading = false;
                await InstaApi.UserProcessor.MarkNewsInboxSeenAsync();

                await InstaApi.UserProcessor.MarkDiscoverMarkSuSeenAsync();
            }
            catch (Exception ex)
            {
                FirstRun =
                    /* IsLoading =*/ false;
                ex.PrintException("ActivitiesViewModel.LoadMoreItemsAsync");
            }
            if (refresh)
            {
                Views.Main.ActivitiesView.Current?.HideTopLoadingYou();
            }
            else
            {
                Views.Main.ActivitiesView.Current?.HideBottomLoadingYou();
            }
            refresh = false;
        }
Пример #9
0
 private void ClearAll()
 {
     _recent.ClearAll();
     RecentItems.Clear();
 }