private async void Feed_TwarpEvent(object sender, EventArgs e) { FeedSelector feeder = sender as FeedSelector; if (feeder.hashtag.Length <= 2) { MessageDialog dialog = new MessageDialog("The hashtag must be greater than two characters in length.", "Invalid hashtag"); dialog.ShowAsync(); return; } TwarpTimeline timeline = new TwarpTimeline(Mobile); timeline.feeder = feeder; timeline.TweetEvent += Timeline_TweetEvent; timeline.CloseEvent += Timeline_CloseEvent; timeline.BackEvent += Timeline_BackEvent; await timeline.init(feeder.hashtag, feeder.startTime); if (timeline.noNetwork) { MessageDialog dialog = new MessageDialog("Please connect to the internet and try again.", "No internet connection"); dialog.ShowAsync(); return; } if (timeline.noData) { MessageDialog dialog = new MessageDialog("The twitter search returned no results. Try using a different hashtag.", "No results found"); dialog.ShowAsync(); return; } if (Mobile) { PivotItem pi = feeder.Parent as PivotItem; pi.Content = timeline; pi.Header = "#" + feeder.hashtag; } else { var index = mainStack.Children.IndexOf(feeder); mainStack.Children[index] = timeline; Grid.SetColumn(timeline, index); } // add history item: favHist.addHistory(feeder.hashtag, feeder.startTime); // enable back button if (Mobile) { stage = app_stage.timeline; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } }
private void Current_Resuming(object sender, object e) { // App resuming, check age of any active timelines, refresh those that are still current: DateTime old = DateTime.Now.AddMinutes(-30); if (Mobile) { foreach (PivotItem item in twarpPivot.Items) { if (item.Content is TwarpTimeline) { TwarpTimeline timeline = item.Content as TwarpTimeline; if (timeline.lastRefresh > old) { // timeline is less than 30 minutes old, refresh it: timeline.refresh(); return; } else { // timeline is old, return to feed selector: item.Content = timeline.feeder; } } } } else { foreach (var item in mainStack.Children) { if (item is TwarpTimeline) { TwarpTimeline timeline = item as TwarpTimeline; if (timeline.lastRefresh > old) { // timeline is less than 30 minutes old, let's refresh it: timeline.refresh(); return; } else { // item is old, return to feed selector: var index = mainStack.Children.IndexOf(item); mainStack.Children[index] = item; } } } } }