private async Task <bool> GetFeed() { var rssTools = new RSSService(); if (CrossConnectivity.Current.IsConnected) { rssFeed = await rssTools.GetFeedFromInternet(Constants.FeedURL); if (rssFeed != null) { return(true); } else { return(false); } } else { rssFeed = await rssTools.LoadFeedFromStorage(); if (rssFeed != null) { return(true); } else { return(false); } } }
/// <summary> /// Loads the selected RSSFeed to the ListBox when /// navigated to this page /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (isNewInstance) { Items = new ObservableCollection <RSSItem>(); ItemsView = new CollectionViewSource(); feedId = int.Parse(NavigationContext.QueryString["feed"]); pageId = int.Parse(NavigationContext.QueryString["page"]); RSSFeed feed = RSSService.GetRSSFeed(pageId, feedId); foreach (RSSItem item in feed.Items) { Items.Add(item); } ItemsView.Source = Items; ItemListBox.ItemsSource = ItemsView.View; ItemListBox.SelectedIndex = App.NO_SELECTION; isLoadingFinished = true; isNewInstance = false; } }
/// <summary> /// Loads feed's items to view /// </summary> /// <param name="useCache">True if cache should be used, otherwise false</param> private void LoadItems(bool useCache) { PivotItem selectedItem = RSSItemsPivot.SelectedItem as PivotItem; Grid contentGrid = selectedItem.Content as Grid; ProgressBar progressBar = contentGrid.Children.First() as ProgressBar; ListBox listBox = contentGrid.Children.Last() as ListBox; listBox.Visibility = Visibility.Collapsed; progressBar.Visibility = Visibility.Visible; progressBar.IsIndeterminate = true; RSSService.GetRSSItems( pageId, feedId, useCache, (rssItems) => { listBox.ItemsSource = rssItems; listBox.Visibility = Visibility.Visible; progressBar.Visibility = Visibility.Collapsed; progressBar.IsIndeterminate = false; }, (exception) => { MessageBox.Show("Application failed to retrieve content from server. Please check your network connectivity."); } ); }
public async void UpdateFeed() { _rssService = RSSService.Instance; FeedParser parser = new FeedParser(); IEnumerable <Item> items = null; try { items = await parser.Parse(new Uri("http://aditya-wibisana.blogspot.com/feeds/posts/default?alt=rss"), FeedType.Rss); } catch (Exception e) { if (e.GetType() == typeof(System.Net.WebException)) { Xamarin.Forms.MessagingCenter.Send(this, Constants.Constant.NO_INTERNET); return; } } FeedList = new ObservableCollection <Item>(); foreach (Item item in items) { FeedList.Add(item); } OnPropertyChanged("FeedList"); }
/// <summary> /// Handler for showing RSS item details when view is ready for it /// </summary> private void ItemPage_Loaded(object sender, RoutedEventArgs e) { browser.Navigated += ArticleWebBrowser_Navigated; if (item.Text != null) { browser.NavigateToString(RSSService.CreateArticleHTML(item)); } }
// Code to execute when the application is activated (brought to foreground) // This code will not execute when the application is first launched private void Application_Activated(object sender, ActivatedEventArgs e) { WasTombstoned = !e.IsApplicationInstancePreserved; // If we were tombstoned, load feeds if (WasTombstoned) { RSSService.InitializeFeeds(); } }
/// <summary> /// Overridden OnNavigatedTo handler /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (isNewInstance) { pageId = int.Parse(NavigationContext.QueryString["pageId"]); page = RSSService.GetRSSPage(pageId); if (page != null) { PageTitle.Text = page.Title; subscriptionsListBox.ItemsSource = page.Feeds; } isNewInstance = false; } }
/// <summary> /// Overridden OnNavigatedTo handler /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (isNewInstance) { originalFeedId = feedId = int.Parse(NavigationContext.QueryString["id"]); pageId = int.Parse(NavigationContext.QueryString["page"]); page = RSSService.GetRSSPage(pageId); InitializePivotViews(page); // Switch to the previously selected PivotItem, if it has been stored if (State.ContainsKey("feedPivotIndex")) { RSSItemsPivot.SelectedIndex = (int)State["feedPivotIndex"]; } isNewInstance = false; } }
public HomeController() { repositoryService = new RepositoryService(); rssService = new RSSService(); }
// Code to execute when the application is deactivated (sent to background) // This code will not execute when the application is closing private void Application_Deactivated(object sender, DeactivatedEventArgs e) { RSSService.PersistCache(); }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { RSSService.InitializeFeeds(); }
// Code to execute when the application is closing (eg, user hit Back) // This code will not execute when the application is deactivated private void Application_Closing(object sender, ClosingEventArgs e) { RSSService.PersistCache(); }
public MainViewModel() { XWingRssFeed = new RSSService <XWingRssItem>(new Uri(@"https://www.fantasyflightgames.com/en/rss/?tags=x-wing&"), XWingRssItem.CreateXWingRssItem); XWingRssFeed.RSSItemsChanged += RssFeedItemsChanged; XWingRssFeed.Start(); }
public void UpdateUser(RSSService.AccountData account) { if (UserDataModel.Instance.IsConnected) { AccountClient.UpdateAsync(UserDataModel.Instance.GetConnectionString(), account); } }
public ArticlePageViewModel() { _rssService = RSSService.Instance; Link = _rssService.Link; }