From db48fec0ac4d817726ebb23b9745e91da4fed8a0 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Wed, 30 Nov 2016 01:18:26 +0000 Subject: [PATCH] am f586156e: am aa1beef7: am ed048c6c: am 790288a0: Merge "Only start nested scrolling if the view is large enough" into lmp-mr1-ub-dev * commit 'f586156eeb13eb210bb0297aa25e9b9b120f5bc9': Only start nested scrolling if the view is large enough GitOrigin-RevId=d7469f6087c6f180641a3f38d11e521ed9a51b05 PiperOrigin-RevId: 140548673 --- .../support/design/widget/AppBarLayout.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/android/support/design/widget/AppBarLayout.java b/src/android/support/design/widget/AppBarLayout.java index d8c3850e0..3007bf814 100644 --- a/src/android/support/design/widget/AppBarLayout.java +++ b/src/android/support/design/widget/AppBarLayout.java @@ -604,9 +604,11 @@ public class AppBarLayout extends LinearLayout { @Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes) { - // Return true if we're nested scrolling vertically and we have scrollable children + // Return true if we're nested scrolling vertically, and we have scrollable children + // and the scrolling view is big enough to scroll final boolean started = (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0 - && child.hasScrollableChildren(); + && child.hasScrollableChildren() + && coordinatorLayout.getHeight() - target.getHeight() <= child.getHeight(); if (started && mAnimator != null) { // Cancel any offset animation @@ -1005,8 +1007,8 @@ public class AppBarLayout extends LinearLayout { int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { if (child.getLayoutParams().height == LayoutParams.MATCH_PARENT) { - // If the child's height is set to match_parent then it with it's maximum visible - // visible height + // If the child's height is set to match_parent then measure it with it's + // maximum visible visible height final List dependencies = parent.getDependencies(child); if (dependencies.isEmpty()) { @@ -1022,9 +1024,8 @@ public class AppBarLayout extends LinearLayout { ViewCompat.setFitsSystemWindows(child, true); } - final int scrollRange = appBar.getTotalScrollRange(); - final int height = parent.getHeight() - - appBar.getMeasuredHeight() + scrollRange; + final int height = parent.getHeight() - appBar.getMeasuredHeight() + + appBar.getTotalScrollRange(); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); @@ -1059,9 +1060,7 @@ public class AppBarLayout extends LinearLayout { setTopAndBottomOffset(AnimationUtils.lerp(expandedMax, collapsedMin, Math.abs(appBarOffset) / (float) scrollRange)); } else { - setTopAndBottomOffset(MathUtils.constrain( - dependency.getHeight() - mOverlayTop + appBarOffset, - collapsedMin, expandedMax)); + setTopAndBottomOffset(dependency.getHeight() - mOverlayTop + appBarOffset); } } return false;