diff options
| author | 2020-01-13 18:48:10 +0000 | |
|---|---|---|
| committer | 2020-01-13 18:48:10 +0000 | |
| commit | 615c9ee4d46a208feffb7a74d3011ebc83a49796 (patch) | |
| tree | 1c3d2092225c7f70b1b78f046043244cb407f0a6 | |
| parent | 238c857815c22f53a9dc0ecc039045b4f0137bb9 (diff) | |
| parent | a7cb697874b9afc8c8323d6325df52f24f997e9d (diff) | |
Merge "Don't let RecyclerView consume fling action when there is no further space."
| -rw-r--r-- | core/java/com/android/internal/widget/RecyclerView.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/java/com/android/internal/widget/RecyclerView.java b/core/java/com/android/internal/widget/RecyclerView.java index 43a227a32346..d7a01c4762f1 100644 --- a/core/java/com/android/internal/widget/RecyclerView.java +++ b/core/java/com/android/internal/widget/RecyclerView.java @@ -2011,13 +2011,27 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro } if (!dispatchNestedPreFling(velocityX, velocityY)) { - final boolean canScroll = canScrollHorizontal || canScrollVertical; - dispatchNestedFling(velocityX, velocityY, canScroll); + 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 (velocityY > 0) { + consumed = getChildAdapterPosition(lastChild) < mAdapter.getItemCount() - 1 + || lastChild.getBottom() > getHeight() - getPaddingBottom(); + } + + dispatchNestedFling(velocityX, velocityY, consumed); if (mOnFlingListener != null && mOnFlingListener.onFling(velocityX, velocityY)) { return true; } + final boolean canScroll = canScrollHorizontal || canScrollVertical; + if (canScroll) { velocityX = Math.max(-mMaxFlingVelocity, Math.min(velocityX, mMaxFlingVelocity)); velocityY = Math.max(-mMaxFlingVelocity, Math.min(velocityY, mMaxFlingVelocity)); |