airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.51k stars 728 forks source link

Epoxy recyclerview keeps reference of old fragment when recreated #1040

Open semso-bonaparta opened 4 years ago

semso-bonaparta commented 4 years ago

Hi,

I have a epoxy recyclerview within a fragment. When the fragment is setup for the first time everything works as expected. When i pop back from that fragment and show it again at some time later, the click events from the epoxy recyclerview get executed on the previously "destroyed" fragment. When I check the "activity" property inside the click event it is "null", but it surely is not, because when I click on a regular button (outside of the recyclerview) i get the propper reference of the activity. Obviously the recyclerview keeps the reference of the old fragment, and I didnt find a way to get it removed.

Is there a way to completly remove the fragment reference from recyclerview?

Edit: Tried these things but it didnt work: binding.epoxyrecyclerviewChooseicon.recycledViewPool.clear() binding.epoxyrecyclerviewChooseicon.adapter = null binding.epoxyrecyclerviewChooseicon.clear() binding.epoxyrecyclerviewChooseicon.invalidate()

dimsuz commented 4 years ago

Perhaps this is related to #1032

elihart commented 4 years ago

maybe you need to rebuild models, and are not properly clearing models when the fragment view is destroyed?

semso-bonaparta commented 4 years ago

maybe you need to rebuild models, and are not properly clearing models when the fragment view is destroyed?

The fragment is being destroyed and recreated, so the model is being rebuild every time