public async override void OnStart() { base.OnStart(); if (ViewModel.Facilities.Count == 0) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (ap.IsOnline(Application.Context)) { await ViewModel.ExecuteFacilitiesCommand(userId); // await this.SqlLiteManager.SyncFacilitiesFromAPI(ViewModel.Facilities); } else { //await this.SqlLiteManager.GetLocalFacilities(userId); } if (ViewModel.Facilities.Count == 0) { messageDialog.SendMessage("There are no facilities that are assinged to this profile.", "No Facilities Found"); } recyclerView.SetAdapter(adapter = new BrowseFacilitiesAdapter(Activity, ViewModel, userId)); messageDialog.HideLoading(); } refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; }
async void ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var items = await StoreManager.ItemStore.GetItemsAsync(true); Items.ReplaceRange(items); } catch (Exception ex) { //Handle exception here Debug.WriteLine(ex); MessageDialog.SendMessage("Unable to load items.", "Error"); } finally { IsBusy = false; } }
private async void LoadData() { RunOnUiThread(() => { progressBar.Visibility = ViewStates.Visible; progressBar.Indeterminate = true; }); try { var items = await BarHelper.GenerateData(viewModel, Resources.GetColor(Resource.Color.bar_up), Resources.GetColor(Resource.Color.bar_down)); RunOnUiThread(() => { if (items.Count == 0) { MessageDialog.SendMessage(this, "There is no data for this group, please check in a few members first to a meetup.", "No Statistics"); return; } else if (viewModel.GroupsEventsCount.ContainsKey(0)) { MessageDialog.SendMessage(this, "Data for group needs synced, please re-visit all meetups to synchronize data and return for in depth statistics.", "No Statistics"); } barChart.ItemsSource = items; barChart.Invalidate(); }); } finally { RunOnUiThread(() => { progressBar.Visibility = ViewStates.Gone; progressBar.Indeterminate = false; }); } }