Code example for ViewPropertyAnimator

Methods: alpha, setDuration, x

0
		case MotionEvent.ACTION_CANCEL:
			if (currentSwipeMode == SwipeMode.MOVING) {
				// Gesture has been stopped, or user did not move item far enough 
				// Restore item position and transparency smoothly 
				ViewPropertyAnimator animator = itemView.animate();
				animator.x(itemViewOriginalX);
				animator.alpha(itemViewOriginalAlpha);
				animator.setDuration(150);
				 
				itemView = null;
				currentSwipeMode = SwipeMode.NONE;
				return true; // Event has been consumed 
			} else if (currentSwipeMode == SwipeMode.IGNORING) {
				itemView = null;
				currentSwipeMode = SwipeMode.NONE;
			} 
			break; 
		} 
 
		// Event not processed 
		return false;