public override bool OnTouchEvent(MotionEvent e) { var index = e.ActionIndex; var action = (MotionEventActions)e.ActionMasked; var pointerId = e.GetPointerId(index); switch (action) { case MotionEventActions.Down: if (this._velocityTracket == null) { this._velocityTracket = VelocityTracker.Obtain(); } else { this._velocityTracket.Clear(); } this._velocityTracket.AddMovement(e); break; case MotionEventActions.Move: this._velocityTracket.AddMovement(e); this._velocityTracket.ComputeCurrentVelocity(1000); Log.Debug(DebugTag, "X velocity: " + VelocityTrackerCompat.GetXVelocity(this._velocityTracket, pointerId)); Log.Debug(DebugTag, "Y velocity: " + VelocityTrackerCompat.GetYVelocity(this._velocityTracket, pointerId)); break; case MotionEventActions.Cancel: case MotionEventActions.Up: this._velocityTracket.Recycle(); break; default: break; } return(true); }
private float getYVelocity() { mVelocityTracker.ComputeCurrentVelocity(1000, mMaximumVelocity); return(VelocityTrackerCompat.GetYVelocity(mVelocityTracker, mActivePointerId)); }