airbnb / epoxy

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

Trigger visibility track in onResume for CarouselModel_ #1379

Open vibindas-m opened 2 months ago

vibindas-m commented 2 months ago

I want to re-trigger the onVisibilityStateChanged using CarouselModel_ in EpoxyRecyclerView when the fragment resumes.

ClearVisibilityStates and requestVisibilityCheck are helping to re triggering the onVisibilityStateChanged event for all components except the items inside CarouselModel_

val customModels = ArrayList<EpoxyModel<*>>() customModels.add( CustomEproxyModel_() .id(viewId) .onVisibilityStateChanged { _, _, visibilityState -> if(visibilityState == VisibilityState.VISIBLE) { Log.d("Eproxy", "CustomEproxyModel_ visible") } } ) CarouselModel_() .id(viewId) .spanSizeOverride { totalSpanCount, _, _ -> totalSpanCount }.models(customModels)

detach and attach visibilityTracker is not working for me.

`override fun onPause() { // Detach the visibility tracker from the RecyclerView visibilityTracker.detach(epoxyRecyclerView) super.onPause() }

override fun onResume() { // Attach the visibility tracker to the RecyclerView visibilityTracker.attach(epoxyRecyclerView) super.onResume() } `