104    boolean handled = 
false;
 
  105    final int action = ev.getAction();
 
  108    switch (action & MotionEvent.ACTION_MASK)
 
  110      case MotionEvent.ACTION_DOWN:
 
  111        if (mCurrentDownEvent != 
null)
 
  112          mCurrentDownEvent.recycle();
 
  114        mCurrentMode = MODE_UNKNOWN;
 
  115        mCurrentDownEvent = MotionEvent.obtain(ev);
 
  116        mCancelDetection = 
false;
 
  117        mDoubleInProgress = 
false;
 
  118        mScrollDetectionScore = 0;
 
  122      case MotionEvent.ACTION_POINTER_UP:
 
  123        if (mPreviousPointerUpEvent != 
null)
 
  124          mPreviousPointerUpEvent.recycle();
 
  125        mPreviousPointerUpEvent = MotionEvent.obtain(ev);
 
  128      case MotionEvent.ACTION_POINTER_DOWN:
 
  131        if (ev.getPointerCount() > 2 ||
 
  132            (ev.getEventTime() - mCurrentDownEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT)
 
  139        if (mCancelDetection)
 
  143        mDoubleInProgress = 
true;
 
  144        if (mCurrentDoubleDownEvent != 
null)
 
  145          mCurrentDoubleDownEvent.recycle();
 
  146        mCurrentDoubleDownEvent = MotionEvent.obtain(ev);
 
  150        mCurrentMode = MODE_UNKNOWN;
 
  151        mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
 
  156      case MotionEvent.ACTION_MOVE:
 
  159        if (mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
 
  163        if (mCurrentMode == MODE_UNKNOWN)
 
  166          if (pointerDistanceChanged(mCurrentDoubleDownEvent, ev))
 
  168            handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
 
  169            MotionEvent e = MotionEvent.obtain(ev);
 
  170            e.setAction(mCurrentDoubleDownEvent.getAction());
 
  171            handled |= scaleGestureDetector.onTouchEvent(e);
 
  172            mCurrentMode = MODE_PINCH_ZOOM;
 
  177            mScrollDetectionScore++;
 
  178            if (mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
 
  179              mCurrentMode = MODE_SCROLL;
 
  183        switch (mCurrentMode)
 
  185          case MODE_PINCH_ZOOM:
 
  186            if (scaleGestureDetector != 
null)
 
  187              handled |= scaleGestureDetector.onTouchEvent(ev);
 
  201      case MotionEvent.ACTION_UP:
 
  203        if (mPreviousPointerUpEvent != 
null &&
 
  204            (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) >
 
  205                DOUBLE_TOUCH_TIMEOUT)
 
  207          mPreviousPointerUpEvent.recycle();
 
  208          mPreviousPointerUpEvent = 
null;
 
  214        if (mCancelDetection || !mDoubleInProgress)
 
  217        boolean hasTapEvent = mHandler.hasMessages(TAP);
 
  218        MotionEvent currentUpEvent = MotionEvent.obtain(ev);
 
  219        if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
 
  221        else if (mCurrentMode == MODE_PINCH_ZOOM)
 
  222          handled = scaleGestureDetector.onTouchEvent(ev);
 
  224        if (mPreviousUpEvent != 
null)
 
  225          mPreviousUpEvent.recycle();
 
  228        mPreviousUpEvent = currentUpEvent;
 
  232      case MotionEvent.ACTION_CANCEL:
 
  237    if ((action == MotionEvent.ACTION_MOVE) && !handled)