Skip to content

Commit

Permalink
Merge pull request #8260 from unoplatform/dev/dr/andReorderFlicker
Browse files Browse the repository at this point in the history
fix(listview): Fix flickering when reordering items on Android
  • Loading branch information
dr1rrb authored Mar 7, 2022
2 parents f3de2ff + 4614b38 commit 9481a9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Uno.UI/FeatureConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ public static class NativeListViewBase
/// from crashing when pressured: Tmp detached view should be removed from RecyclerView before it can be recycled
/// </summary>
public static bool RemoveItemAnimator = true;

/// <summary>
/// Indicates if a full recycling pass should be achieved on drop (re-order) on a ListView instead of a simple layout pass.
/// </summary>
/// <remarks>
/// This flag should be kept to 'false' if you turned <see cref="RemoveItemAnimator"/> to 'false'.
/// Forcing a recycling pass with ItemAnimator is known to cause a flicker of the whole list.
/// </remarks>
public static bool ForceRecycleOnDrop = false;
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2240,9 +2240,18 @@ internal void CleanupReordering()
_pendingReorder = null;

ViewCache.RemoveReorderingItem();
// We need a full refresh to properly re-arrange all items at their right location,
// ignoring the temp location of the dragged / reordered item.
RecycleLayout();

if (FeatureConfiguration.NativeListViewBase.ForceRecycleOnDrop)
{
// We need a full refresh to properly re-arrange all items at their right location,
// ignoring the temp location of the dragged / reordered item.
// Since https://github.com/unoplatform/uno/pull/8227 a full recycle pass seems to be no longer required.
RecycleLayout();
}
else
{
RequestLayout();
}
}

protected bool ShouldInsertReorderingView(GeneratorDirection direction, double physicalExtentOffset)
Expand Down

0 comments on commit 9481a9b

Please sign in to comment.