Пример #1
0
        protected override async Task <IEnumerable <TabItem> > GetSections()
        {
            var apiClient = _sessionManager.ActiveApiClient;

            var userViews = await apiClient.GetUserViews(_sessionManager.LocalUserId, CancellationToken.None);

            var views = userViews.Items.Select(i =>
            {
                var collectionType = string.IsNullOrEmpty(i.CollectionType) || string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)
                    ? "folders"
                    : i.CollectionType;

                var supportedViews = new List <string>
                {
                    CollectionType.Movies,
                    "folders",
                    CollectionType.Channels,
                    CollectionType.Games,
                    CollectionType.TvShows,
                    CollectionType.Playlists,
                    CollectionType.LiveTv,
                    CollectionType.Photos,
                    CollectionType.Music,
                    CollectionType.BoxSets
                };

                if (!supportedViews.Contains(collectionType, StringComparer.OrdinalIgnoreCase))
                {
                    return(null);
                }

                return(new TabItem
                {
                    DisplayName = i.Name,
                    Name = collectionType,
                    Item = i
                });
            }).Where(i => i != null).ToList();

            if (_presentationManager.GetApps(_sessionManager.CurrentUser).Any())
            {
                views.Add(new TabItem
                {
                    Name        = "apps",
                    DisplayName = "Apps"
                });
            }

            return(views);
        }
Пример #2
0
        protected override async Task <IEnumerable <TabItem> > GetSections()
        {
            var userViews = await _apiClient.GetUserViews(_sessionManager.CurrentUser.Id, CancellationToken.None);

            var views = userViews.Items.Select(i =>
            {
                // Mixed folder type.
                if (string.IsNullOrEmpty(i.CollectionType))
                {
                    return(null);
                }

                var supportedViews = new List <string>
                {
                    CollectionType.Movies,
                    "Folders",
                    CollectionType.Channels,
                    CollectionType.Games,
                    CollectionType.TvShows,
                    CollectionType.Playlists,
                    CollectionType.LiveTv
                };

                if (!supportedViews.Contains(i.CollectionType, StringComparer.OrdinalIgnoreCase))
                {
                    return(null);
                }

                return(new TabItem
                {
                    DisplayName = i.Name,
                    Name = i.CollectionType,
                    Item = i
                });
            }).Where(i => i != null).ToList();

            if (_presentationManager.GetApps(_sessionManager.CurrentUser).Any())
            {
                views.Add(new TabItem
                {
                    Name        = "apps",
                    DisplayName = "Apps"
                });
            }

            return(views);
        }
        protected override async Task <IEnumerable <TabItem> > GetSections()
        {
            var views = new List <TabItem>
            {
                //_sessionManager.CurrentUser.Name.ToLower()
            };

            try
            {
                var itemCounts = await _apiClient.GetItemCountsAsync(new ItemCountsQuery
                {
                    UserId = _sessionManager.CurrentUser.Id
                });

                if (itemCounts.MovieCount > 0 || itemCounts.TrailerCount > 0)
                {
                    views.Add(new TabItem
                    {
                        Name        = "movies",
                        DisplayName = "Movies"
                    });
                }

                if (itemCounts.SeriesCount > 0 || itemCounts.EpisodeCount > 0)
                {
                    views.Add(new TabItem
                    {
                        Name        = "tv",
                        DisplayName = "TV"
                    });
                }

                //if (itemCounts.SongCount > 0)
                //{
                //    views.Add("music");
                //}
                if (itemCounts.GameCount > 0)
                {
                    views.Add(new TabItem
                    {
                        Name        = "games",
                        DisplayName = "Games"
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error getting item counts", ex);
            }

            views.Add(new TabItem
            {
                Name        = "favorites",
                DisplayName = "Favorites"
            });

            if (_presentationManager.GetApps(_sessionManager.CurrentUser).Any())
            {
                views.Add(new TabItem
                {
                    Name        = "apps",
                    DisplayName = "Apps"
                });
            }

            views.Add(new TabItem
            {
                Name        = "media collections",
                DisplayName = "Collections"
            });

            return(views);
        }