示例#1
0
        public bool dispatchTouchEvent(MotionEvent ev)
        {
            float x = ev.GetX();
            float y = ev.GetY();

            switch (ev.Action())
            {
            case MotionEventActions.Down:

                mLastX    = x;
                mLastY    = y;
                mDownTime = Java.Lang.JavaSystem.CurrentTimeMillis();
                mTmpAngle = 0;

                if (isFling)
                {
                    RemoveCallbacks(mFlingRunnable);
                    isFling = false;
                    return(true);
                }

                break;

            case MotionEventActions.Move:


                float start = getAngle(mLastX, mLastY);

                float end = getAngle(x, y);

                // Log.e("TAG", "start = " + start + " , end =" + end);
                if (getQuadrant(x, y) == 1 || getQuadrant(x, y) == 4)
                {
                    mStartAngle += end - start;
                    mTmpAngle   += end - start;
                }
                else
                {
                    mStartAngle += start - end;
                    mTmpAngle   += start - end;
                }

                RequestLayout();

                mLastX = x;
                mLastY = y;

                break;

            case MotionEventActions.Up:

                float anglePerSecond = mTmpAngle * 1000
                                       / (Java.Lang.JavaSystem.CurrentTimeMillis() - mDownTime);

                // Log.e("TAG", anglePrMillionSecond + " , mTmpAngel = " +
                // mTmpAngle);

                if (Math.Abs(anglePerSecond) > mFlingableValue && !isFling)
                {
                    Post(mFlingRunnable = new AutoFlingRunnable(anglePerSecond));

                    return(true);
                }

                if (Math.Abs(mTmpAngle) > NOCLICK_VALUE)
                {
                    return(true);
                }

                break;
            }
            return(base.DispatchTouchEvent(ev));
        }