private async Task RefreshAsync()
        {
            if (_isLoading)
            {
                return;
            }
            _isLoading = true;
            if (RefreshControl != null)
            {
                RefreshControl.BeginRefreshing();
            }
            try
            {
                await EventService.GetInstance().SyncAsync();

                EventItems.Clear();
                EventItems.AddRange(await EventService.GetInstance().GetItems());
                TableView.ReloadData();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                _isLoading = false;
                if (RefreshControl != null)
                {
                    RefreshControl.EndRefreshing();
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Method for Pull to refresh
 /// </summary>
 void RefreshTable(object sender, EventArgs e)
 {
     RefreshControl.BeginRefreshing();
     RefreshDeviceList();
     TableView.ReloadData();
     RefreshControl.EndRefreshing();
 }
        private async Task RefreshAsync()
        {
            RefreshControl.BeginRefreshing();
            await _service.RefreshDataAsync();

            RefreshControl.EndRefreshing();
            TableView.ReloadData();
        }
Esempio n. 4
0
        public async void UpdateTable()
        {
            RefreshControl.BeginRefreshing();
            feed = await FeedManager.Get();

            feed.Sort((p1, p2) => p2.Created.CompareTo(p1.Created));
            TableView.ReloadData();
            RefreshControl.EndRefreshing();
        }
        private async Task Refresh()
        {
            RefreshControl.BeginRefreshing();
            await Task.Delay(200);

            RefreshControl.EndRefreshing();
            TableView.Source = new ToDoDataSource(this);
            TableView.ReloadData();
        }
 void RefreshStatistics(object sender, EventArgs args)
 {
     RefreshControl.BeginRefreshing();
     FetchMostRecentData((totalJoulesConsumed, error) => {
         InvokeOnMainThread(delegate {
             SimulatedBurntEnergy = new Random().Next(0, 300000);
             ConsumedEnergy       = totalJoulesConsumed;
             NetEnergy            = consumedEnergy - simulatedBurntEnergy;
             RefreshControl.EndRefreshing();
         });
     });
 }
Esempio n. 7
0
        async Task RefreshAcquaintances()
        {
            // ! flag to indicate how this refresh command was instantiated.
            bool triggeredByPullToRefresh = false;

            // Store the original offset of the TableView.
            var originalOffset = new CGPoint(TableView.ContentOffset.X, TableView.ContentOffset.Y);

            // If
            if (RefreshControl.Refreshing)
            {
                triggeredByPullToRefresh = true;
            }

            try
            {
                // If this refresh has not been started by a pull-to-refresh UI action, then we need to manually set the tableview offset to SHOW the refresh indicator.
                if (!triggeredByPullToRefresh)
                {
                    TableView.SetContentOffset(new CGPoint(originalOffset.X, originalOffset.Y - RefreshControl.Frame.Size.Height), true);
                }

                // Starts animating the refreshing indicator, and sets its Refreshing property to true.
                RefreshControl.BeginRefreshing();

                // request the TableViewSource to load acquaintances
                await _AcquaintanceTableViewSource.LoadAcquaintances();

                // Tell the TableView to update its UI (reload the cells) because the TableViewSource has updated.
                TableView.ReloadData();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Error getting acquaintances: {ex.Message}");

                // present an alert about the failure
                using (var alert = new UIAlertView("Error getting acquaintances", "Ensure you have a network connection, and that a valid backend service URL is present in the app settings.", null, "OK"))
                {
                    alert.Show();
                }
            }
            finally
            {
                // Starts animating the refreshing indicator, and sets its Refreshing property to false.
                RefreshControl.EndRefreshing();

                // If this refresh has not been started by a pull-to-refresh UI action, then we need to manually set the tableview offset to HIDE the refresh indicator.
                if (!triggeredByPullToRefresh)
                {
                    TableView.SetContentOffset(originalOffset, true);
                }
            }
        }
Esempio n. 8
0
        async void GetData()
        {
            RefreshControl.BeginRefreshing();
            await FillData();

            TableView.ReloadData();
            TableView.BeginUpdates();
            TableView.EndUpdates();
            if (RefreshControl != null && RefreshControl.Refreshing)
            {
                RefreshControl.EndRefreshing();
            }
        }
        private async Task Refresh()
        {
            if (!RefreshControl.Refreshing)
            {
                RefreshControl.BeginRefreshing();
                TableView.SetContentOffset(new CGPoint(0, TableView.ContentOffset.Y - RefreshControl.Frame.Size.Height), true);
            }

            await MatchesPresenter.InitAsync();

            TableView.ReloadData();

            RefreshControl.EndRefreshing();
        }
Esempio n. 10
0
        async void GetData()
        {
            RefreshControl.BeginRefreshing();
            await MenuHelper.FillData();

            Usuarios = MenuHelper.Comunidad;
            TableView.ReloadData();
            TableView.BeginUpdates();
            TableView.EndUpdates();
            if (RefreshControl != null && RefreshControl.Refreshing)
            {
                RefreshControl.EndRefreshing();
            }
        }
        private async Task Refresh()
        {
            if (_isLoading)
            {
                return;
            }
            _isLoading = true;
            InvokeOnMainThread(() => RefreshControl.BeginRefreshing());
            var item = await Detail.GetDetail(ID, LanguageHelper.PrefLang);

            List = item.List;
            InvokeOnMainThread(() => { CollectionView.ReloadData(); RefreshControl.EndRefreshing(); });
            _isLoading = false;
        }
Esempio n. 12
0
        private async Task Refresh()
        {
            if (_isLoading)
            {
                return;
            }
            _isLoading = true;
            InvokeOnMainThread(() => RefreshControl.BeginRefreshing());
            _page = 0;
            var item = await Home.GetList(_page ++, LanguageHelper.PrefLang);

            List     = item.List.ToList();
            _hasMore = _page < item.MaxPage;
            InvokeOnMainThread(() => { TableView.ReloadData(); RefreshControl.EndRefreshing(); });
            _isLoading = false;
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();


            viewModel = ServiceContainer.Resolve <ExpensesViewModel>();

            viewModel.IsBusyChanged = (busy) =>
            {
                if (busy)
                {
                    RefreshControl.BeginRefreshing();
                }
                else
                {
                    RefreshControl.EndRefreshing();
                }
            };


            this.RefreshControl = new UIRefreshControl();

            RefreshControl.ValueChanged += async(sender, args) =>
            {
                if (viewModel.IsBusy)
                {
                    return;
                }

                await viewModel.ExecuteSyncExpensesCommand();

                TableView.ReloadData();
            };

            TableView.Source = new ExpensesSource(viewModel, this);
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, delegate
            {
                NavigationController.PushViewController(new ExpenseViewController(null), true);
            });

            await Authenticate();

            await viewModel.ExecuteSyncExpensesCommand();

            TableView.ReloadData();
        }
Esempio n. 14
0
        async Task RefreshAsync()
        {
            // only activate the refresh control if the feature is available
            if (useRefreshControl)
            {
                RefreshControl.BeginRefreshing();
            }

            await todoService.RefreshDataAsync();

            if (useRefreshControl)
            {
                RefreshControl.EndRefreshing();
            }

            TableView.ReloadData();
        }
Esempio n. 15
0
        async void GetData()
        {
            RefreshControl.BeginRefreshing();
            ContPag = 0;
            await MenuHelper.GetMuroPosts(ContPag, 5);

            allPosts = MenuHelper.AllPost;
            TableView.ReloadData();
            this.TableView.BeginUpdates();
            this.TableView.EndUpdates();
            await MenuHelper.FillTable();

            if (RefreshControl != null && RefreshControl.Refreshing)
            {
                RefreshControl.EndRefreshing();
            }
        }
Esempio n. 16
0
        private async Task RefreshAsync()
        {
            RefreshControl.BeginRefreshing();
            SavedLocations = new List <SavedLocation>();

            using (var connection = new SQLite.SQLiteConnection(pathToDatabase))
            {
                var query = connection.Table <SavedLocation>();

                foreach (SavedLocation mapItem in query)
                {
                    SavedLocations.Add(mapItem);
                    TableView.ReloadData();
                }
            }
            RefreshControl.EndRefreshing();
            TableView.ReloadData();
        }
        private async Task RefreshAsync()
        {
            // start of RefreshAsync method
            if (todoService.User == null)
            {
                await QSTodoService.DefaultService.Authenticate(this);

                if (todoService.User == null)
                {
                    Console.WriteLine("couldn't login!!");
                    return;
                }
            }
            // rest of RefreshAsync method
            RefreshControl.BeginRefreshing();
            await todoService.RefreshDataAsync();

            RefreshControl.EndRefreshing();

            TableView.ReloadData();
        }
Esempio n. 18
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
            viewModel = ServiceContainer.Resolve <ExpensesViewModel>();

            TableView.Source        = new ExpenseSource(this, viewModel);
            viewModel.IsBusyChanged = (busy) =>
            {
                if (busy)
                {
                    RefreshControl.BeginRefreshing();
                }
                else
                {
                    RefreshControl.EndRefreshing();
                }
            };


            RefreshControl = new UIRefreshControl();
            RefreshControl.ValueChanged += async(sender, args) =>
            {
                if (viewModel.IsBusy)
                {
                    return;
                }

                await viewModel.ExecuteLoadExpensesCommand();

                TableView.ReloadData();
            };

            ButtonAdd.Clicked += (sender, args) =>
            {
                NavigationController.PushViewController(new ExpenseViewController(null), true);
            };
        }
Esempio n. 19
0
 /// <summary>
 /// Sets the boolean state of a device.
 /// </summary>
 /// <param name="device"></param>
 /// <param name="on_off"></param>
 public void SetDevice(Device device, bool on_off)
 {
     foreach (Backend.Models.Activator act in device.Activators)
     {
         if (act.State.Type == "bool")
         {
             try
             {
                 act.State = new ActivatorState(on_off, "bool");
                 RefreshControl.BeginRefreshing();
                 RefreshDeviceList();
                 TableView.ReloadData();
                 RefreshControl.EndRefreshing();
             }
             catch (ServerInteractionException ex)
             {
                 Console.WriteLine("Exception while changing activator state");
                 Console.WriteLine(ex);
             }
             return;
         }
     }
 }
Esempio n. 20
0
 void PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     InvokeOnMainThread(() =>
     {
         switch (e.PropertyName)
         {
         case "IsBusy":
             {
                 if (viewModel.IsBusy)
                 {
                     RefreshControl.BeginRefreshing();
                     activityIndicator.StartAnimating();
                 }
                 else
                 {
                     RefreshControl.EndRefreshing();
                     activityIndicator.StopAnimating();
                 }
             }
             break;
         }
     });
 }
 /// <summary>
 /// Method for Pull to refresh
 /// </summary>
 void RefreshTable(object sender, EventArgs e)
 {
     RefreshControl.BeginRefreshing();
     RefreshServerList();
     RefreshControl.EndRefreshing();
 }