summaryrefslogtreecommitdiff
path: root/core/java/android/widget/ScrollView.java
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2021-04-29 18:19:15 +0000
committerGeorge Mount <mount@google.com>2021-04-29 20:37:56 +0000
commit02843213c076f4ea754dbd9edf459500437adc06 (patch)
tree5224ceda1b5eadc1d0d89b18dcf1615229a87706 /core/java/android/widget/ScrollView.java
parent75fd8835faecae56eb655817f628caa7166c5a1c (diff)
Fling while overscrolled: ScrollView/HorizontalScrollView
Bug: 186430321 ScrollView and HorizontalScrollView was not allowing a fling effect while overscrolling. This adds the ability to fling while overscrolling. Test: new test Test: manual ApiDemos Change-Id: Iebd402ff0f5b6f16518ecc5403e085cb58de5976
Diffstat (limited to 'core/java/android/widget/ScrollView.java')
-rw-r--r--core/java/android/widget/ScrollView.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 2dd7f022ff44..3610eb47edbc 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -49,6 +49,7 @@ import android.view.animation.AnimationUtils;
import android.view.inspector.InspectableProperty;
import com.android.internal.R;
+import com.android.internal.annotations.VisibleForTesting;
import java.util.List;
@@ -95,20 +96,24 @@ public class ScrollView extends FrameLayout {
*
* Even though this field is practically final, we cannot make it final because there are apps
* setting it via reflection and they need to keep working until they target Q.
+ * @hide
*/
@NonNull
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768600)
- private EdgeEffect mEdgeGlowTop;
+ @VisibleForTesting
+ public EdgeEffect mEdgeGlowTop;
/**
* Tracks the state of the bottom edge glow.
*
* Even though this field is practically final, we cannot make it final because there are apps
* setting it via reflection and they need to keep working until they target Q.
+ * @hide
*/
@NonNull
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769386)
- private EdgeEffect mEdgeGlowBottom;
+ @VisibleForTesting
+ public EdgeEffect mEdgeGlowBottom;
/**
* Position of the last motion event.
@@ -1791,9 +1796,15 @@ public class ScrollView extends FrameLayout {
final boolean canFling = (mScrollY > 0 || velocityY > 0) &&
(mScrollY < getScrollRange() || velocityY < 0);
if (!dispatchNestedPreFling(0, velocityY)) {
- dispatchNestedFling(0, velocityY, canFling);
+ final boolean consumed = dispatchNestedFling(0, velocityY, canFling);
if (canFling) {
fling(velocityY);
+ } else if (!consumed) {
+ if (!mEdgeGlowTop.isFinished()) {
+ mEdgeGlowTop.onAbsorb(-velocityY);
+ } else if (!mEdgeGlowBottom.isFinished()) {
+ mEdgeGlowBottom.onAbsorb(velocityY);
+ }
}
}
}