コード例 #1
0
        public MenuPageViewModel(int index, Func <IDataSource> getGetDataSource, IConnectionListener connectionListener)
        {
            _getDataSource      = getGetDataSource;
            _connectionListener = connectionListener;
            _connectionListener.Subscribe(this);
            _categories = new ObservableCollection <GuideCategoryNodeViewModel>();

            if (_getDataSource().IsAuthorized)
            {
                _recommendedSectionViewModel = new RecommendedSectionViewModel(_getDataSource, connectionListener, this);
                _subscriptions           = new SubscriptionChannelsViewModel(_getDataSource, connectionListener);
                _history                 = new HistoryPageViewModel(_getDataSource, connectionListener);
                _likedViewModel          = new LikedViewModel(_getDataSource, connectionListener);
                _uploadedPageViewModel   = new UploadedPageViewModel(_getDataSource, connectionListener);
                _myPlaylistListViewModel = new MyPlaylistListViewModel(_getDataSource, connectionListener, new NoContextMenuStrategy(), this);
            }

            _categoryCommand = new RelayCommand <NavigationObject>(CategoryLoad);

            SelectedIndex = index;

            _isConnected = connectionListener.CheckNetworkAvailability();
            //App.ViewModel.IndicatorHolder.Subscribe(() =>
            //{
            //    ProgressIndicator = App.ViewModel.IndicatorHolder.ProgressIndicator;
            //});
        }
コード例 #2
0
        private async void LoadVideoItem(string videoId)
        {
            RelatedVideosViewModel = new RelatedVideosViewModel(videoId, _getDataSource, _connectionListener, this);
            CommentsViewModel      = new CommentsViewModel(videoId, _getDataSource, _connectionListener);

            var videoItem = await _getDataSource().GetVideoItem(videoId);

            if (videoItem == null)
            {
                return;
            }

            SetChannelInfo(videoItem.ChannelId);

            LayoutHelper.InvokeFromUiThread(() =>
            {
                if (!_connectionListener.CheckNetworkAvailability())
                {
                    return;
                }

                if (videoItem.Details != null)
                {
                    Title       = videoItem.Details.Title;
                    Description = videoItem.Details.Description;
                    Duration    = videoItem.Details.Duration;
                    ViewCount   = videoItem.Details.Statistics.ViewCount;
                    SetLikesAndDislikes(videoItem.Details.Statistics);
                    IsLive = videoItem.Details.IsLive;
                }

                if (videoItem.Thumbnails != null)
                {
                    ImagePath = videoItem.Thumbnails.GetThumbnailUrl();
                }

                if (videoItem.PublishedAt != null)
                {
                    PublishedAt = videoItem.PublishedAt.Value.ToString("D");
                }

                SetVideoRating(videoId);
                var defaultQuality = SettingsHelper.GetQuality();
                var quality        = _qualityConverter.GetQualityEnum(defaultQuality);
                SetVideoUri(videoId, quality, IsLive);
            });
        }