Code example for ActionBar

Methods: getNavigationItemCount, getSelectedNavigationIndex

0
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
		 
		final ActionBar actionBar = activity.getActionBar(); 
		if(actionBar == null) return false; 
		 
		int navigationItemCount = actionBar.getNavigationItemCount(); 
		if(navigationItemCount == 0) return false; 
		 
		int selectedIndex = actionBar.getSelectedNavigationIndex(); 
		 
		try { 
			 
			boolean hasTravelled = Math.abs(e1.getX() - e2.getX()) > DISTANCE; 
			boolean velocityReached = Math.abs(velocityX) > VELOCITY; 
			boolean hasDeviated = Math.abs(e1.getY() - e2.getY()) > DEVIATION; 
			 
			if(hasTravelled && !hasDeviated && velocityReached) { 
				 
				boolean swipedLeft = (e1.getX() - e2.getX()) > 0; 
				 
				if(swipedLeft) {