Hi all.
I have item list with "webView" inside. When I scroll list, "webView" over and over again loading content.
How properly disable recycle items ?
Overriding this method in item not work for me:
override fun isRecyclable(): Boolean { return false }
Thanks)
Hmm, this is interesting. Looking at the source code, we never actually call RecyclerView.ViewHolder.setIsRecyclable.
The only place where Item.isRecyclable() is used is in this one place in GroupAdapter:
@Override
public boolean onFailedToRecycleView(@NonNull VH holder) {
Item contentItem = holder.getItem();
return contentItem.isRecyclable();
}
which I don't believe is sufficient. Maybe @lisawray can pitch in here?
@zabochen
You can simply override createViewHolder and call setIsRecyclable with false argument on created ViewHolder:
override fun createViewHolder(itemView: View): ViewHolder {
return super.createViewHolder(itemView).apply {
setIsRecyclable(false)
}
}
@zabochen did @Kamil-H 's solution work for you? I tried @Kamil-H 's solution but the "webView" keeps loading content again and again when I scroll the list.
I needed a fast fix and I didn't check this solution.
I "disable" recyclerView, like this:
<androidx.core.widget.NestedScrollView>
<LinearLayout>
...
<androidx.recyclerview.widget.RecyclerView/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Thanks @zabochen
Feels like you shouldn't be using Groupie for your use-case.
https://github.com/lisawray/groupie/issues/308#issuecomment-575896865 should be correct
override fun createViewHolder(itemView: View): ViewHolder {
return super.createViewHolder(itemView).apply {
setIsRecyclable(false)
}
}
This code is not working for me
Most helpful comment
@zabochen
You can simply override
createViewHolderand callsetIsRecyclablewithfalseargument on createdViewHolder: