Skip to content

Commit b294779

Browse files
Tentative fix for Android
Context: #18757
1 parent bd19000 commit b294779

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#nullable disable
22
using System;
33
using System.ComponentModel;
4+
using System.Threading.Tasks;
45
using Android.Content;
56
using Android.Runtime;
67
using 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

0 commit comments

Comments
 (0)