@Override public boolean onInterceptTouchEvent(MotionEvent ev){
  final int action=ev.getAction() & MotionEvent.ACTION_MASK;
  if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
    mIsBeingDragged=false;
    mIsUnableToDrag=false;
    return false;
  }
  if (action != MotionEvent.ACTION_DOWN) {
    if (mIsBeingDragged) {
      return true;
    }
    if (mIsUnableToDrag) {
      return false;
    }
  }
switch (action) {
case MotionEvent.ACTION_MOVE:
{
      final float x=ev.getX();
      final float dx=x - mLastMotionX;
      final float xDiff=Math.abs(dx);
      final float y=ev.getY();
      final float yDiff=Math.abs(y - mLastMotionY);
      if (xDiff > mTouchSlop && xDiff > yDiff) {
        mIsBeingDragged=true;
        mLastMotionX=x;
      }
 else {
        if (yDiff > mTouchSlop) {
          mIsUnableToDrag=true;
        }
      }
      break;
    }
case MotionEvent.ACTION_DOWN:
{
    if (!mScroller.isFinished()) {
      return false;
    }
    mLastMotionX=ev.getX();
    mLastMotionY=ev.getY();
    mIsBeingDragged=false;
    mIsUnableToDrag=false;
    break;
  }
}
return mIsBeingDragged;
}

@ Override public boolean onInterceptTouchEvent ( MotionEvent ev ) { final int action = ev . getAction ( ) & MotionEvent . ACTION_MASK ; if ( action == MotionEvent . ACTION_CANCEL || action == MotionEvent . ACTION_UP ) { mIsBeingDragged = false ; mIsUnableToDrag = false ; return false ; } if ( action != MotionEvent . ACTION_DOWN ) { if ( mIsBeingDragged ) { return true ; } if ( mIsUnableToDrag ) { return false ; } } switch ( action ) { case MotionEvent . ACTION_MOVE : { final float x = ev . getX ( ) ; final float dx = x - mLastMotionX ; final float xDiff = Math . abs ( dx ) ; final float y = ev . getY ( ) ; final float yDiff = Math . abs ( y - mLastMotionY ) ; if ( xDiff > mTouchSlop && xDiff > yDiff ) { mIsBeingDragged = true ; mLastMotionX = x ; } else { if ( yDiff > mTouchSlop ) { mIsUnableToDrag = true ; } } break ; } case MotionEvent . ACTION_DOWN : { if ( ! mScroller . isFinished ( ) ) { return false ; } mLastMotionX = ev . getX ( ) ; mLastMotionY = ev . getY ( ) ; mIsBeingDragged = false ; mIsUnableToDrag = false ; break ; } } return mIsBeingDragged ; }
this method just determines whether we want to intercept the motion . if we return true , onmotionevent will be called and we do the actual scrolling there .
