Code example for VelocityTracker

Methods: addMovementcomputeCurrentVelocitygetXVelocitygetYVelocityrecycle

0
	                 break; 
	             } 
 
             float deltaXActionUp = motionEvent.getRawX() - mActionDownXCoordinate;
              
             mVelocityTracker.addMovement(motionEvent);
              
             mVelocityTracker.computeCurrentVelocity(1000);
              
              
             float velocityX = Math.abs(mVelocityTracker.getXVelocity());
             float velocityY = Math.abs(mVelocityTracker.getYVelocity());
              
             boolean dismiss = false;
             boolean dismissRight = false;
              
              
	             if (Math.abs(deltaXActionUp) > mViewWidth / 2) 
	             { 
	            	  
	                 dismiss = true;
	                 dismissRight = deltaXActionUp > 0;
	                  
	             }  
              
	             else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity && velocityY < velocityX) 
	             { 
	            	  
	                 dismiss = true;
	                 dismissRight = mVelocityTracker.getXVelocity() > 0;
	                  
	             } 
	              
	              
	             if (dismiss) 
	             { 
	            	  
	            	 mView.animate()
	                         .translationX(dismissRight ? mViewWidth : -mViewWidth)
	                         .alpha(0)
	                         .setDuration(mAnimationTime)
	                         .setListener(new AnimatorListenerAdapter() 
	                         { 
	                             @Override 
	                             public void onAnimationEnd(Animator animation) 
	                             { 
	                            	  
	                                 performDismiss(); 
	                                  
	                             } 
	                         }); 
                  
	             } 
	              
	             else  
	             { 
	            	  
	             // User has cancelled action	  
                 mView.animate()
                         .translationX(0)
                         .alpha(1)
                         .setDuration(mAnimationTime)
                         .setListener(null);
                  
	             } 
	              
	         mVelocityTracker.recycle();
             mTranslationX = 0;
             mActionDownXCoordinate = 0;
             isSwiping = false;
              
             break; 
Connect your IDE to all the code out there  Get Codota for Java