Fix intercept touch handling in SwipeDismissBehavior

Currently ACTION_UP|DOWN are never sent to the
ViewDragHelper.

BUG: 30148711
Change-Id: Idd3aeb3d4d64da5895655599a54d27762e907c21
diff --git a/design/src/android/support/design/widget/SwipeDismissBehavior.java b/design/src/android/support/design/widget/SwipeDismissBehavior.java
index bfc98ea..ae1ef86 100644
--- a/design/src/android/support/design/widget/SwipeDismissBehavior.java
+++ b/design/src/android/support/design/widget/SwipeDismissBehavior.java
@@ -80,7 +80,7 @@
 
     private ViewDragHelper mViewDragHelper;
     private OnDismissListener mListener;
-    private boolean mIgnoreEvents;
+    private boolean mInterceptingEvents;
 
     private float mSensitivity = 0f;
     private boolean mSensitivitySet;
@@ -168,27 +168,26 @@
 
     @Override
     public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
+        boolean dispatchEventToHelper = mInterceptingEvents;
+
         switch (MotionEventCompat.getActionMasked(event)) {
+            case MotionEvent.ACTION_DOWN:
+                mInterceptingEvents = parent.isPointInChildBounds(child,
+                        (int) event.getX(), (int) event.getY());
+                dispatchEventToHelper = mInterceptingEvents;
+                break;
             case MotionEvent.ACTION_UP:
             case MotionEvent.ACTION_CANCEL:
-                // Reset the ignore flag
-                if (mIgnoreEvents) {
-                    mIgnoreEvents = false;
-                    return false;
-                }
-                break;
-            default:
-                mIgnoreEvents = !parent.isPointInChildBounds(child,
-                        (int) event.getX(), (int) event.getY());
+                // Reset the ignore flag for next time
+                mInterceptingEvents = false;
                 break;
         }
 
-        if (mIgnoreEvents) {
-            return false;
+        if (dispatchEventToHelper) {
+            ensureViewDragHelper(parent);
+            return mViewDragHelper.shouldInterceptTouchEvent(event);
         }
-
-        ensureViewDragHelper(parent);
-        return mViewDragHelper.shouldInterceptTouchEvent(event);
+        return false;
     }
 
     @Override