File tree Expand file tree Collapse file tree
src/Controls/src/Core/Compatibility/Handlers/ListView/Android Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#nullable disable
22using System ;
33using System . ComponentModel ;
4+ using System . Threading . Tasks ;
45using Android . Content ;
56using Android . Runtime ;
67using Android . Views ;
@@ -476,19 +477,17 @@ void UpdateIsRefreshing(bool isInitialValue = false)
476477 }
477478 }
478479
479- void UpdateIsSwipeToRefreshEnabled ( )
480+ async void UpdateIsSwipeToRefreshEnabled ( )
480481 {
481482 if ( _refresh != null )
482483 {
483484 var isEnabled = Element . IsPullToRefreshEnabled && ( Element as IListViewController ) . RefreshAllowed ;
484- _refresh . Post ( ( ) =>
485- {
486- // NOTE: only disable while NOT refreshing, otherwise Command bindings CanExecute behavior will effectively
487- // cancel refresh animation. If not possible right now we will be called by UpdateIsRefreshing().
488- // For details see https://github.com/xamarin/Xamarin.Forms/issues/8384
489- if ( isEnabled || ! _refresh . Refreshing )
490- _refresh . Enabled = isEnabled ;
491- } ) ;
485+ await Task . Yield ( ) ;
486+ // NOTE: only disable while NOT refreshing, otherwise Command bindings CanExecute behavior will effectively
487+ // cancel refresh animation. If not possible right now we will be called by UpdateIsRefreshing().
488+ // For details see https://github.com/xamarin/Xamarin.Forms/issues/8384
489+ if ( isEnabled || ! _refresh . Refreshing )
490+ _refresh . Enabled = isEnabled ;
492491 }
493492 }
494493
You can’t perform that action at this time.
0 commit comments