예제 #1
0
        protected async Task GetDataFromApi()
        {
            List <Apparatus> vehiclesList = await API.All();

            if (vehiclesList.Count > 0)
            {
                VehiclesListTableSource ListDataSource = new VehiclesListTableSource(this, vehiclesList);
                TableView.Source = ListDataSource;
                TableView.ReloadData();
            }
            else
            {
                UIAlertController _error = UIAlertController.Create("Error", "Could not load vehicles list.  Please check your server settings.  If problem persists, contact your administrator.", UIAlertControllerStyle.Alert);
                _error.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => { }));
                this.PresentViewController(_error, true, null);
            }
        }
        public async Task <List <Apparatus> > RefreshVehiclesList()
        {
            UIActivityIndicatorView loader = UIFactory.UiElementFactoryHelper.CreateLoader();

            AddSubview(loader);
            BringSubviewToFront(loader);
            loader.StartAnimating();

            List <Apparatus> vehiclesList = await API.All();

            ListDataSource = new VehiclesListTableSource(this, vehiclesList);
            Source         = ListDataSource;
            ReloadData();


            loader.StopAnimating();


            return(vehiclesList);
        }