Skip to content

Commit

Permalink
Cancel animations in onViewDetachedFromWindow since they prevent View…
Browse files Browse the repository at this point in the history
…Holders from being recycled
  • Loading branch information
rubensousa committed Jul 10, 2024
1 parent 7243741 commit 3610006
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class NestedComposeListAdapter(
holder.item?.let {
scrollState.save(holder.getRecyclerView(), it.diffId)
}
}

override fun onViewDetachedFromWindow(holder: NestedComposeListViewHolder) {
super.onViewDetachedFromWindow(holder)
holder.cancelAnimations()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ class HorizontalListAdapter(
holder.recycle()
}

override fun onViewDetachedFromWindow(holder: HorizontalListViewHolder) {
holder.cancelAnimations()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class HorizontalListViewHolder(
animator.startDeselectionAnimation()
}

fun cancelAnimations() {
animator.cancel()
}

override fun getSubPositionAlignments(): List<SubPositionAlignment> {
return alignments
}
Expand Down

0 comments on commit 3610006

Please sign in to comment.