roubachof / Sharpnado.CollectionView

A performant list view supporting: grid, horizontal and vertical layout, drag and drop, and reveal animations.
The Unlicense
244 stars 30 forks source link

Fixes a memory leak in Android's CollectionViewRenderer #111

Closed AdamEssenmacher closed 8 months ago

AdamEssenmacher commented 8 months ago

Fixes #110

We need to be careful using the ViewTreeObserver getter. It can return different instances depending on where the view is in its lifecycle, resulting in events being unsubscribed from instances they were not subscribed to.

This PR converts the event subscription to using an explicit handler, which allows us to subscribe to the event using a weak reference back to the renderer and thus avoiding the memory leak.

roubachof commented 8 months ago

That's some quality PR here, thanks !