protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); this.id = (int)e.Parameter; this.root = await HNItem.fromID(id); this.ScoreText.Text = root.score.ToString(); this.TitleText.Text = root.title; RefreshThread(id); }
private async void RefreshMessages(string category) { var client = new HttpClient(); var raw = await client.GetStringAsync(new Uri("https://hacker-news.firebaseio.com/v0/" + category + "stories.json")); List <int> topids = JsonConvert.DeserializeObject <List <int> >(raw); var topitems = new List <HNItem>(); while (topitems.Count < 20) { topitems.Add(await HNItem.fromID(topids[topitems.Count], client)); } MessageList.ItemsSource = topitems; }
private async Task <List <ThreadItem> > buildThread(List <ThreadItem> thread, int level, List <int> nodes, HttpClient client) { if (nodes != null) { foreach (int kidid in nodes) { var kid = await HNItem.fromID(kidid); thread.Add(new ThreadItem(level, kid)); await buildThread(thread, level + 1, kid.kids, client); } } return(thread); }