/** * All gesture detectors need to be called through this method to be able to * detect gestures. This method delegates work to handler methods * (handleStartProgressEvent, handleInProgressEvent) implemented in * extending classes. * * @param event * @return */ public boolean onTouchEvent(MotionEvent event){ final int actionCode = event.getAction() & MotionEvent.ACTION_MASK; if (!mGestureInProgress) { handleStartProgressEvent(actionCode, event); } else { handleInProgressEvent(actionCode, event); } return true; }
protected void updateStateByEvent(MotionEvent curr){ super.updateStateByEvent(curr); final MotionEvent prev = mPrevEvent; mCurrLen = -1; mPrevLen = -1; // Previous final float px0 = prev.getX(0); final float py0 = prev.getY(0); final float px1 = prev.getX(1); final float py1 = prev.getY(1); final float pvx = px1 - px0; final float pvy = py1 - py0; mPrevFingerDiffX = pvx; mPrevFingerDiffY = pvy; // Current final float cx0 = curr.getX(0); final float cy0 = curr.getY(0); final float cx1 = curr.getX(1); final float cy1 = curr.getY(1); final float cvx = cx1 - cx0; final float cvy = cy1 - cy0; mCurrFingerDiffX = cvx; mCurrFingerDiffY = cvy; }
/** * All gesture detectors need to be called through this method to be able to * detect gestures. This method delegates work to handler methods * (handleStartProgressEvent, handleInProgressEvent) implemented in * extending classes. * * @param event * @return */ public boolean onTouchEvent(MotionEvent event) { final int actionCode = event.getAction() & MotionEvent.ACTION_MASK; if (!mGestureInProgress) { handleStartProgressEvent(actionCode, event); } else { handleInProgressEvent(actionCode, event); } return true; }
protected void updateStateByEvent(MotionEvent curr) { super.updateStateByEvent(curr); final MotionEvent prev = mPrevEvent; // Focus intenal mCurrFocusInternal = determineFocalPoint(curr); mPrevFocusInternal = determineFocalPoint(prev); // Focus external // - Prevent skipping of focus delta when a finger is added or removed boolean mSkipNextMoveEvent = prev.getPointerCount() != curr.getPointerCount(); mFocusDeltaExternal = mSkipNextMoveEvent ? FOCUS_DELTA_ZERO : new PointF(mCurrFocusInternal.x - mPrevFocusInternal.x, mCurrFocusInternal.y - mPrevFocusInternal.y); // - Don't directly use mFocusInternal (or skipping will occur). Add // unskipped delta values to mFocusExternal instead. mFocusExternal.x += mFocusDeltaExternal.x; mFocusExternal.y += mFocusDeltaExternal.y; }
protected void updateStateByEvent(MotionEvent curr) { super.updateStateByEvent(curr); final MotionEvent prev = mPrevEvent; mCurrLen = -1; mPrevLen = -1; // Previous final float px0 = prev.getX(0); final float py0 = prev.getY(0); final float px1 = prev.getX(1); final float py1 = prev.getY(1); final float pvx = px1 - px0; final float pvy = py1 - py0; mPrevFingerDiffX = pvx; mPrevFingerDiffY = pvy; // Current final float cx0 = curr.getX(0); final float cy0 = curr.getY(0); final float cx1 = curr.getX(1); final float cy1 = curr.getY(1); final float cvx = cx1 - cx0; final float cvy = cy1 - cy0; mCurrFingerDiffX = cvx; mCurrFingerDiffY = cvy; }
protected void updateStateByEvent(MotionEvent curr) { super.updateStateByEvent(curr); final MotionEvent prev = mPrevEvent; // Focus intenal mCurrFocusInternal = determineFocalPoint(curr); mPrevFocusInternal = determineFocalPoint(prev); // Focus external // - Prevent skipping of focus delta when a finger is added or removed boolean mSkipNextMoveEvent = prev.getPointerCount() != curr.getPointerCount(); mFocusDeltaExternal = mSkipNextMoveEvent ? FOCUS_DELTA_ZERO : new PointF(mCurrFocusInternal.x - mPrevFocusInternal.x, mCurrFocusInternal.y - mPrevFocusInternal.y); // - Don't directly use mFocusInternal (or skipping will occur). Add // unskipped delta values to mFocusExternal instead. mFocusExternal.x += mFocusDeltaExternal.x; mFocusExternal.y += mFocusDeltaExternal.y; }