airbnb / epoxy

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

feat: Add aggregate visibility state changed callback #1385

Open shinwan2 opened 5 months ago

shinwan2 commented 5 months ago

To fix https://github.com/airbnb/epoxy/issues/1343, I believe a new callback that reports the latest visibility state(s) for that EpoxyVisibilityItem should be introduced. Without this aggregate information, client will need to somehow batch the VisibilityState by themselves for 1 vi.update cycle. To avoid object allocation, instead of using data class AggregateVisibilityState I just expose the properties from EpoxyVisibilityItem as read-only.

Alternatively to fix https://github.com/airbnb/epoxy/issues/1343, we could change the ordering of VisibilityState emission on onVisibilityStateChanged. Please let me know if that's preferred.

Test

I have included comparing the aggregate visibility state in EpoxyVisibilityStateTrackerTest.