Example usage for android.view ViewParent requestDisallowInterceptTouchEvent

List of usage examples for android.view ViewParent requestDisallowInterceptTouchEvent

Introduction

In this page you can find the example usage for android.view ViewParent requestDisallowInterceptTouchEvent.

Prototype

public void requestDisallowInterceptTouchEvent(boolean disallowIntercept);

Source Link

Document

Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup#onInterceptTouchEvent(MotionEvent) .

Usage

From source file:com.huyn.demogroup.zoomageview.view.PhotoViewAttacher.java

@Override
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable(v)) {
        mDragToFinish = false;/*  www .  java 2 s  . co  m*/
        switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            ViewParent parent = v.getParent();
            // First, disable the Parent from intercepting the touch
            // event
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }

            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (rect != null) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            break;
        }

        // Try the Scale/Drag detector
        if (mScaleDragDetector != null) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();

            handled = mScaleDragDetector.onTouchEvent(ev);

            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

            mBlockParentIntercept = didntScale && didntDrag;
        }

        // Check to see if the user double tapped
        if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }

    }

    return handled;
}

From source file:com.appunite.scroll.ScaleImageView.java

@SuppressWarnings("UnusedDeclaration")
public ScaleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMinEdge = viewConfiguration.getScaledEdgeSlop();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScaleImageView, defStyle, defStyle);
    assert a != null;

    Drawable src = null;/*  w  w  w .j ava  2  s. c o  m*/
    try {
        mMinWidth = a.getDimensionPixelSize(R.styleable.ScaleImageView_android_minWidth, 0);
        mMinHeight = a.getDimensionPixelSize(R.styleable.ScaleImageView_android_minHeight, 0);
        src = a.getDrawable(R.styleable.ScaleImageView_android_src);
    } finally {
        a.recycle();
    }

    ScaleGestureDetector.OnScaleGestureListener scaleGestureListener = new ScaleGestureDetector.SimpleOnScaleGestureListener() {
        /**
         * This is the active focal point in terms of the viewport. Could be a local
         * variable but kept here to minimize per-frame allocations.
         */
        private PointF viewportFocus = new PointF();

        @Override
        public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
            final ViewParent parent = getParent();
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
            return true;
        }

        @Override
        public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
            float focusX = scaleGestureDetector.getFocusX();
            float focusY = scaleGestureDetector.getFocusY();
            float scaleFactor = scaleGestureDetector.getScaleFactor();
            float previousScale = mScale;
            mScale *= scaleFactor;

            doScale(focusX, focusY, scaleFactor);
            return true;
        }

    };
    GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {

            releaseEdgeEffects();
            mScroller.forceFinished(true);
            ViewCompat.postInvalidateOnAnimation(ScaleImageView.this);
            return true;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return performClick();
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            mZoomer.forceFinished(true);
            mZoomStartScale = mScale;
            mZoomFocalPoint.set(e.getX(), e.getY());
            mZoomer.startZoom(ZOOM_AMOUNT);
            ViewCompat.postInvalidateOnAnimation(ScaleImageView.this);
            return true;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            getRealTranslation(mTranslation, mRealTranslation);
            mRealTranslation.offset(-distanceX, -distanceY);
            getTranslation(mRealTranslation, mTranslation);

            computeMaxScrollSize(mMaxScrollBuffer);
            getImageRect(mRectF);
            float scrolledX = -mRectF.left;
            float scrolledY = -mRectF.top;
            boolean canScrollX = mRectF.left > mContentRect.left || mRectF.right < mContentRect.right;
            boolean canScrollY = mRectF.top > mContentRect.top || mRectF.bottom < mContentRect.bottom;
            validateTranslation();

            disallowParentInterceptWhenOnEdge(distanceX, distanceY);

            if (mScale > mMinScale) {
                if (canScrollX && scrolledX < 0) {
                    mEdgeEffectLeft.onPull(scrolledX / (float) mContentRect.width());
                    mEdgeEffectLeftActive = true;
                }
                if (canScrollY && scrolledY < 0) {
                    mEdgeEffectTop.onPull(scrolledY / (float) mContentRect.height());
                    mEdgeEffectTopActive = true;
                }
                if (canScrollX && scrolledX > mMaxScrollBuffer.x) {
                    mEdgeEffectRight.onPull((scrolledX - mMaxScrollBuffer.x) / (float) mContentRect.width());
                    mEdgeEffectRightActive = true;
                }
                if (canScrollY && scrolledY > mMaxScrollBuffer.y) {
                    mEdgeEffectBottom.onPull((scrolledY - mMaxScrollBuffer.y) / (float) mContentRect.height());
                    mEdgeEffectBottomActive = true;
                }
            }

            ViewCompat.postInvalidateOnAnimation(ScaleImageView.this);
            return true;
        }

        private void disallowParentInterceptWhenOnEdge(float directionX, float directionY) {
            final ViewParent parent = getParent();
            if (parent != null && (mAllowParentHorizontalScroll || mAllowParentVerticalScroll)) {
                getImageRect(mRectF);
                if (mAllowParentHorizontalScroll) {
                    if (directionX > 0 && Math.abs(mRectF.right - mContentRect.right) > mMinEdge) {
                        parent.requestDisallowInterceptTouchEvent(true);
                    }
                    if (directionX < 0 && Math.abs(mRectF.left - mContentRect.left) > mMinEdge) {
                        parent.requestDisallowInterceptTouchEvent(true);
                    }
                }
                if (mAllowParentVerticalScroll) {
                    if (directionY > 0 && Math.abs(mRectF.bottom - mContentRect.bottom) > mMinEdge) {
                        parent.requestDisallowInterceptTouchEvent(true);
                    }
                    if (directionY < 0 && Math.abs(mRectF.top - mContentRect.top) > mMinEdge) {
                        parent.requestDisallowInterceptTouchEvent(true);
                    }
                }
            }
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            disallowParentInterceptWhenOnEdge(velocityX, velocityY);
            fling((int) -velocityX, (int) -velocityY);
            return true;
        }
    };

    mScaleGestureDetector = new ScaleGestureDetector(context, scaleGestureListener);
    mGestureDetector = new GestureDetectorCompat(context, gestureListener);

    mScroller = new OverScroller(context);
    mZoomer = new Zoomer(context);

    // Sets up edge effects
    mEdgeEffectLeft = new EdgeEffectCompat(context);
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectRight = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);

    setSrcDrawable(src);
}

From source file:net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.java

@Override
public boolean onTouch(View view, MotionEvent ev) {
    if (mViewWidth < 2) {
        mViewWidth = mListView.getWidth();
    }//from w w w .j a v a2  s.  c  om

    switch (ev.getActionMasked()) {
    case MotionEvent.ACTION_DOWN: {
        if (mSwipePaused) {
            return false;
        }

        // Find the child view that was touched (perform a hit test)
        Rect rect = new Rect();
        int childCount = mListView.getChildCount();
        int[] listViewCoords = new int[2];
        mListView.getLocationOnScreen(listViewCoords);
        int x = (int) ev.getRawX() - listViewCoords[0];
        int y = (int) ev.getRawY() - listViewCoords[1];
        View child;
        for (int i = mListView.getHeaderViewsCount(); i < childCount; i++) {
            child = mListView.getChildAt(i);
            if (child != null) {
                child.getHitRect(rect);
                if (rect.contains(x, y)) {
                    // if a specific swiping layout has been giving, use this to swipe.
                    if (mSwipingLayout > 0) {
                        View swipingView = child.findViewById(mSwipingLayout);
                        if (swipingView != null) {
                            mSwipeDownView = swipingView;
                            mSwipeDownChild = child;
                            break;
                        }
                    }
                    // If no swiping layout has been found, swipe the whole child
                    mSwipeDownView = mSwipeDownChild = child;
                    break;
                }
            }
        }

        if (mSwipeDownView != null) {
            // test if the item should be swiped
            int position = mListView.getPositionForView(mSwipeDownView) - mListView.getHeaderViewsCount();
            if (mCallbacks == null || mCallbacks.canDismiss(position)) {
                mDownX = ev.getRawX();
                mDownY = ev.getRawY();
                mDownPosition = position;

                mVelocityTracker = VelocityTracker.obtain();
                mVelocityTracker.addMovement(ev);
            } else {
                // set back to null to revert swiping
                mSwipeDownView = mSwipeDownChild = null;
            }
        }
        return false;
    }

    case MotionEvent.ACTION_CANCEL: {
        if (mVelocityTracker == null) {
            break;
        }

        if (mSwipeDownView != null && mSwiping) {
            // cancel
            ViewCompat.animate(mSwipeDownView).translationX(0).alpha(1).setDuration(mAnimationTime)
                    .setListener(null);
        }
        mVelocityTracker.recycle();
        mVelocityTracker = null;
        mDownX = 0;
        mDownY = 0;
        mSwipeDownView = mSwipeDownChild = null;
        mDownPosition = ListView.INVALID_POSITION;
        mSwiping = false;
        break;
    }

    case MotionEvent.ACTION_UP: {
        if (mVelocityTracker == null) {
            break;
        }

        float deltaX = ev.getRawX() - mDownX;
        mVelocityTracker.addMovement(ev);
        mVelocityTracker.computeCurrentVelocity(1000);
        float velocityX = Math.abs(mVelocityTracker.getXVelocity());
        float velocityY = Math.abs(mVelocityTracker.getYVelocity());
        boolean dismiss = false;
        boolean dismissRight = false;
        if (Math.abs(deltaX) > mViewWidth / 2 && mSwiping) {
            dismiss = true;
            dismissRight = deltaX > 0;
        } else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity && velocityY < velocityX
                && mSwiping && isSwipeDirectionValid(mVelocityTracker.getXVelocity())
                && deltaX >= mViewWidth * 0.2f) {
            dismiss = true;
            dismissRight = mVelocityTracker.getXVelocity() > 0;
        }
        if (dismiss) {
            // dismiss
            slideOutView(mSwipeDownView, mSwipeDownChild, mDownPosition, dismissRight);
        } else if (mSwiping) {
            // Swipe back to regular position
            ViewCompat.animate(mSwipeDownView).translationX(0).alpha(1).setDuration(mAnimationTime)
                    .setListener(null);
        }
        mVelocityTracker = null;
        mDownX = 0;
        mDownY = 0;
        mSwipeDownView = null;
        mSwipeDownChild = null;
        mDownPosition = AbsListView.INVALID_POSITION;
        mSwiping = false;
        break;
    }

    case MotionEvent.ACTION_MOVE: {
        if (mVelocityTracker == null || mSwipePaused) {
            break;
        }

        mVelocityTracker.addMovement(ev);
        float deltaX = ev.getRawX() - mDownX;
        float deltaY = ev.getRawY() - mDownY;
        // Only start swipe in correct direction
        if (isSwipeDirectionValid(deltaX)) {
            ViewParent parent = mListView.getParent();
            if (parent != null) {
                // If we swipe don't allow parent to intercept touch (e.g. like NavigationDrawer does)
                // otherwise swipe would not be working.
                parent.requestDisallowInterceptTouchEvent(true);
            }
            if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
                mSwiping = true;
                mListView.requestDisallowInterceptTouchEvent(true);

                // Cancel ListView's touch (un-highlighting the item)
                MotionEvent cancelEvent = MotionEvent.obtain(ev);
                cancelEvent.setAction(MotionEvent.ACTION_CANCEL
                        | (ev.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
                mListView.onTouchEvent(cancelEvent);
            }
        } else {
            // If we swiped into wrong direction, act like this was the new
            // touch down point
            mDownX = ev.getRawX();
            deltaX = 0;
        }

        if (mSwiping) {
            ViewCompat.setTranslationX(mSwipeDownView, deltaX);
            ViewCompat.setAlpha(mSwipeDownView,
                    Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth)));
            return true;
        }
        break;
    }
    }
    return false;
}

From source file:com.huyn.demogroup.zoomageview.view.PhotoViewAttacher.java

@Override
public void onDrag(boolean down, float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }// www .j a  va2 s. co m

    mSuppMatrix.postTranslate(dx, dy);
    if (down) {
        mIsDragging = true;
        computeDrag(dx, dy);
    }
    checkAndDisplayMatrix(false);

    /*
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = mImageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (parent != null) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

From source file:com.yanzhenjie.album.widget.photoview.PhotoViewAttacher.java

@SuppressLint("ClickableViewAccessibility")
@Override/*from   w w  w  .  j  a  v a2  s .com*/
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch (ev.getAction()) {
        case ACTION_DOWN:
            // First, disable the Parent from intercepting the touch
            // event
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(true);
            }

            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case ACTION_CANCEL:
        case ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (null != rect) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            break;
        }

        // Try the Scale/Drag detector
        if (null != mScaleDragDetector) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();

            handled = mScaleDragDetector.onTouchEvent(ev);

            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

            mBlockParentIntercept = didntScale && didntDrag;
        }

        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }

    }

    return handled;
}

From source file:com.ycl.framework.photoview.PhotoViewAttacher.java

@Override
public boolean onTouch(final View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch (ev.getAction()) {
        case ACTION_DOWN:
            // First, disable the Parent from intercepting the touch
            // event
            v.removeCallbacks(mRunColse);
            if (null != parent)
                parent.requestDisallowInterceptTouchEvent(true);
            else//from w  w w  .j  a  va 2  s.com
                Log.i(LOG_TAG, "onTouch getParent() returned null");
            //?
            lastPosX = ev.getX();
            lastPosY = ev.getY();
            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case ACTION_CANCEL:
        case ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (null != rect) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            //?click
            if (Math.abs(ev.getX() - lastPosX) < 4 && Math.abs(ev.getY() - lastPosY) < 4) {
                if (OnDoubleTap) {
                    OnDoubleTap = false;
                } else
                    v.postDelayed(mRunColse, 330);
            } else {
                OnDoubleTap = false;
            }
            break;
        }

        // Try the Scale/Drag detector
        if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) {
            handled = true;
        }

        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }
    }

    return handled;
}

From source file:com.ycl.framework.photoview.PhotoViewAttacher.java

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }//  www  .  java  2 s.c  o  m

    if (DEBUG) {
        LogManager.getLogger().d(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling()) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent)
                parent.requestDisallowInterceptTouchEvent(false);
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

From source file:com.homechart.app.commont.imagedetail.PhotoViewAttacher.java

@SuppressLint("ClickableViewAccessibility")
@Override/*from www . j a v a2  s .  co m*/
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch (ev.getAction()) {
        case ACTION_DOWN:
            // First, disable the Parent from intercepting the touch
            // event
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(true);
            } else {

            }

            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case ACTION_CANCEL:
        case ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (null != rect) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            break;
        }

        // Try the Scale/Drag detector
        if (null != mScaleDragDetector) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();

            handled = mScaleDragDetector.onTouchEvent(ev);

            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

            mBlockParentIntercept = didntScale && didntDrag;
        }

        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }

    }

    return handled;
}

From source file:com.example.imagegallerydemo.photoview.PhotoViewAttacher.java

@SuppressLint("ClickableViewAccessibility")
@Override/*  w w  w .  j a v a 2s  .c o  m*/
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch (ev.getAction()) {
        case ACTION_DOWN:
            // First, disable the Parent from intercepting the touch
            // event
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(true);
            } else {
                Log.i(LOG_TAG, "onTouch getParent() returned null");
            }

            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case ACTION_CANCEL:
        case ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (null != rect) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            break;
        }

        // Try the Scale/Drag detector
        if (null != mScaleDragDetector) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();

            handled = mScaleDragDetector.onTouchEvent(ev);

            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

            mBlockParentIntercept = didntScale && didntDrag;
        }

        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }

    }

    return handled;
}

From source file:com.zxj.androidmvvm.common.view.photoview.PhotoViewAttacher.java

@SuppressLint("ClickableViewAccessibility")
@Override//ww  w.j av  a  2s .  co  m
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch (ev.getAction()) {
        case ACTION_DOWN:
            // First, disable the Parent from intercepting the touch
            // event
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(true);
            } else {
                ILog.i("onTouch getParent() returned null");
            }

            // If we're flinging, and the user presses down, cancel
            // fling
            cancelFling();
            break;

        case ACTION_CANCEL:
        case ACTION_UP:
            // If the user has zoomed less than min scale, zoom back
            // to min scale
            if (getScale() < mMinScale) {
                RectF rect = getDisplayRect();
                if (null != rect) {
                    v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                    handled = true;
                }
            }
            break;
        }

        // Try the Scale/Drag detector
        if (null != mScaleDragDetector) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();

            handled = mScaleDragDetector.onTouchEvent(ev);

            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

            mBlockParentIntercept = didntScale && didntDrag;
        }

        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }

    }

    return handled;
}