NobsterTheLobster / Xamarin.Forms.GridView

GridView for xamarin forms
MIT License
60 stars 10 forks source link

[Android]: IsPullToRefreshEnabled not observed #23

Closed deakjahn closed 6 years ago

deakjahn commented 6 years ago

Pull-to-refresh is always active because, although the value of IsPullToRefreshEnabled is passed to _pullToRefresh.Enabled, it's never actually checked later (neither by the gridview nor by SwipeRefreshLayout, apparently). A fix:

private void _pullToRefresh_Refresh(object sender, EventArgs e) {
  if (_pullToRefresh.Enabled) {
    if (Element.RefreshCommand != null) {
      Element.IsRefreshing = true;
      Element.RefreshCommand.Execute(null);
    }
    else
      _pullToRefresh.Refreshing = false;
  }
  else
    _pullToRefresh.Refreshing = false;
}
NobsterTheLobster commented 6 years ago

Is this property change handler not effective?

protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "ItemsSource") { _adapter.Items = Element.ItemsSource; } //If the element IsRefreshing property is changing. else if (e.PropertyName == "IsRefreshing") { //Indicate whether the control is refreshing. _pullToRefresh.Refreshing = Element.IsRefreshing; } //If the element PullToRefresh property is changing. else if (e.PropertyName == "IsPullToRefreshEnabled") { //Indicate whether pull to refresh is enabled. _pullToRefresh.Enabled = Element.IsPullToRefreshEnabled; } }

deakjahn commented 6 years ago

No, it isn't. The refreshing icon will appear, anyway. Even the workaround isn't perfect, it doesn't disable the animation, just exits it immediately.

My suspicion is the you simply can't solve this with a SwipeRefreshLayout. Once you decide to use that, there will be visible reaction to the swiping gesture, no matter what.

NobsterTheLobster commented 6 years ago

New version