Analyzes the given motion event and if applicable triggers the appropriate callbacks on the OnGestureListener supplied.
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);
149 mCurrentMode = MODE_UNKNOWN;
150 mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
155 case MotionEvent.ACTION_MOVE:
158 if (mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
162 if (mCurrentMode == MODE_UNKNOWN)
165 if (pointerDistanceChanged(mCurrentDoubleDownEvent, ev))
167 handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
168 MotionEvent e = MotionEvent.obtain(ev);
169 e.setAction(mCurrentDoubleDownEvent.getAction());
170 handled |= scaleGestureDetector.onTouchEvent(e);
171 mCurrentMode = MODE_PINCH_ZOOM;
176 mScrollDetectionScore++;
177 if (mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
178 mCurrentMode = MODE_SCROLL;
182 switch (mCurrentMode)
184 case MODE_PINCH_ZOOM:
185 if (scaleGestureDetector !=
null)
186 handled |= scaleGestureDetector.onTouchEvent(ev);
200 case MotionEvent.ACTION_UP:
202 if (mPreviousPointerUpEvent !=
null &&
203 (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) >
204 DOUBLE_TOUCH_TIMEOUT)
206 mPreviousPointerUpEvent.recycle();
207 mPreviousPointerUpEvent =
null;
213 if (mCancelDetection || !mDoubleInProgress)
216 boolean hasTapEvent = mHandler.hasMessages(TAP);
217 MotionEvent currentUpEvent = MotionEvent.obtain(ev);
218 if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
220 else if (mCurrentMode == MODE_PINCH_ZOOM)
221 handled = scaleGestureDetector.onTouchEvent(ev);
223 if (mPreviousUpEvent !=
null)
224 mPreviousUpEvent.recycle();
227 mPreviousUpEvent = currentUpEvent;
231 case MotionEvent.ACTION_CANCEL:
236 if ((action == MotionEvent.ACTION_MOVE) && handled ==
false)
boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2)
boolean onDoubleTouchUp(MotionEvent e)
boolean onDoubleTouchDown(MotionEvent e)
boolean onDoubleTouchSingleTap(MotionEvent e)