예제 #1
0
        private void loadData()
        {
            refView.IsRefreshing = true;
            Models.AllGradesResponse        resp;
            Task <Models.AllGradesResponse> task = Task.Run(() => restService.GetAllGradesAsync());

            task.ContinueWith(t => Device.BeginInvokeOnMainThread(
                                  async() =>
            {
                if (t.IsFaulted)
                {
                    await App.Current.MainPage.DisplayAlert("Connection error", "There was an error connecting to the server", "Try Again");
                }
                resp = t.Result;
                if (!resp.Success)
                {
                    refView.IsRefreshing = false;
                    await App.Current.MainPage.DisplayAlert(resp.Error.Message, resp.Error.Detail, "Try Again");
                    return;
                }
                grades = resp.Grades.values;


                refView.IsRefreshing   = false;
                gradPicker.ItemsSource = grades;
            }
                                  ));
        }
예제 #2
0
        private void loadData()
        {
            isRefreshing = true;
            Models.AllGradesResponse        resp;
            Task <Models.AllGradesResponse> task = Task.Run(() => restService.GetAllGradesAsync());

            task.ContinueWith(t => Device.BeginInvokeOnMainThread(
                                  async() =>
            {
                if (t.IsFaulted)
                {
                    await App.Current.MainPage.DisplayAlert("Connection error", "There was an error connecting to the server", "Try Again");
                }
                resp = t.Result;
                if (!resp.Success)
                {
                    isRefreshing = false;
                    await App.Current.MainPage.DisplayAlert(resp.Error.Message, resp.Error.Detail, "Try Again");
                    return;
                }
                grades = resp.Grades.values;


                gradesCollection.Clear();



                foreach (var g in grades)
                {
                    GradeCell newG  = new GradeCell(g);
                    newG.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black;
                    gradesCollection.Add(newG);
                }
                isRefreshing = false;
            }
                                  ));
        }