Closed mdrafiwynk closed 1 month ago
@mdrafiwynk can you please share a sample that reproduces that issue? In the sample app, the views are being recycled correctly
I have checked in profiler. In sample app, there is only one text view in item view but it will take lot of time to inflate. Also showing lot of janks whenever scrolling vertical in nested one
@mdrafiwynk I just checked and found the problem in the sample app. I'm running some animations which are not cancelled in onViewDetachedFromWindow
, which prevents ViewHolders from being recycled since there is transient state: https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onFailedToRecycleView(VH)
Will file a MR that fixes that, but if you're affected by this, it means you're also running animations you're not cancelling.
Will link the fix MR here once it is open
@mdrafiwynk have a look here: https://github.com/rubensousa/DpadRecyclerView/pull/237
Yes i am using nested horizontal RV item animation to scale In current focused item and scale out last focused item. Is I need to cancel it OnViewHolderDetachFromWindow?
Is there any method in you library which called during scroll is idle. Like I am scale in currently focused and scale out last focused on focus listener of itemView. But if I scroll horizontal faster then it will show little scale in and out animation for micro second. I want to scale item only if scroll state is idle. How can i achieve this with your library?
do I need to cancel it OnViewHolderDetachFromWindow?
Yes, you do.
How can i achieve this with your library?
You can observe scroll state of RecyclerView
via https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView#addOnScrollListener(androidx.recyclerview.widget.RecyclerView.OnScrollListener)
or you can use the selection callback that has the aligned event:
recyclerView.addOnViewHolderSelectedListener(object : OnViewHolderSelectedListener {
override fun onViewHolderSelectedAndAligned(
parent: RecyclerView,
child: RecyclerView.ViewHolder?,
position: Int,
subPosition: Int
) {
super.onViewHolderSelectedAndAligned(parent, child, position, subPosition)
// ViewHolder is in its final position
}
})
Thank you soo much.
Closing since the sample now contains examples for canceling the animations
I am working on tv app and using dpad recycler view. But I am getting huge performance issue in nested recycler view when scrolling vertically horizontal recycler view each item is created and its UI is inflated again. I have check in library sample under nested option but facing same lagging and jank while vertical scrolling. Please check and fix it asap.
Feel free to contact any time.