protected override void ReLoadItemsAndSubViewSpecifications(out IList <MediaItem> mediaItems, out IList <ViewSpecification> subViewSpecifications)
        {
            base.ReLoadItemsAndSubViewSpecifications(out mediaItems, out subViewSpecifications);
            // Grouped display, nothing to do here
            if (subViewSpecifications.Count > 0)
            {
                return;
            }

            try
            {
                var mediaItemsResults = mediaItems;
                var lookup            = mediaItemsResults.ToLookup(SortByRecordingDateDesc.GetBestTitle, r => r).ToLookup(r => r.Count() == 1);
                // [true] --> Single media items
                // [false]--> Multi media items
                subViewSpecifications = new List <ViewSpecification>(0);
                var groupedItems = lookup[false].OrderByDescending(g => g.Max(r => SortByRecordingDateDesc.GetBestDate(r)));
                foreach (IGrouping <string, MediaItem> group in groupedItems)
                {
                    StackingSubViewSpecification subViewSpecification = new StackingSubViewSpecification(group.Key, NecessaryMIATypeIds, OptionalMIATypeIds, group.OrderByDescending(SortByRecordingDateDesc.GetBestDate).ToList());
                    subViewSpecifications.Add(subViewSpecification);
                }
                // Only one item per group, so first takes the only one
                mediaItems = lookup[true].Select(group => group.First()).ToList();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("StackingViewSpecification.ReLoadItemsAndSubViewSpecifications: Error requesting server", e);
                mediaItems            = null;
                subViewSpecifications = null;
            }
        }
        protected override async Task PrepareAsync()
        {
            await base.PrepareAsync();

            AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new RecordingItem(mi)
            {
                Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi))
            };

            _defaultScreen    = new RecordingsShowItemsScreenData(picd);
            _availableScreens = new List <AbstractScreenData>
            {
                _defaultScreen,
                new RecordingFilterByNameScreenData(),
                new RecordingsFilterByChannelScreenData(),
                //new VideosFilterByActorScreenData(),
                //new VideosFilterByDirectorScreenData(),
                //new VideosFilterByWriterScreenData(),
                //new VideosFilterByGenreScreenData(),
                //new VideosFilterByYearScreenData(),
                //new VideosFilterBySystemScreenData(),
                new RecordingsSimpleSearchScreenData(picd),
            };

            _defaultSorting    = new SortByRecordingDateDesc();
            _availableSortings = new List <Sorting>
            {
                _defaultSorting,
                new SortByTitle(),
                //new VideoSortByFirstGenre(),
                //new VideoSortByDuration(),
                //new VideoSortByFirstActor(),
                //new VideoSortByFirstDirector(),
                //new VideoSortByFirstWriter(),
                //new VideoSortBySize(),
                //new VideoSortByAspectRatio(),
                //new SortBySystem(),
            };

            var optionalMias = new[]
            {
                MovieAspect.ASPECT_ID,
                EpisodeAspect.ASPECT_ID,
                AudioAspect.ASPECT_ID,
                VideoAspect.ASPECT_ID,
                VideoStreamAspect.ASPECT_ID,
                VideoAudioStreamAspect.ASPECT_ID,
                ImageAspect.ASPECT_ID
            }.Union(MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode));

            _customRootViewSpecification = new StackingViewSpecification(_viewName, null, _necessaryMias, optionalMias, true)
            {
                MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE
            };
        }
Example #3
0
        public void InitMediaNavigation(out string mediaNavigationMode, out NavigationData navigationData)
        {
            IEnumerable <Guid> skinDependentOptionalMIATypeIDs = MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode);

            AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new VideoItem(mi)
            {
                Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi))
            };
            ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(SlimTvConsts.RES_RECORDINGS_VIEW_NAME,
                                                                                             null, SlimTvConsts.NECESSARY_RECORDING_MIAS, skinDependentOptionalMIATypeIDs, true)
            {
                MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE
            };
            AbstractScreenData defaultScreen = new RecordingFilterByNameScreenData();
            ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData>
            {
                // C# doesn't like it to have an assignment inside a collection initializer
                defaultScreen,
                new VideosShowItemsScreenData(picd),
                new RecordingsFilterByChannelScreenData(),
                new VideosFilterByActorScreenData(),
                new VideosFilterByGenreScreenData(),
                new VideosFilterByYearScreenData(),
                new VideosFilterBySystemScreenData(),
                new VideosSimpleSearchScreenData(picd),
            };
            Sorting defaultSorting = new SortByRecordingDateDesc();
            ICollection <Sorting> availableSortings = new List <Sorting>
            {
                defaultSorting,
                new SortByTitle(),
                new VideoSortByFirstGenre(),
                new VideoSortByDuration(),
                new VideoSortByDirector(),
                new VideoSortByFirstActor(),
                new VideoSortBySize(),
                new VideoSortByAspectRatio(),
                new SortBySystem(),
            };

            navigationData = new NavigationData(null, Consts.RES_MOVIES_VIEW_NAME, MediaNavigationRootState,
                                                MediaNavigationRootState, rootViewSpecification, defaultScreen, availableScreens, defaultSorting)
            {
                AvailableSortings = availableSortings
            };
            mediaNavigationMode = MediaNavigationMode;
        }