private async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { using (var httpClient = new HttpClient()) { var feed = "http://api.espn.com/v1/sports/soccer/fifa.world/news?apikey=trs58u4j7gw4aat7ck8dsmgc"; var responseString = await httpClient.GetStringAsync(feed); NewsItems.Clear(); var items = await ParseFeed(responseString); foreach (var item in items) { newsItems.Add(item); } } } catch (Exception) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load News.", "OK", null); } IsBusy = false; }
/// <summary> /// Creates and adds the data to the viewmodels /// </summary> public void LoadData(bool reload) { if (!IsEssentialsLoaded) { LoadInfo(); LoadAssociations(); LoadSettings(); try { LoadFaceBookSettings(); } catch (Exception) { //NIET INGELOGD } } if (!reload) { return; } RestoItems.Clear(); NewsItems.Clear(); ActivityItems.Clear(); SchamperItems.Clear(); _fromCache = DateTime.Now.AddMinutes(-60) < _cacheTime; if (!_fromCache && !HasConnection) { _fromCache = true; } LoadNews(); LoadResto(); LoadActivities(); LoadSchamper(); }
public void LoadData(object param = null) { // Load Trovesaurus data from API try { log.Info("Loading Trovesaurus news, calendar, and streams data"); if (_StatusTimer == null) { StartStatusTimer(); } CheckStatus(); TrovesaurusApi.RefreshNewsList(); NewsItems.Clear(); foreach (var item in TrovesaurusApi.NewsList) { NewsItems.Add(item); } TrovesaurusApi.RefreshCalendarList(); CalendarItems.Clear(); foreach (var item in TrovesaurusApi.CalendarList) { CalendarItems.Add(item); } TrovesaurusApi.RefreshStreamList(); OnlineStreams.Clear(); foreach (var item in TrovesaurusApi.StreamList) { OnlineStreams.Add(item); } CalendarView.SortDescriptions.Clear(); CalendarView.SortDescriptions.Add(new SortDescription("EndDateTime", ListSortDirection.Ascending)); log.Info("Trovesaurus news, calendar, and streams data loaded successfully"); } catch (Exception ex) { log.Error("Error loading Trovesaurus news, calendar or streams", ex); } }
async Task ExecuteLoadItemsCommand() { IsBusy = true; try { NewsItems.Clear(); var activities = await DataStore.GetItemsAsync(true); foreach (var activity in activities) { NewsItems.Add(activity); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void LoadNewsFeed() { NewsProvider.GetVideos((videos, exception) => { SmartDispatcher.BeginInvoke(() => { NewsItems.Clear(); if (videos.Count >= 2) { NewsItems.Add(new NewsItem() { Title = Properties.Resources.WebTV_DMI, WebTVItem = videos.FirstOrDefault(v => v.Category == "DMI"), }); NewsItems.Add(new NewsItem() { Title = Properties.Resources.WebTV_3D, WebTVItem = videos.FirstOrDefault(v => v.Category == "3D"), }); } NewsProvider.GetNewsItems((items, e) => { SmartDispatcher.BeginInvoke(() => { foreach (var item in items) { NewsItems.Add(item); } }); }); }); }); }