timusus / RecyclerView-FastScroll

A simple FastScroller for Android's RecyclerView
Other
1.39k stars 183 forks source link

NullPointerException if adapter not set #26

Closed cybergen78 closed 8 years ago

cybergen78 commented 8 years ago

If the adapter of the recycler view is not (yet) set, the recycler view crashes with a NullPointerException on the first frame to draw (calling getItemCount() on the null adapter).

This is counter intuitive and annoying especially when working with loaders or even cursor loaders. You have to write the adapter null safe and instantiate and set an empty adapter with a null cursor every time the loader is reset. This is an ugly workaround.