@ Nullable private Animator createAnimator ( @ NonNull final View animatedView , @ NonNull final View rootView , @ NonNull final CircleRevealAnimation animation , @ Nullable final AnimatorListener listener , final boolean show ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { long duration = getDuration ( animatedView , animation ) ; int horizontalDistance = Math . max ( Math . abs ( rootView . getLeft ( ) - animation . getX ( ) ) , Math . abs ( rootView . getRight ( ) - animation . getX ( ) ) ) ; int verticalDistance = Math . max ( Math . abs ( rootView . getTop ( ) - animation . getY ( ) ) , Math . abs ( rootView . getBottom ( ) - animation . getY ( ) ) ) ; float maxRadius = ( float ) Math . sqrt ( Math . pow ( horizontalDistance , 2 ) + Math . pow ( verticalDistance , 2 ) ) ; Animator animator = ViewAnimationUtils . createCircularReveal ( animatedView , animation . getX ( ) , animation . getY ( ) , show ? animation . getRadius ( ) : maxRadius , show ? maxRadius : animation . getRadius ( ) ) ; animator . setInterpolator ( animation . getInterpolator ( ) ) ; animator . setStartDelay ( animation . getStartDelay ( ) ) ; animator . setDuration ( duration ) ; if ( listener != null ) { animator . addListener ( listener ) ; } if ( animation . getAlpha ( ) != null ) { ObjectAnimator alphaAnimator = ObjectAnimator . ofFloat ( animatedView , "alpha" , show ? animation . getAlpha ( ) : 1 , show ? 1 : animation . getAlpha ( ) ) ; alphaAnimator . setInterpolator ( animation . getInterpolator ( ) ) ; alphaAnimator . setStartDelay ( animation . getStartDelay ( ) ) ; alphaAnimator . setDuration ( duration ) ; AnimatorSet animatorSet = new AnimatorSet ( ) ; animatorSet . playTogether ( animator , alphaAnimator ) ; return animatorSet ; } return animator ; } return null ; }
Creates an animator which should be used for a circle reveal animation .