Mark view when swipe starts so ItemAnimator doesn't interfere

This commit is contained in:
cketti 2022-11-14 13:28:31 +01:00
parent 23b68555fb
commit 30a2126fcb

View file

@ -69,6 +69,9 @@ class MessageListSwipeCallback(
}
override fun onSwipeStarted(viewHolder: ViewHolder, direction: Int) {
// Mark view to prevent MessageListItemAnimator from interfering with swipe animations
viewHolder.markAsSwiped(true)
val swipeAction = when (direction) {
ItemTouchHelper.RIGHT -> swipeRightAction
ItemTouchHelper.LEFT -> swipeLeftAction
@ -91,9 +94,6 @@ class MessageListSwipeCallback(
override fun onSwiped(viewHolder: ViewHolder, direction: Int) {
val item = viewHolder.messageListItem
// Mark view to prevent MessageListItemAnimator from interfering with swipe animations
viewHolder.markAsSwiped(true)
when (direction) {
ItemTouchHelper.RIGHT -> listener.onSwipeAction(item, swipeRightAction)
ItemTouchHelper.LEFT -> listener.onSwipeAction(item, swipeLeftAction)