Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49bd07d6 authored by George Mount's avatar George Mount
Browse files

Fix NPE in RecyclerView

Bug: 184256183

Prevents NullPointerException when there are no children in the
RecyclerView while a fling occurs.

Test: Ran share sheet
Change-Id: I6aa5a4622c8afa792ca5e3f4c8fffb9ec92128d9
parent 7eb1c4c2
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -2049,9 +2049,10 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
        }
        if (!dispatchNestedPreFling(velocityX, velocityY)) {
            boolean consumed = false;
            if (mLayout.getChildCount() > 0) {
                final View firstChild = mLayout.getChildAt(0);
                final View lastChild = mLayout.getChildAt(mLayout.getChildCount() - 1);
            boolean consumed = false;
                if (velocityY < 0) {
                    consumed = getChildAdapterPosition(firstChild) > 0
                            || firstChild.getTop() < getPaddingTop();
@@ -2061,6 +2062,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
                    consumed = getChildAdapterPosition(lastChild) < mAdapter.getItemCount() - 1
                            || lastChild.getBottom() > getHeight() - getPaddingBottom();
                }
            }
            dispatchNestedFling(velocityX, velocityY, consumed);