private async void LoadFeed() { Utils.Loaders Loader = new Utils.Loaders(); List <Tweet2> lstTweets = await Loader.GetFeedAsync(); lstFeed.ItemsSource = FormatEntities(lstTweets); }
private async void LoadBlade(object sender, SelectionChangedEventArgs e) { // instantiate sender into a listview object ListView theSender = (ListView)sender; //Load a blade for the selected tweet //Tweet SelectedTweet = (sender as ListView).SelectedItem as Tweet; if (theSender.SelectedItem != null) { // this needs to go away at some point Tweet2 SelectedTweet = (theSender.SelectedItem as Tweet2).ShallowCopy(); // Create a new list of Tweet objects List <Tweet2> theTweet = new List <Tweet2>(); TwitterUser theUser = SelectedTweet.Tweet.User; string theTweetId = SelectedTweet.Tweet.Id; // we don't have to do this if there aren't any responses // but Twitter won't let us know this information without paying the big bucks Utils.Loaders Loader = new Utils.Loaders(); List <Tweet2> theTweets = await Loader.GetTweetRepliesAsync(theUser, theTweetId); // Add selected tweet to list theTweet.Add(SelectedTweet); // TODO // - use search API to retreive tweet responses. this will be inexact at best, but whatevs. // create a new listview control ListView newList = new ListView(); newList.Name = "lstFeed"; newList.Margin = new Thickness { Bottom = 0, Top = 7, Left = 0, Right = 0 }; // populate listview with selected tweet newList.ItemsSource = FormatEntities(theTweet); // unload any existing blades spawned by this view UnloadBlade(bladeView, theSender.Parent as BladeItem); BladeItem newBlade = new BladeItem(); newBlade.Name = "bldHome"; newBlade.Width = 430; newList.ItemTemplate = (DataTemplate)App.Current.Resources["TweetTemplate"]; newList.SelectionChanged += LoadBlade; newBlade.Content = newList; newBlade.Style = (Style)App.Current.Resources["BladeStyle"]; bladeView.Items.Add(newBlade); // TODO: scroll bladeView to newly-created blade. if (bladeView.BladeMode == BladeMode.Fullscreen) { // update the layout so StartBringIntoView() works bladeView.UpdateLayout(); // scroll BladeView to newly-created BladeItem newBlade.StartBringIntoView(); } } }