This NPE might happen after dataset change when use dynamic item type with inner RecyclerView.
scrollVerticallyBy might run many times during the layout. In middle state of them, there might be only 1 item with type TYPE_HEADER that exist in child views, and thus getTopmostChildView/getBottommostChildView will return Null.
And then the getDecoratedTop/getDecoratedBottom will trigger the NPE.
Fixed by: simply add Null check and return 0. In the later layout pass, child view will be added and scrollVerticallyBy will work normally.
Fixed NPE in
scrollVerticallyBy
.This NPE might happen after dataset change when use dynamic item type with inner RecyclerView.
scrollVerticallyBy
might run many times during the layout. In middle state of them, there might be only 1 item with type TYPE_HEADER that exist in child views, and thusgetTopmostChildView
/getBottommostChildView
will return Null. And then thegetDecoratedTop
/getDecoratedBottom
will trigger the NPE.Fixed by: simply add Null check and return 0. In the later layout pass, child view will be added and
scrollVerticallyBy
will work normally.