Merge "Fix NPE in RecyclerView" into sc-dev am: e57091c6c3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14069295

Change-Id: I3ad45c9c3e8807bdf87d44f1ccd44ad129a109a0
This commit is contained in:
George Mount
2021-04-02 16:28:48 +00:00
committed by Automerger Merge Worker

View File

@@ -2049,17 +2049,19 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
}
if (!dispatchNestedPreFling(velocityX, velocityY)) {
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();
}
if (mLayout.getChildCount() > 0) {
final View firstChild = mLayout.getChildAt(0);
final View lastChild = mLayout.getChildAt(mLayout.getChildCount() - 1);
if (velocityY < 0) {
consumed = getChildAdapterPosition(firstChild) > 0
|| firstChild.getTop() < getPaddingTop();
}
if (velocityY > 0) {
consumed = getChildAdapterPosition(lastChild) < mAdapter.getItemCount() - 1
|| lastChild.getBottom() > getHeight() - getPaddingBottom();
if (velocityY > 0) {
consumed = getChildAdapterPosition(lastChild) < mAdapter.getItemCount() - 1
|| lastChild.getBottom() > getHeight() - getPaddingBottom();
}
}
dispatchNestedFling(velocityX, velocityY, consumed);