When I use filtering i.e. the number of items in the RecyclerView changes, I sometimes get the following error:
08-07 19:47:17.648 23025-23025/de.brueckmann.robert.musicmate E/AndroidRuntime: FATAL EXCEPTION: main Process: de.brueckmann.robert.musicmate, PID: 23025 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference at android.support.v7.widget.RecyclerView$LayoutManager.getDecoratedTop(RecyclerView.java:8095) at com.turingtechnologies.materialscrollbar.ScrollingUtilities.getCurScrollState(ScrollingUtilities.java:152) at com.turingtechnologies.materialscrollbar.ScrollingUtilities.scrollHandleAndIndicator(ScrollingUtilities.java:52) at com.turingtechnologies.materialscrollbar.MaterialScrollBar$scrollListener.onScrolled(MaterialScrollBar.java:694) at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4250) at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3348) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3080) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1761) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1191) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) at android.view.Choreographer.doCallbacks(Choreographer.java:590) at android.view.Choreographer.doFrame(Choreographer.java:560) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main
I assume that because of the ongoing layout-run at this point, the item retrieved via getChildAt(0) is null. Maybe you can put in an extra null check to prevent the issue?
When I use filtering i.e. the number of items in the RecyclerView changes, I sometimes get the following error:
08-07 19:47:17.648 23025-23025/de.brueckmann.robert.musicmate E/AndroidRuntime: FATAL EXCEPTION: main Process: de.brueckmann.robert.musicmate, PID: 23025 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference at android.support.v7.widget.RecyclerView$LayoutManager.getDecoratedTop(RecyclerView.java:8095) at com.turingtechnologies.materialscrollbar.ScrollingUtilities.getCurScrollState(ScrollingUtilities.java:152) at com.turingtechnologies.materialscrollbar.ScrollingUtilities.scrollHandleAndIndicator(ScrollingUtilities.java:52) at com.turingtechnologies.materialscrollbar.MaterialScrollBar$scrollListener.onScrolled(MaterialScrollBar.java:694) at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4250) at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3348) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3080) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1761) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1191) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556) at android.widget.LinearLayout.onLayout(LinearLayout.java:1465) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) at android.widget.FrameLayout.onLayout(FrameLayout.java:508) at android.view.View.layout(View.java:16711) at android.view.ViewGroup.layout(ViewGroup.java:5328) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) at android.view.Choreographer.doCallbacks(Choreographer.java:590) at android.view.Choreographer.doFrame(Choreographer.java:560) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main
I assume that because of the ongoing layout-run at this point, the item retrieved via
getChildAt(0)
is null. Maybe you can put in an extra null check to prevent the issue?