private void setContext(android.view.MotionEvent curr)
        {
            if (mCurrEvent != null)
            {
                mCurrEvent.recycle();
            }
            mCurrEvent   = android.view.MotionEvent.obtain(curr);
            mCurrLen     = -1;
            mPrevLen     = -1;
            mScaleFactor = -1;
            android.view.MotionEvent prev = mPrevEvent;
            int prevIndex0 = prev.findPointerIndex(mActiveId0);
            int prevIndex1 = prev.findPointerIndex(mActiveId1);
            int currIndex0 = curr.findPointerIndex(mActiveId0);
            int currIndex1 = curr.findPointerIndex(mActiveId1);

            if (prevIndex0 < 0 || prevIndex1 < 0 || currIndex0 < 0 || currIndex1 < 0)
            {
                mInvalidGesture = true;
                android.util.Log.e(TAG, "Invalid MotionEvent stream detected.", new System.Exception
                                       ());
                if (mGestureInProgress)
                {
                    mListener.onScaleEnd(this);
                }
                return;
            }
            float px0 = prev.getX(prevIndex0);
            float py0 = prev.getY(prevIndex0);
            float px1 = prev.getX(prevIndex1);
            float py1 = prev.getY(prevIndex1);
            float cx0 = curr.getX(currIndex0);
            float cy0 = curr.getY(currIndex0);
            float cx1 = curr.getX(currIndex1);
            float cy1 = curr.getY(currIndex1);
            float pvx = px1 - px0;
            float pvy = py1 - py0;
            float cvx = cx1 - cx0;
            float cvy = cy1 - cy0;

            mPrevFingerDiffX = pvx;
            mPrevFingerDiffY = pvy;
            mCurrFingerDiffX = cvx;
            mCurrFingerDiffY = cvy;
            mFocusX          = cx0 + cvx * 0.5f;
            mFocusY          = cy0 + cvy * 0.5f;
            mTimeDelta       = curr.getEventTime() - prev.getEventTime();
            mCurrPressure    = curr.getPressure(currIndex0) + curr.getPressure(currIndex1);
            mPrevPressure    = prev.getPressure(prevIndex0) + prev.getPressure(prevIndex1);
        }
Beispiel #2
0
        private bool isConsideredDoubleTap(android.view.MotionEvent firstDown, android.view.MotionEvent
                                           firstUp, android.view.MotionEvent secondDown)
        {
            if (!mAlwaysInBiggerTapRegion)
            {
                return(false);
            }
            if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT)
            {
                return(false);
            }
            int deltaX = (int)firstDown.getX() - (int)secondDown.getX();
            int deltaY = (int)firstDown.getY() - (int)secondDown.getY();

            return(deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
        }
 /// <summary>Return the event time of the current event being processed.</summary>
 /// <remarks>Return the event time of the current event being processed.</remarks>
 /// <returns>Current event time in milliseconds.</returns>
 public virtual long getEventTime()
 {
     return(mCurrEvent.getEventTime());
 }