protected override async Task <IAsyncEnumerable <CommunityVideoInfoViewModel> > GetPagedItemsImpl(int start, int count)
        {
            if (count >= VideoCount)
            {
                return(null);
            }

            var tail = (start + count);

            while (Items.Count < tail)
            {
                try
                {
                    var pageCount = (uint)(start / 20) + 1;

                    Debug.WriteLine("communitu video : page " + pageCount);
                    var videoRss = await CommunityProvider.GetCommunityVideo(CommunityId, pageCount);

                    var items = videoRss.Items;

                    Items.AddRange(items);
                }
                catch (Exception ex)
                {
                    TriggerError(ex);
                    return(null);
                }
            }

            return(Items.Skip(start).Take(count).Select(x => new CommunityVideoInfoViewModel(x)
            {
            }).ToAsyncEnumerable());
        }
        protected override async Task ListPageNavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            if (IsValidCommunity)
            {
                try
                {
                    var res = await CommunityProvider.GetCommunityDetail(CommunityId);

                    CommunityDetail = res.CommunitySammary.CommunityDetail;

                    CommunityName = CommunityDetail.Name;
                }
                catch
                {
                    Debug.WriteLine("コミュ情報取得に失敗");
                    IsValidCommunity = false;
                }
            }
            else
            {
                Debug.WriteLine("CommunityID は無効: " + CommunityId);
            }



            await base.ListPageNavigatedToAsync(cancelToken, e, viewModelState);
        }
 public CommunityVideoIncrementalSource(string communityId, int videoCount, CommunityProvider communityProvider)
     : base()
 {
     CommunityProvider = communityProvider;
     CommunityId       = communityId;
     VideoCount        = videoCount;
 }
Пример #4
0
        public HohoemaNotificationService(
            PageManager pageManager,
            QueuePlaylist queuePlaylist,
            HohoemaPlaylistPlayer hohoemaPlaylistPlayer,
            NiconicoSession niconicoSession,
            NotificationService notificationService,
            NicoVideoProvider nicoVideoProvider,
            MylistProvider mylistProvider,
            NicoLiveProvider nicoLiveProvider,
            CommunityProvider communityProvider,
            UserProvider userProvider,
            IMessenger messenger
            )
        {
            PageManager         = pageManager;
            _queuePlaylist      = queuePlaylist;
            _niconicoSession    = niconicoSession;
            NotificationService = notificationService;
            NicoVideoProvider   = nicoVideoProvider;
            MylistProvider      = mylistProvider;
            NicoLiveProvider    = nicoLiveProvider;
            CommunityProvider   = communityProvider;
            UserProvider        = userProvider;

            _messenger = messenger;
        }
 public CommunityVideoPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     CommunityProvider communityProvider,
     Services.PageManager pageManager
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     CommunityProvider        = communityProvider;
     PageManager = pageManager;
 }
 public CommunityVideoPageViewModel(
     CommunityProvider communityProvider,
     Services.PageManager pageManager,
     Services.HohoemaPlaylist hohoemaPlaylist
     )
     : base(pageManager)
 {
     CommunityProvider = communityProvider;
     HohoemaPlaylist   = hohoemaPlaylist;
 }
Пример #7
0
 public CommunityPageViewModel(Services.PageManager pageManager,
                               NiconicoSession niconicoSession,
                               CommunityFollowProvider followProvider,
                               CommunityProvider communityProvider,
                               FollowManager followManager,
                               NiconicoFollowToggleButtonService followToggleButtonService
                               )
     : base(pageManager)
 {
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
Пример #8
0
 public CommunityPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     PageManager pageManager,
     NiconicoSession niconicoSession,
     CommunityFollowProvider communityFollowProvider,
     CommunityProvider communityProvider
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     PageManager              = pageManager;
     NiconicoSession          = niconicoSession;
     _communityFollowProvider = communityFollowProvider;
     CommunityProvider        = communityProvider;
 }
Пример #9
0
 public CommunityPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     Services.PageManager pageManager,
     NiconicoSession niconicoSession,
     CommunityFollowProvider followProvider,
     CommunityProvider communityProvider,
     FollowManager followManager,
     NiconicoFollowToggleButtonService followToggleButtonService
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     PageManager               = pageManager;
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            if (parameters.TryGetValue("id", out string id))
            {
                CommunityId = id;

                try
                {
                    var res = await CommunityProvider.GetCommunityDetail(CommunityId);

                    CommunityDetail = res.CommunitySammary.CommunityDetail;

                    CommunityName = CommunityDetail.Name;
                }
                catch
                {
                    Debug.WriteLine("コミュ情報取得に失敗");
                }
            }

            await base.OnNavigatedToAsync(parameters);
        }
Пример #11
0
        private async Task <InAppNotificationPayload> SubmitCommunityContentSuggestion(string communityId)
        {
            Mntone.Nico2.Communities.Detail.CommunityDetailResponse communityDetail = null;
            try
            {
                communityDetail = await CommunityProvider.GetCommunityDetail(communityId);
            }
            catch { }

            if (communityDetail == null || !communityDetail.IsStatusOK)
            {
                return(null);
            }

            var communityInfo = communityDetail.CommunitySammary.CommunityDetail;

            return(new InAppNotificationPayload()
            {
                Content = $"{communityInfo.Name} をお探しですか?",
                ShowDuration = DefaultNotificationShowDuration,
                SymbolIcon = Symbol.Video,
                IsShowDismissButton = true,
                Commands =
                {
                    new InAppNotificationCommand()
                    {
                        Label = "コミュニティを開く",
                        Command = new DelegateCommand(() =>
                        {
                            PageManager.OpenPageWithId(HohoemaPageType.Community, communityId);

                            NotificationService.DismissInAppNotification();
                        })
                    },
                }
            });
        }
Пример #12
0
        public async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            // ナビゲーションパラメータからコミュニティIDを取得
            IsFailed = false;
            try
            {
                NowLoading = true;

                if (parameters.TryGetValue("id", out string id))
                {
                    CommunityId = id;

                    var res = await CommunityProvider.GetCommunityInfo(CommunityId);

                    if (res == null || !res.IsStatusOK)
                    {
                        return;
                    }

                    CommunityInfo = res.Community;

                    RaisePropertyChanged(nameof(CommunityName));
                    RaisePropertyChanged(nameof(IsPublic));
                    RaisePropertyChanged(nameof(CommunityDescription));
                    RaisePropertyChanged(nameof(IsOfficial));
                    RaisePropertyChanged(nameof(MaxUserCount));
                    RaisePropertyChanged(nameof(UserCount));
                    RaisePropertyChanged(nameof(CommunityLevel));
                    RaisePropertyChanged(nameof(CreatedAt));
                    RaisePropertyChanged(nameof(ThumbnailUrl));
                    RaisePropertyChanged(nameof(TopUrl));



                    var detail = await CommunityProvider.GetCommunityDetail(CommunityId);

                    if (detail == null && !detail.IsStatusOK)
                    {
                        return;
                    }

                    CommunityDetail = detail.CommunitySammary.CommunityDetail;

                    ApplicationTheme appTheme;
                    if (_appearanceSettings.Theme == ElementTheme.Dark)
                    {
                        appTheme = ApplicationTheme.Dark;
                    }
                    else if (_appearanceSettings.Theme == ElementTheme.Light)
                    {
                        appTheme = ApplicationTheme.Light;
                    }
                    else
                    {
                        appTheme = Views.Helpers.SystemThemeHelper.GetSystemTheme();
                    }
                    var profileHtmlId = $"{CommunityId}_profile";
                    ProfileHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(profileHtmlId, CommunityDetail.ProfielHtml, appTheme);

                    OwnerUserInfo = new UserInfoViewModel(
                        CommunityDetail.OwnerUserName,
                        CommunityDetail.OwnerUserId
                        );

                    IsOwnedCommunity = NiconicoSession.UserId.ToString() == OwnerUserInfo.Id;

                    Tags = CommunityDetail.Tags.Select(x => new NicoVideoTag(x))
                           .ToList();

                    FutureLiveList = CommunityDetail.FutureLiveList.Select(x => new CommunityLiveInfoViewModel(x))
                                     .ToList();

                    RecentLiveList = CommunityDetail.RecentLiveList.Select(x => new CommunityLiveInfoViewModel(x))
                                     .ToList();

                    NewsList = new List <CommunityNewsViewModel>();
                    foreach (var news in CommunityDetail.NewsList)
                    {
                        var newsVM = await CommunityNewsViewModel.Create(CommunityId, news.Title, news.PostAuthor, news.PostDate, news.ContentHtml, PageManager, _appearanceSettings);

                        NewsList.Add(newsVM);
                    }



                    HasNews = NewsList.Count > 0;


                    CurrentLiveInfoList = CommunityDetail.CurrentLiveList.Select(x => new CurrentLiveInfoViewModel(x, CommunityDetail))
                                          .ToList();

                    HasCurrentLiveInfo = CurrentLiveInfoList.Count > 0;

                    CommunityVideoSamples = new List <CommunityVideoInfoViewModel>();
                    foreach (var sampleVideo in CommunityDetail.VideoList)
                    {
                        var videoInfoVM = new CommunityVideoInfoViewModel(sampleVideo);

                        CommunityVideoSamples.Add(videoInfoVM);
                    }


                    RaisePropertyChanged(nameof(CommunityOwnerName));
                    RaisePropertyChanged(nameof(VideoCount));
                    RaisePropertyChanged(nameof(PrivilegeDescription));
                    //					RaisePropertyChanged(nameof(IsJoinAutoAccept));
                    //					RaisePropertyChanged(nameof(IsJoinWithoutPrivacyInfo));
                    //					RaisePropertyChanged(nameof(IsCanLiveOnlyPrivilege));
                    //					RaisePropertyChanged(nameof(IsCanAcceptJoinOnlyPrivilege));
                    //					RaisePropertyChanged(nameof(IsCanSubmitVideoOnlyPrivilege));

                    RaisePropertyChanged(nameof(ProfileHtmlFileUri));
                    RaisePropertyChanged(nameof(OwnerUserInfo));
                    RaisePropertyChanged(nameof(Tags));
                    RaisePropertyChanged(nameof(FutureLiveList));
                    RaisePropertyChanged(nameof(NewsList));
                    RaisePropertyChanged(nameof(HasNews));
                    RaisePropertyChanged(nameof(CurrentLiveInfoList));
                    RaisePropertyChanged(nameof(HasCurrentLiveInfo));
                    RaisePropertyChanged(nameof(CommunityVideoSamples));


                    // フォロー表示・操作の準備

                    // Note: オーナーコミュニティのフォローを解除=コミュニティの解散操作となるため注意が必要
                    // 安全管理上、アプリ上でコミュニティの解散は不可の方向に倒して対応したい
                    if (!IsOwnedCommunity)
                    {
                        FollowToggleButtonService.SetFollowTarget(this);
                    }
                    else
                    {
                        FollowToggleButtonService.SetFollowTarget(null);
                    }

                    UpdateCanNotFollowReason();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                IsFailed = true;
            }
            finally
            {
                NowLoading = false;
            }
        }
Пример #13
0
 public CommunityVideoPlaylistFactory(CommunityProvider communityProvider)
 {
     _communityProvider = communityProvider;
 }
Пример #14
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            // ナビゲーションパラメータからコミュニティIDを取得
            IsFailed = false;
            try
            {
                NowLoading = true;

                CommunityId = null;
                if (e.Parameter is string)
                {
                    CommunityId = e.Parameter as string;
                }

                // コミュニティ情報の取得
                if (!string.IsNullOrEmpty(CommunityId))
                {
                    var res = await CommunityProvider.GetCommunityInfo(CommunityId);

                    if (res == null || !res.IsStatusOK)
                    {
                        return;
                    }

                    CommunityInfo = res.Community;

                    RaisePropertyChanged(nameof(CommunityName));
                    RaisePropertyChanged(nameof(IsPublic));
                    RaisePropertyChanged(nameof(CommunityDescription));
                    RaisePropertyChanged(nameof(IsOfficial));
                    RaisePropertyChanged(nameof(MaxUserCount));
                    RaisePropertyChanged(nameof(UserCount));
                    RaisePropertyChanged(nameof(CommunityLevel));
                    RaisePropertyChanged(nameof(CreatedAt));
                    RaisePropertyChanged(nameof(ThumbnailUrl));
                    RaisePropertyChanged(nameof(TopUrl));



                    var detail = await CommunityProvider.GetCommunityDetail(CommunityId);

                    if (detail == null && !detail.IsStatusOK)
                    {
                        return;
                    }

                    CommunityDetail = detail.CommunitySammary.CommunityDetail;

                    var profileHtmlId = $"{CommunityId}_profile";
                    ProfileHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(profileHtmlId, CommunityDetail.ProfielHtml);

                    OwnerUserInfo = new UserInfoViewModel(
                        CommunityDetail.OwnerUserName,
                        CommunityDetail.OwnerUserId
                        );

                    IsOwnedCommunity = NiconicoSession.UserId.ToString() == OwnerUserInfo.Id;

                    Tags = CommunityDetail.Tags.Select(x => new TagViewModel(x))
                           .ToList();

                    FutureLiveList = CommunityDetail.FutureLiveList.Select(x => new CommunityLiveInfoViewModel(x))
                                     .ToList();

                    RecentLiveList = CommunityDetail.RecentLiveList.Select(x => new CommunityLiveInfoViewModel(x))
                                     .ToList();

                    NewsList = new List <CommunityNewsViewModel>();
                    foreach (var news in CommunityDetail.NewsList)
                    {
                        var newsVM = await CommunityNewsViewModel.Create(CommunityId, news.Title, news.PostAuthor, news.PostDate, news.ContentHtml, PageManager);

                        NewsList.Add(newsVM);
                    }



                    HasNews = NewsList.Count > 0;


                    CurrentLiveInfoList = CommunityDetail.CurrentLiveList.Select(x => new CurrentLiveInfoViewModel(x, CommunityDetail))
                                          .ToList();

                    HasCurrentLiveInfo = CurrentLiveInfoList.Count > 0;

                    CommunityVideoSamples = new List <CommunityVideoInfoViewModel>();
                    foreach (var sampleVideo in CommunityDetail.VideoList)
                    {
                        var videoInfoVM = new CommunityVideoInfoViewModel(sampleVideo);

                        CommunityVideoSamples.Add(videoInfoVM);
                    }


                    RaisePropertyChanged(nameof(CommunityOwnerName));
                    RaisePropertyChanged(nameof(VideoCount));
                    RaisePropertyChanged(nameof(PrivilegeDescription));
//					RaisePropertyChanged(nameof(IsJoinAutoAccept));
//					RaisePropertyChanged(nameof(IsJoinWithoutPrivacyInfo));
//					RaisePropertyChanged(nameof(IsCanLiveOnlyPrivilege));
//					RaisePropertyChanged(nameof(IsCanAcceptJoinOnlyPrivilege));
//					RaisePropertyChanged(nameof(IsCanSubmitVideoOnlyPrivilege));

                    RaisePropertyChanged(nameof(ProfileHtmlFileUri));
                    RaisePropertyChanged(nameof(OwnerUserInfo));
                    RaisePropertyChanged(nameof(Tags));
                    RaisePropertyChanged(nameof(FutureLiveList));
                    RaisePropertyChanged(nameof(NewsList));
                    RaisePropertyChanged(nameof(HasNews));
                    RaisePropertyChanged(nameof(CurrentLiveInfoList));
                    RaisePropertyChanged(nameof(HasCurrentLiveInfo));
                    RaisePropertyChanged(nameof(CommunityVideoSamples));


                    // フォロー表示・操作の準備

                    // Note: オーナーコミュニティのフォローを解除=コミュニティの解散操作となるため注意が必要
                    // 安全管理上、アプリ上でコミュニティの解散は不可の方向に倒して対応したい
                    if (!IsOwnedCommunity)
                    {
                        FollowToggleButtonService.SetFollowTarget(this);
                    }
                    else
                    {
                        FollowToggleButtonService.SetFollowTarget(null);
                    }

                    UpdateCanNotFollowReason();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                IsFailed = true;
            }
            finally
            {
                NowLoading = false;
            }
        }