Code example for VelocityTracker

Methods: addMovementcomputeCurrentVelocitygetXVelocitygetYVelocityrecycle

0
						if (null != mVelocityTracker) {
							mLastTouchX = getActiveX(ev);
							mLastTouchY = getActiveY(ev);
 
							// Compute velocity within the last 1000ms 
							mVelocityTracker.addMovement(ev);
							mVelocityTracker.computeCurrentVelocity(1000);
 
							final float vX = mVelocityTracker.getXVelocity(), vY = mVelocityTracker.getYVelocity();
 
							// If the velocity is greater than minVelocity, call 
							// listener 
							if (Math.max(Math.abs(vX), Math.abs(vY)) >= mMinimumVelocity) {
								mListener.onFling(mLastTouchX, mLastTouchY, -vX, -vY);
							} 
						} 
					} 
 
					// Recycle Velocity Tracker 
					if (null != mVelocityTracker) {
						mVelocityTracker.recycle();
						mVelocityTracker = null;
					} 
					break; 
				} 
			} 
Experience pair programming with AI  Get Codota for Java