Code example for VelocityTracker

Methods: addMovement, computeCurrentVelocity, getXVelocity, recycle

0
				requestLayout();
			} 
			return true; 
		} else if (action == MotionEvent.ACTION_UP
				|| action == MotionEvent.ACTION_CANCEL) {
			mTracker.addMovement(event);
			// We intercepted the event because the user either 
			// 1) scrolled horizontally OR 
			// 2) tapped on the content view while the navigation view is 
			// showing 
			if (mScrolledHorizontally) {
				// If the user flinged, we should scroll in the direction of the 
				// fling. Otherwise, we scroll whichever one we're closer to. 
				mTracker.computeCurrentVelocity(1000, mMaximumVelocity);
				float velocity = mTracker.getXVelocity();
				if (Math.abs(velocity) > mMinimumVelocity) {
					if (velocity > 0) {
						showNavigationView(); 
					} else { 
						showContentView(); 
					} 
				} else { 
					scrollToNavigationOrContentView((int) event.getX());
				} 
			} else { 
				// We want to show the content view if the user tapped on it 
				// while the navigation is showing. 
				showContentView(); 
			} 
			mTracker.recycle();
			mTracker = null;
		} 
		return super.onTouchEvent(event);
	}