private async Task FeedReInit(RssSchema data) { bool isUnread = Convert.ToBoolean(AppTools.GetLocalSetting(AppSettings.IsJustUnread, "False")); if (!isUnread) { ShowFeeds.Insert(0, _sourceFeed); } ShowFeeds.Remove(data); _sourceFeed = data; LoadingRing.IsActive = true; if (MainPage.Current.ChannelListView.SelectedItem != null) { var selectChannel = MainPage.Current.ChannelListView.SelectedItem as Channel; if (MainPage.Current.ReadableList.Any(c => c.Id == selectChannel.Id)) { DetailWebView.NavigateToString(""); SmartReader.Article article = await SmartReader.Reader.ParseArticleAsync(_sourceFeed.FeedUrl); if (article.IsReadable || !string.IsNullOrEmpty(article.TextContent)) { _sourceFeed.Content = article.Content; } else { new PopupToast(AppTools.GetReswLanguage("Tip_ReadError"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); } } } await UpdateFeed(); LoadingRing.IsActive = false; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.Back) { ReadabilityButton.IsEnabled = true; return; } if (e.Parameter != null) { ShowFeeds.Clear(); // 这种情况表明入口点为频道 if (e.Parameter is Tuple <RssSchema, List <RssSchema> > ) { var anim = ConnectedAnimationService.GetForCurrentView().GetAnimation("ForwardConnectedAnimation"); if (anim != null) { anim.TryStart(TitleTextBlock); } LoadingRing.IsActive = true; var data = e.Parameter as Tuple <RssSchema, List <RssSchema> >; bool isUnread = Convert.ToBoolean(AppTools.GetLocalSetting(AppSettings.IsJustUnread, "False")); bool isCollection = Convert.ToBoolean(MainPage.Current.TodoButton.IsChecked) || Convert.ToBoolean(MainPage.Current.StarButton.IsChecked); _sourceFeed = data.Item1; AllFeeds = data.Item2; TitleTextBlock.Text = _sourceFeed.Title; MainPage.Current.AddReadId(_sourceFeed.InternalID); foreach (var item in AllFeeds) { if (item.InternalID != _sourceFeed.InternalID) { if (isUnread && !isCollection && !MainPage.Current.ReadIds.Contains(item.InternalID)) { ShowFeeds.Add(item); } else if (!isUnread || isCollection) { ShowFeeds.Add(item); } } } if (MainPage.Current.ChannelListView.SelectedItem != null) { var selectChannel = MainPage.Current.ChannelListView.SelectedItem as Channel; if (MainPage.Current.ReadableList.Any(c => c.Id == selectChannel.Id)) { SmartReader.Article article = await SmartReader.Reader.ParseArticleAsync(_sourceFeed.FeedUrl); if (article.IsReadable || !string.IsNullOrEmpty(article.TextContent)) { _sourceFeed.Content = article.Content; } else { new PopupToast(AppTools.GetReswLanguage("Tip_ReadError"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); } } } _sourceContent = _sourceFeed.Content; await GenerateActivityAsync(_sourceFeed); } // 这种情况表明入口点是动态卡片 else if (e.Parameter is string[]) { var data = e.Parameter as string[]; _sourceFeed = new RssSchema() { InternalID = data[0], Title = data[1], Content = data[2], FeedUrl = data[3], ImageUrl = data[4], PublishDate = Convert.ToDateTime(data[5]), Summary = data[6], }; _sourceContent = data[2]; LoadingRing.IsActive = true; GridViewButton.Visibility = Visibility.Collapsed; SideListButton.Visibility = Visibility.Collapsed; FeedListView.Visibility = Visibility.Collapsed; Grid.SetColumn(SideControlContainer, 1); MainPage.Current.SideHide(); SideControlContainer.HorizontalAlignment = HorizontalAlignment.Right; SideControlContainer.Margin = new Thickness(0, 0, 10, 0); DetailSplitView.IsPaneOpen = false; } // 入口点是通知 else if (e.Parameter is string) { string url = e.Parameter as string; _sourceFeed = new RssSchema { InternalID = url, FeedUrl = url }; var content = await ReadabilityFromUrl(url); _sourceFeed.Content = content.Content ?? content.TextContent; _sourceFeed.Title = content.Title; _sourceFeed.PublishDate = Convert.ToDateTime(content.PublicationDate).ToLocalTime(); _sourceFeed.ImageUrl = content.FeaturedImage; _sourceContent = content.Content ?? content.TextContent; LoadingRing.IsActive = true; GridViewButton.Visibility = Visibility.Collapsed; SideListButton.Visibility = Visibility.Collapsed; FeedListView.Visibility = Visibility.Collapsed; Grid.SetColumn(SideControlContainer, 1); MainPage.Current.SideHide(); SideControlContainer.HorizontalAlignment = HorizontalAlignment.Right; SideControlContainer.Margin = new Thickness(0, 0, 10, 0); DetailSplitView.IsPaneOpen = false; } ButtonStatusCheck(); TitleTextBlock.Text = _sourceFeed.Title; string html = await PackageHTML(_sourceFeed.Content ?? _sourceFeed.Summary); DetailWebView.NavigateToString(html); string fontFamily = AppTools.GetLocalSetting(AppSettings.ReadFontFamily, "Tw Cen MT"); string fontSize = AppTools.GetLocalSetting(AppSettings.ReadFontSize, "16"); var selectFontFamily = MainPage.Current.SystemFonts.Where(p => p.Name == fontFamily).FirstOrDefault(); FontFamilyComboBox.SelectedItem = selectFontFamily; FontSizeTextBox.Text = fontSize; _isInit = true; } }