turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
778 stars 126 forks source link

Improvement - handle empty RecyclerView Adapter #81

Closed MFlisar closed 7 years ago

MFlisar commented 7 years ago

If the adapter is not set, the ScrollingUtilities will crash...

I would suggest adding following before this line https://github.com/turing-tech/MaterialScrollBar/blob/master/lib/src/main/java/com/turingtechnologies/materialscrollbar/ScrollingUtilities.java#L146

if  (materialScrollBar.recyclerView.getAdapter() == null) {
    return;
}

In some cases, the adapter may be set lazily... Problem can be solved by setting an empty adapter, but handling this case automatically is probably the better thing to do

turing-tech commented 7 years ago

I'll check into that later today. Looks good though.