reddit / IndicatorFastScroll

Android library providing a simple UI control for scrolling through RecyclerViews
MIT License
707 stars 58 forks source link

Indicators are not updated upon 'swapAdapter' #17

Closed gustavaa closed 5 years ago

gustavaa commented 5 years ago

Hello and thank you for this great library!

I have a project that uses a SortedList for handling sorting and filtering logic in my RecyclerView using different comparators to enable different sorting modes. This works great apart from the fact that a SortedList cannot be resorted, so when the user changes the sorting mode I create a new Adapter and calls swapAdapter() which efficiently changes the adapter of the RecyclerView and does not clear the RecycledViewPool.

Calls to setAdapter() or swapAdapter() is currently not supported by this library and does not update the fast scroll-indicators. Since it is currently also not possible to "re-setup" an IndicatorFastScrollView, it would be great if you could create a public method which refreshes the reference to the adapter and updates the item indicators.

Thanks!

DSteve595 commented 5 years ago

Definitely an issue, the view wasn't built to support switching adapters. It shouldn't be too much work to hook that up. I'll take a look. Thanks for the report!

DSteve595 commented 5 years ago

@gustavaa Try version 1.2.0-beta01 and let me know how it goes!

gustavaa commented 5 years ago

@DSteve595 After some testing it seems to work perfectly. Thanks a lot for fixing this!