summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-10-25 20:11:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-10-25 20:11:39 +0000
commit2fd941b6d94742ddd93d12438bb4966f12a46fed (patch)
treedb80da3295dd4ab8ff007f245f2c75cb41397bcd
parent0d5f5e2b97758b38ecc573c2aecd13cb31bb6cae (diff)
parentd27a6319f21800cf423e0a7d3d49acc88eaa38ed (diff)
Merge "Prevent touch delegate from blocking parent events"
-rw-r--r--core/java/android/view/TouchDelegate.java46
1 files changed, 20 insertions, 26 deletions
diff --git a/core/java/android/view/TouchDelegate.java b/core/java/android/view/TouchDelegate.java
index cf36f4360c3b..dc50fa1d6036 100644
--- a/core/java/android/view/TouchDelegate.java
+++ b/core/java/android/view/TouchDelegate.java
@@ -44,7 +44,7 @@ public class TouchDelegate {
/**
* mBounds inflated to include some slop. This rect is to track whether the motion events
- * should be considered to be be within the delegate view.
+ * should be considered to be within the delegate view.
*/
private Rect mSlopBounds;
@@ -64,14 +64,12 @@ public class TouchDelegate {
public static final int BELOW = 2;
/**
- * The touchable region of the View extends to the left of its
- * actual extent.
+ * The touchable region of the View extends to the left of its actual extent.
*/
public static final int TO_LEFT = 4;
/**
- * The touchable region of the View extends to the right of its
- * actual extent.
+ * The touchable region of the View extends to the right of its actual extent.
*/
public static final int TO_RIGHT = 8;
@@ -108,28 +106,24 @@ public class TouchDelegate {
boolean handled = false;
switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- Rect bounds = mBounds;
-
- if (bounds.contains(x, y)) {
- mDelegateTargeted = true;
- sendToDelegate = true;
- }
- break;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_MOVE:
- sendToDelegate = mDelegateTargeted;
- if (sendToDelegate) {
- Rect slopBounds = mSlopBounds;
- if (!slopBounds.contains(x, y)) {
- hit = false;
+ case MotionEvent.ACTION_DOWN:
+ mDelegateTargeted = mBounds.contains(x, y);
+ sendToDelegate = mDelegateTargeted;
+ break;
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_MOVE:
+ sendToDelegate = mDelegateTargeted;
+ if (sendToDelegate) {
+ Rect slopBounds = mSlopBounds;
+ if (!slopBounds.contains(x, y)) {
+ hit = false;
+ }
}
- }
- break;
- case MotionEvent.ACTION_CANCEL:
- sendToDelegate = mDelegateTargeted;
- mDelegateTargeted = false;
- break;
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ sendToDelegate = mDelegateTargeted;
+ mDelegateTargeted = false;
+ break;
}
if (sendToDelegate) {
final View delegateView = mDelegateView;