Ejemplo n.º 1
0
        public ISearchPagePayloadContent GetContentImpl()
        {
            if (_Content != null)
            {
                return(_Content);
            }

            switch (SearchTarget)
            {
            case SearchTarget.Keyword:
                _Content = Newtonsoft.Json.JsonConvert.DeserializeObject <KeywordSearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Tag:
                _Content = Newtonsoft.Json.JsonConvert.DeserializeObject <TagSearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Mylist:
                _Content = Newtonsoft.Json.JsonConvert.DeserializeObject <MylistSearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Community:
                _Content = Newtonsoft.Json.JsonConvert.DeserializeObject <CommunitySearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Niconama:
                _Content = Newtonsoft.Json.JsonConvert.DeserializeObject <LiveSearchPagePayloadContent>(ContentJson);
                break;

            default:
                break;
            }

            return(_Content);
        }
Ejemplo n.º 2
0
        public SearchPagePayload(ISearchPagePayloadContent content)
        {
            _Content = content;

            if (content is KeywordSearchPagePayloadContent)
            {
                SearchTarget = SearchTarget.Keyword;
            }
            else if (content is TagSearchPagePayloadContent)
            {
                SearchTarget = SearchTarget.Tag;
            }
            else if (content is MylistSearchPagePayloadContent)
            {
                SearchTarget = SearchTarget.Mylist;
            }
            else if (content is CommunitySearchPagePayloadContent)
            {
                SearchTarget = SearchTarget.Community;
            }
            else if (content is LiveSearchPagePayloadContent)
            {
                SearchTarget = SearchTarget.Niconama;
            }

            ContentJson = content.ToParameterString();
        }
        public static void Search(this PageManager pageManager, ISearchPagePayloadContent searchPayload, bool forgetLastSearch = false)
        {
            HohoemaPageType resultPageType = HohoemaPageType.Search;

            if (searchPayload is KeywordSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultKeyword;
            }
            else if (searchPayload is TagSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultTag;
            }
            else if (searchPayload is MylistSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultMylist;
            }
            else if (searchPayload is CommunitySearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultCommunity;
            }
            else if (searchPayload is LiveSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultLive;
            }

            pageManager.OpenPage(resultPageType, searchPayload.ToParameterString(), forgetLastSearch);
        }
Ejemplo n.º 4
0
        public ISearchPagePayloadContent GetContentImpl()
        {
            if (_Content != null)
            {
                return(_Content);
            }

            switch (SearchTarget)
            {
            case SearchTarget.Keyword:
                _Content = JsonSerializer.Deserialize <KeywordSearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Tag:
                _Content = JsonSerializer.Deserialize <TagSearchPagePayloadContent>(ContentJson);
                break;

            case SearchTarget.Niconama:
                _Content = JsonSerializer.Deserialize <LiveSearchPagePayloadContent>(ContentJson);
                break;

            default:
                break;
            }

            return(_Content);
        }
Ejemplo n.º 5
0
        public static void Search(this PageManager pageManager, ISearchPagePayloadContent searchPayload, bool forgetLastSearch = false)
        {
            HohoemaPageType resultPageType = HohoemaPageType.Search;

            if (searchPayload is KeywordSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultKeyword;
            }
            else if (searchPayload is TagSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultTag;
            }
            else if (searchPayload is MylistSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultMylist;
            }
            else if (searchPayload is CommunitySearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultCommunity;
            }
            else if (searchPayload is LiveSearchPagePayloadContent)
            {
                resultPageType = HohoemaPageType.SearchResultLive;
            }

            bool isRequireForgetLastNavigation = false;

            if (pageManager.CurrentPageType == HohoemaPageType.SearchResultCommunity ||
                pageManager.CurrentPageType == HohoemaPageType.SearchResultKeyword ||
                pageManager.CurrentPageType == HohoemaPageType.SearchResultTag ||
                pageManager.CurrentPageType == HohoemaPageType.SearchResultLive ||
                pageManager.CurrentPageType == HohoemaPageType.SearchResultMylist)
            {
                isRequireForgetLastNavigation = true;
            }

            pageManager.OpenPage(resultPageType, searchPayload.ToParameterString(), isRequireForgetLastNavigation);
        }
Ejemplo n.º 6
0
        public MenuNavigatePageBaseViewModel(
            HohoemaApp hohoemaApp,
            PageManager pageManager
            )
        {
            PageManager = pageManager;
            HohoemaApp  = hohoemaApp;

            // TV Mode
            if (Util.DeviceTypeHelper.IsXbox)
            {
                IsTVModeEnable = new ReactiveProperty <bool>(true);
            }
            else
            {
                IsTVModeEnable = HohoemaApp.UserSettings
                                 .AppearanceSettings.ObserveProperty(x => x.IsForceTVModeEnable)
                                 .ToReactiveProperty();
            }

            ServiceLevel = HohoemaApp.ObserveProperty(x => x.ServiceStatus)
                           .ToReadOnlyReactiveProperty();

            IsNeedFullScreenToggleHelp
                = ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen;

            IsOpenPane = new ReactiveProperty <bool>(false);

            MenuItems = new List <PageTypeSelectableItem>()
            {
                new PageTypeSelectableItem(HohoemaPageType.Search, OnMenuItemSelected, "検索", Symbol.Find),
                new PageTypeSelectableItem(HohoemaPageType.RankingCategoryList, OnMenuItemSelected, "ランキング", Symbol.Flag),
                new PageTypeSelectableItem(HohoemaPageType.UserMylist, OnMenuItemSelected, "マイリスト", Symbol.Bookmarks),
                new PageTypeSelectableItem(HohoemaPageType.FollowManage, OnMenuItemSelected, "フォロー", Symbol.OutlineStar),
                new PageTypeSelectableItem(HohoemaPageType.FeedGroupManage, OnMenuItemSelected, "フィード", Symbol.List),
            };

            SubMenuItems = new List <PageTypeSelectableItem>()
            {
                new PageTypeSelectableItem(HohoemaPageType.History, OnMenuItemSelected, "視聴履歴", Symbol.Clock),
                new PageTypeSelectableItem(HohoemaPageType.CacheManagement, OnMenuItemSelected, "キャッシュ管理", Symbol.Download),
                new PageTypeSelectableItem(HohoemaPageType.Settings, OnMenuItemSelected, "設定", Symbol.Setting),
                new PageTypeSelectableItem(HohoemaPageType.UserInfo, OnAccountMenuItemSelected, "アカウント", Symbol.Account),
            };

            AllMenuItems = MenuItems.Concat(SubMenuItems).ToList();

            MainSelectedItem = new ReactiveProperty <PageTypeSelectableItem>(MenuItems[0], ReactivePropertyMode.DistinctUntilChanged);
            SubSelectedItem  = new ReactiveProperty <PageTypeSelectableItem>(null, ReactivePropertyMode.DistinctUntilChanged);

            Observable.Merge(
                MainSelectedItem,
                SubSelectedItem
                )
            .Where(x => x != null)
            .Subscribe(x => x.SelectedAction(x.Source));

            PageManager.ObserveProperty(x => x.CurrentPageType)
            .Subscribe(pageType =>
            {
//                    IsOpenPane.Value = false;

                bool isMenuItemOpened = false;
                foreach (var item in MenuItems)
                {
                    if (item.Source == pageType)
                    {
                        MainSelectedItem.Value = item;
                        SubSelectedItem.Value  = null;
                        isMenuItemOpened       = true;
                        break;
                    }
                }

                foreach (var item in SubMenuItems)
                {
                    if (item.Source == pageType)
                    {
                        SubSelectedItem.Value  = item;
                        MainSelectedItem.Value = null;
                        isMenuItemOpened       = true;
                        break;
                    }
                }

                if (!isMenuItemOpened)
                {
                    MainSelectedItem.Value = null;
                    SubSelectedItem.Value  = null;
                }
            });

            IsSubMenuItemPage = PageManager.ObserveProperty(x => x.CurrentPageType)
                                .Select(x => SubMenuItems.Any(y => y.Source == x))
                                .ToReactiveProperty();



            PageManager.ObserveProperty(x => x.PageTitle)
            .Subscribe(x =>
            {
                TitleText = x;
            });


            IsVisibleMenu = PageManager.ObserveProperty(x => x.CurrentPageType)
                            .Select(x =>
            {
                return(PageManager.DontNeedMenuPageTypes.All(dontNeedMenuPageType => x != dontNeedMenuPageType));
            })
                            .ToReactiveProperty();

            NowNavigating = PageManager.ObserveProperty(x => x.PageNavigating)
                            .ToReactiveProperty();


            PageManager.StartWork    += PageManager_StartWork;
            PageManager.ProgressWork += PageManager_ProgressWork;
            PageManager.CompleteWork += PageManager_CompleteWork;
            PageManager.CancelWork   += PageManager_CancelWork;



            var updater = HohoemaApp.BackgroundUpdater;

            var bgUpdateStartedObserver = Observable.FromEventPattern <BackgroundUpdateScheduleHandler>(
                handler => updater.BackgroundUpdateStartedEvent += handler,
                handler => updater.BackgroundUpdateStartedEvent -= handler
                );

            var bgUpdateCompletedObserver = Observable.FromEventPattern <BackgroundUpdateScheduleHandler>(
                handler => updater.BackgroundUpdateCompletedEvent += handler,
                handler => updater.BackgroundUpdateCompletedEvent -= handler
                );


            var bgUpdateCanceledObserver = Observable.FromEventPattern <BackgroundUpdateScheduleHandler>(
                handler => updater.BackgroundUpdateCanceledEvent += handler,
                handler => updater.BackgroundUpdateCanceledEvent -= handler
                );

            BGUpdateText    = new ReactiveProperty <string>();
            HasBGUpdateText = BGUpdateText.Select(x => !string.IsNullOrEmpty(x))
                              .ToReactiveProperty();
            bgUpdateStartedObserver.Subscribe(x =>
            {
                if (!string.IsNullOrEmpty(x.EventArgs.Label))
                {
                    BGUpdateText.Value = $"{x.EventArgs.Label} を処理中...";
                }
                else
                {
                    BGUpdateText.Value = $"{x.EventArgs.Id} を処理中...";
                }
            });


            Observable.Merge(
                bgUpdateCompletedObserver,
                bgUpdateCanceledObserver
                )
            .Throttle(TimeSpan.FromSeconds(2))
            .Subscribe(x =>
            {
                BGUpdateText.Value = null;
            });

            HohoemaApp.ObserveProperty(x => x.IsLoggedIn)
            .Subscribe(x => IsLoggedIn = x);

            HohoemaApp.ObserveProperty(x => x.LoginUserName)
            .Subscribe(x =>
            {
                UserName = x;
                UserMail = AccountManager.GetPrimaryAccountId();
            });

            HohoemaApp.ObserveProperty(x => x.UserIconUrl)
            .Subscribe(x => UserIconUrl = x);



            // 検索
            SearchKeyword = new ReactiveProperty <string>("");
            SearchTarget  = new ReactiveProperty <Models.SearchTarget>(Models.SearchTarget.Keyword);

            SearchCommand = SearchKeyword
                            .Select(x => !string.IsNullOrWhiteSpace(x))
                            .ToReactiveCommand();
            SearchCommand.Subscribe(_ =>
            {
                ISearchPagePayloadContent searchContent =
                    SearchPagePayloadContentHelper.CreateDefault(SearchTarget.Value, SearchKeyword.Value);
                PageManager.Search(searchContent);

                IsMobileNowSearching = false;
            });
        }