/// <summary> /// Method for Pull to refresh /// </summary> void RefreshTable(object sender, EventArgs e) { RefreshControl.BeginRefreshing(); RefreshDeviceList(); TableView.ReloadData(); RefreshControl.EndRefreshing(); }
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(); } } }
void updateMusicAssets() { Log.Debug("Load Content"); if (allAssets?.Count == 0 && ContentClient.Shared.AvContent.Count > 0) { allAssets = ContentClient.Shared.AvContent [UserRoles.General].Where(m => m.HasId && m.HasRemoteAssetUri) .Select(s => AssetPersistenceManager.Shared.GetMusicAsset(s)) .ToList(); } else { var newAssets = ContentClient.Shared.AvContent [UserRoles.General].Where(m => m.HasId && m.HasRemoteAssetUri && !allAssets.Any(ma => ma.Id == m.Id)) .Select(s => AssetPersistenceManager.Shared.GetMusicAsset(s)); allAssets.AddRange(newAssets); allAssets.RemoveAll(ma => !ContentClient.Shared.AvContent [UserRoles.General].Any(a => a.Id == ma.Id)); } allAssets?.Sort((x, y) => y.Music.Timestamp.CompareTo(x.Music.Timestamp)); BeginInvokeOnMainThread(() => { TableView.ReloadData(); if (RefreshControl?.Refreshing ?? false) { RefreshControl.EndRefreshing(); } }); }
public void RefreshTable(UIAlertView loading = null) { if (NetworkAvailable()) { _parser.UpdatePublications(publications => InvokeOnMainThread(() => { TableView.Source = new PublicationsViewSource(publications, NavigationController); TableView.ReloadData(); if (loading != null) { loading.DismissWithClickedButtonIndex(0, true); } }), state => InvokeOnMainThread(() => { var alert = new UIAlertView("Error".t(), "ErrorMessage".t(), null, "Ok", null); //alert.Clicked += (sender, e) => UIApplication.SharedApplication.PerformSelector(new Selector("terminateWithSuccess"), null, 0f); alert.Show(); })); } else { var publications = _parser.Publications; TableView.Source = new PublicationsViewSource(publications, NavigationController); TableView.ReloadData(); if (loading != null) { loading.DismissWithClickedButtonIndex(0, true); } } RefreshControl.EndRefreshing(); }
private async Task RefreshAsync() { RefreshControl.BeginRefreshing(); await _service.RefreshDataAsync(); RefreshControl.EndRefreshing(); TableView.ReloadData(); }
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(); }
protected virtual void LoadViewModel() { var iLoadableViewModel = ViewModel as ILoadableViewModel; if (iLoadableViewModel == null) { return; } var refreshControl = new UIRefreshControl(); OnActivation(d => { d(refreshControl.GetChangedObservable().Subscribe(_ => { if (iLoadableViewModel.LoadCommand.CanExecute(null)) { iLoadableViewModel.LoadCommand.ExecuteAsync() .Subscribe(__ => refreshControl.EndRefreshing()); } })); d(iLoadableViewModel.LoadCommand.IsExecuting .Where(x => x && !refreshControl.Refreshing).Subscribe(_ => { nint rows = 0; if (TableView.Source != null) { for (var i = 0; i < TableView.Source.NumberOfSections(TableView); i++) { rows += TableView.Source.RowsInSection(TableView, i); } } if (rows == 0) { _loadingActivityView.Value.StartAnimating(); TableView.TableFooterView = _loadingActivityView.Value; RefreshControl.Do(x => x.EndRefreshing()); RefreshControl = null; } })); d(iLoadableViewModel.LoadCommand.IsExecuting .Where(x => !x).Subscribe(_ => { _loadingActivityView.Value.StopAnimating(); if (TableView.TableFooterView != null) { TableView.TableFooterView = null; TableView.ReloadData(); } if (RefreshControl == null) { RefreshControl = refreshControl; } })); }); }
async void RefreshControl_ValueChanged(object sender, EventArgs e) { if (await Refresh()) { RefreshControl.AttributedTitle = new NSAttributedString(String.Format("Last Updated" + ":{0:g}", DateTime.Now)); } RefreshControl.EndRefreshing(); TableView.ReloadData(); }
async void RefreshControl_ValueChanged() { await ViewModel.ExecuteLoadPastTripsCommandAsync(); InvokeOnMainThread(delegate { TableView.ReloadData(); RefreshControl.EndRefreshing(); }); }
/// <summary> /// Invoke this method to signal that a reload has completed, this will update the UI accordingly. /// </summary> public void ReloadComplete() { if (!reloading) { return; } reloading = false; RefreshControl.EndRefreshing(); }
private void OnKeyDownHandler(object sender, KeyRoutedEventArgs e) { try { if (e.Key == Windows.System.VirtualKey.F5) { RefreshControl.RequestRefresh(); } } catch { } }
void handleAvContentChanged(object sender, UserRoles e) { BeginInvokeOnMainThread(() => { TableView.ReloadData(); if (RefreshControl?.Refreshing ?? false) { RefreshControl.EndRefreshing(); } }); }
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); } } }
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(); }); }); }
void FetchPosts() { new FeedManager().loadFeeds((_, posts) => { this.posts = posts as Post[]; TableView.ReloadData(); RefreshControl.EndRefreshing(); }, (response, data) => { RefreshControl.EndRefreshing(); System.Console.WriteLine("failed to load posts, show some error message"); }); }
public override void ViewDidLoad( ) { base.ViewDidLoad( ); TableView.Source = new DynamicSource( ); RefreshControl.ValueChanged += async(sender, e) => { await Task.Delay(1000); RefreshControl.EndRefreshing( ); }; }
/// <summary> /// Invoke this method to signal that a reload has completed, this will update the UI accordingly. /// </summary> public void ReloadComplete() { if (!reloading) { return; } reloading = false; #if !__TVOS__ RefreshControl.EndRefreshing(); #endif }
async void GetData() { RefreshControl.BeginRefreshing(); await FillData(); TableView.ReloadData(); TableView.BeginUpdates(); TableView.EndUpdates(); if (RefreshControl != null && RefreshControl.Refreshing) { RefreshControl.EndRefreshing(); } }
async void HandleValueChanged(object sender, EventArgs e) { var handle = Insights.TrackTime("TimeLoadMovieList"); handle.Start(); dataSource.movies.Add(await PotatoesManager.Instance.GetMoviesOpening()); dataSource.movies.Add(await PotatoesManager.Instance.GetMoviesBoxOffice()); dataSource.movies.Add(await PotatoesManager.Instance.GetMoviesTheater()); handle.Stop(); TableView.ReloadData(); RefreshControl.EndRefreshing(); }
public override async void ViewDidLoad() { base.ViewDidLoad(); ViewModel = new PastTripsViewModel(); await ViewModel.ExecuteLoadPastTripsCommandAsync(); TableView.ReloadData(); TableView.TableFooterView = new UIView(new CGRect(0, 0, 0, 0)); RefreshControl.AddTarget(this, new Selector("RefreshSource"), UIControlEvent.ValueChanged); NSNotificationCenter.DefaultCenter.AddObserver(new NSString("RefreshPastTripsTable"), HandleReloadTableNotification); }
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; }
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 (!RefreshControl.Refreshing) { RefreshControl.BeginRefreshing(); TableView.SetContentOffset(new CGPoint(0, TableView.ContentOffset.Y - RefreshControl.Frame.Size.Height), true); } await MatchesPresenter.InitAsync(); TableView.ReloadData(); RefreshControl.EndRefreshing(); }
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 override void ViewDidLoad() { base.ViewDidLoad(); this.TableView.Source = new MyDataSource(this); if (!isIos6) { return; } this.RefreshControl = new UIRefreshControl(); RefreshControl.AttributedTitle = new NSAttributedString("Pull down to refresh..."); RefreshControl.ValueChanged += delegate { reloadData(); RefreshControl.AttributedTitle = new NSAttributedString(String.Format("Last Updated: {0:g}", DateTime.Now)); RefreshControl.EndRefreshing(); }; }
void ShowLoading(bool ShowLoader) { if (ShowLoader) { UIView.Animate(0.4, 0, UIViewAnimationOptions.CurveEaseIn, delegate { LoadingText.Alpha = 0; LoadingErrorImg.Alpha = 0; }, delegate { LoadingSpinner.StartAnimating(); }); } else { UIView.Animate(0.4, 0, UIViewAnimationOptions.CurveEaseOut, delegate { LoadingText.Alpha = 0; LoadingErrorImg.Alpha = 0; }, delegate { LoadingSpinner.StopAnimating(); RefreshControl.EndRefreshing(); }); } }
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(); }
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(); }
partial void profileButtonClicked(NSObject sender) { if (ProducerClient.Shared.User == null) { var loginNc = Storyboard.Instantiate <LoginNc> (); PresentViewController(loginNc, true, null); } else { var userNc = Storyboard.Instantiate <UserNc> (); PresentViewController(userNc, true, null); } Log.Debug(RefreshControl?.ToString()); }