public boolean shouldInterceptTouchEvent(MotionEvent ev){
  final int action=MotionEventCompat.getActionMasked(ev);
  final int actionIndex=MotionEventCompat.getActionIndex(ev);
  if (action == MotionEvent.ACTION_DOWN) {
    cancel();
  }
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
switch (action) {
case MotionEvent.ACTION_DOWN:
{
      final float x=ev.getX();
      final float y=ev.getY();
      final int pointerId=MotionEventCompat.getPointerId(ev,0);
      saveInitialMotion(x,y,pointerId);
      final View toCapture=findTopChildUnder((int)x,(int)y);
      if (toCapture == mCapturedView && mDragState == STATE_SETTLING) {
        tryCaptureViewForDrag(toCapture,pointerId);
      }
      final int edgesTouched=mInitialEdgesTouched[pointerId];
      if ((edgesTouched & mTrackingEdges) != 0) {
        mCallback.onEdgeTouched(edgesTouched & mTrackingEdges,pointerId);
      }
      break;
    }
case MotionEventCompat.ACTION_POINTER_DOWN:
{
    final int pointerId=MotionEventCompat.getPointerId(ev,actionIndex);
    final float x=MotionEventCompat.getX(ev,actionIndex);
    final float y=MotionEventCompat.getY(ev,actionIndex);
    saveInitialMotion(x,y,pointerId);
    if (mDragState == STATE_IDLE) {
      final int edgesTouched=mInitialEdgesTouched[pointerId];
      if ((edgesTouched & mTrackingEdges) != 0) {
        mCallback.onEdgeTouched(edgesTouched & mTrackingEdges,pointerId);
      }
    }
 else     if (mDragState == STATE_SETTLING) {
      final View toCapture=findTopChildUnder((int)x,(int)y);
      if (toCapture == mCapturedView) {
        tryCaptureViewForDrag(toCapture,pointerId);
      }
    }
    break;
  }
case MotionEvent.ACTION_MOVE:
{
  if (mInitialMotionX == null || mInitialMotionY == null) {
    return false;
  }
  final int pointerCount=MotionEventCompat.getPointerCount(ev);
  for (int i=0; i < pointerCount; i++) {
    final int pointerId=MotionEventCompat.getPointerId(ev,i);
    final float x=MotionEventCompat.getX(ev,i);
    final float y=MotionEventCompat.getY(ev,i);
    final float dx=x - mInitialMotionX[pointerId];
    final float dy=y - mInitialMotionY[pointerId];
    final float slope=Math.abs(dy / dx);
    if (slope >= 1) {
      break;
    }
    reportNewEdgeDrags(dx,dy,pointerId);
    if (mDragState == STATE_DRAGGING) {
      break;
    }
    final View toCapture=findTopChildUnder((int)x,(int)y);
    if (toCapture != null && checkTouchSlop(toCapture,dx,dy) && tryCaptureViewForDrag(toCapture,pointerId)) {
      break;
    }
  }
  saveLastMotion(ev);
  break;
}
case MotionEventCompat.ACTION_POINTER_UP:
{
final int pointerId=MotionEventCompat.getPointerId(ev,actionIndex);
clearMotionHistory(pointerId);
break;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
{
cancel();
break;
}
}
return mDragState == STATE_DRAGGING;
}

public boolean shouldInterceptTouchEvent ( MotionEvent ev ) { final int action = MotionEventCompat . getActionMasked ( ev ) ; final int actionIndex = MotionEventCompat . getActionIndex ( ev ) ; if ( action == MotionEvent . ACTION_DOWN ) { cancel ( ) ; } if ( mVelocityTracker == null ) { mVelocityTracker = VelocityTracker . obtain ( ) ; } mVelocityTracker . addMovement ( ev ) ; switch ( action ) { case MotionEvent . ACTION_DOWN : { final float x = ev . getX ( ) ; final float y = ev . getY ( ) ; final int pointerId = MotionEventCompat . getPointerId ( ev , 0 ) ; saveInitialMotion ( x , y , pointerId ) ; final View toCapture = findTopChildUnder ( ( int ) x , ( int ) y ) ; if ( toCapture == mCapturedView && mDragState == STATE_SETTLING ) { tryCaptureViewForDrag ( toCapture , pointerId ) ; } final int edgesTouched = mInitialEdgesTouched [ pointerId ] ; if ( ( edgesTouched & mTrackingEdges ) != 0 ) { mCallback . onEdgeTouched ( edgesTouched & mTrackingEdges , pointerId ) ; } break ; } case MotionEventCompat . ACTION_POINTER_DOWN : { final int pointerId = MotionEventCompat . getPointerId ( ev , actionIndex ) ; final float x = MotionEventCompat . getX ( ev , actionIndex ) ; final float y = MotionEventCompat . getY ( ev , actionIndex ) ; saveInitialMotion ( x , y , pointerId ) ; if ( mDragState == STATE_IDLE ) { final int edgesTouched = mInitialEdgesTouched [ pointerId ] ; if ( ( edgesTouched & mTrackingEdges ) != 0 ) { mCallback . onEdgeTouched ( edgesTouched & mTrackingEdges , pointerId ) ; } } else if ( mDragState == STATE_SETTLING ) { final View toCapture = findTopChildUnder ( ( int ) x , ( int ) y ) ; if ( toCapture == mCapturedView ) { tryCaptureViewForDrag ( toCapture , pointerId ) ; } } break ; } case MotionEvent . ACTION_MOVE : { if ( mInitialMotionX == null || mInitialMotionY == null ) { return false ; } final int pointerCount = MotionEventCompat . getPointerCount ( ev ) ; for ( int i = 0 ; i < pointerCount ; i ++ ) { final int pointerId = MotionEventCompat . getPointerId ( ev , i ) ; final float x = MotionEventCompat . getX ( ev , i ) ; final float y = MotionEventCompat . getY ( ev , i ) ; final float dx = x - mInitialMotionX [ pointerId ] ; final float dy = y - mInitialMotionY [ pointerId ] ; final float slope = Math . abs ( dy / dx ) ; if ( slope >= 1 ) { break ; } reportNewEdgeDrags ( dx , dy , pointerId ) ; if ( mDragState == STATE_DRAGGING ) { break ; } final View toCapture = findTopChildUnder ( ( int ) x , ( int ) y ) ; if ( toCapture != null && checkTouchSlop ( toCapture , dx , dy ) && tryCaptureViewForDrag ( toCapture , pointerId ) ) { break ; } } saveLastMotion ( ev ) ; break ; } case MotionEventCompat . ACTION_POINTER_UP : { final int pointerId = MotionEventCompat . getPointerId ( ev , actionIndex ) ; clearMotionHistory ( pointerId ) ; break ; } case MotionEvent . ACTION_UP : case MotionEvent . ACTION_CANCEL : { cancel ( ) ; break ; } } return mDragState == STATE_DRAGGING ; }
check if this event as provided to the parent view ' s onintercepttouchevent should cause the parent to intercept the touch event stream .
