Open smelfungus opened 2 years ago
The "Reused" hook itself is working right, and the item is correct, too. However, reused hook contains a reference to old, no-longer-valid Fragment, old Fragment contains a reference to old, no-longer-valid stateful ViewModel, and so on... Maybe there's a way to implement an optional FastAdapter mode to bind hooks with ViewHolder bind event instead of a creation-based "hooking"? Probably it may impact performance tho.
Given this usecase? Would a "quick" fix be to offer an API to remove previously registered event hooks?
EventHook
s are kept within the FastAdapter
instance, so it sounds you re-use the FastAdapter
class over multiple Fragments
?
Or actually more indirectly via the adapter
being kept inside the item view's tag: https://github.com/mikepenz/FastAdapter/blob/70b1380b6e888b9fbfb6bb4357295892ffb1d8a5/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/EventHookUtil.kt#L40-L41
So practically you need to clear tags from itemView
when such caching is setup. Do you have any way to clear the tags of a view when re-used from the RecycledViewPool
?
@mikepenz, thank you for getting back to me! Yes, so FastAdapter
s are not reused, but item views are reused via RecycledViewPool
, which indirectly causes View
s to keep hooks and attach them only once (from the very first fragment) via tags during initial VH creation.
Potentially we can clear tags during the bind, but then we should somehow re-attach new event hooks after it...
Maybe that's just a unique usecase that should not have FastAdapter
support, and we should just pass new listeners to items and set them in a bind each time, but I'm just wondering what are your thoughts on some sort of a bind-based hooks attachment or API?
About this issue
Hello! I've recently started to combine a series of consecutive Fragment RecyclerViews with
RecycledViewPool
to bump performance up viaView
pooling. However, it seems like that does not work too well with the FastAdapter EventHook mechanism (onPostCreateViewHolder
is no longer called for "pooled" Views from following Fragments, old, no-longer-valid hooks are being reused (because of tag-based attachment?)) Any ideas on how to properly manage that case?Best regards, Illia
Details
5.6.0