summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewParent.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2014-07-16 21:41:31 -0700
committerAdam Powell <adamp@google.com>2014-07-17 11:37:59 -0700
commitb72be59a6a5ca5fae3ede2470f1662598098b666 (patch)
tree10518b18a8a9459bad2a1f9917b7aa1c86509e3e /core/java/android/view/ViewParent.java
parent9142a0f80cff7572a8249680eaa5db35cb193e34 (diff)
Add nested pre-fling for nested scrolling
Nested pre-fling allows a nested scrolling parent to consume a fling operation before the child view does. If a parent has been consuming nested pre-scroll events in a particular direction, this is generally a good indication that it should also consume the resulting fling at the end. Bug 15538504 Change-Id: I88e8753a96c9b41815c3be530cafab8345164e64
Diffstat (limited to 'core/java/android/view/ViewParent.java')
-rw-r--r--core/java/android/view/ViewParent.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java
index 588b9cd7ce8f..87a37f4739be 100644
--- a/core/java/android/view/ViewParent.java
+++ b/core/java/android/view/ViewParent.java
@@ -523,10 +523,32 @@ public interface ViewParent {
* parent instead. The parent may optionally consume the fling or observe a child fling.</p>
*
* @param target View that initiated the nested scroll
- * @param velocityX Horizontal velocity in pixels per second.
+ * @param velocityX Horizontal velocity in pixels per second
* @param velocityY Vertical velocity in pixels per second
* @param consumed true if the child consumed the fling, false otherwise
* @return true if this parent consumed or otherwise reacted to the fling
*/
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed);
+
+ /**
+ * React to a nested fling before the target view consumes it.
+ *
+ * <p>This method siginfies that a nested scrolling child has detected a fling with the given
+ * velocity along each axis. Generally this means that a touch scroll has ended with a
+ * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds
+ * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity}
+ * along a scrollable axis.</p>
+ *
+ * <p>If a nested scrolling parent is consuming motion as part of a
+ * {@link #onNestedPreScroll(View, int, int, int[]) pre-scroll}, it may be appropriate for
+ * it to also consume the pre-fling to complete that same motion. By returning
+ * <code>true</code> from this method, the parent indicates that the child should not
+ * fling its own internal content as well.</p>
+ *
+ * @param target View that initiated the nested scroll
+ * @param velocityX Horizontal velocity in pixels per second
+ * @param velocityY Vertical velocity in pixels per second
+ * @return true if this parent consumed the fling ahead of the target view
+ */
+ public boolean onNestedPreFling(View target, float velocityX, float velocityY);
}