@Override public void setUpdateListener(final UpdateListener updateListener) { animator.setUpdateListener( new ValueAnimatorCompat.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimatorCompat valueAnimatorCompat) { updateListener.onUpdate(new ViewUtilsAnimator(valueAnimatorCompat)); } }); }
private void animateOffsetTo( final CoordinatorLayout coordinatorLayout, final AppBarLayout child, int offset) { if (mAnimator == null) { mAnimator = ViewUtils.createAnimator(); mAnimator.setInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); mAnimator.setUpdateListener( new ValueAnimatorCompat.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimatorCompat animator) { setHeaderTopBottomOffset(coordinatorLayout, child, animator.getAnimatedIntValue()); } }); } else { mAnimator.cancel(); } mAnimator.setIntValues(getTopBottomOffsetForScrollingSibling(), offset); mAnimator.setDuration(300); mAnimator.start(); }
@Override public void start() { animator.start(); }
@Override public void setIntValues(int from, int to) { animator.setIntValues(from, to); }
@Override public int getAnimatedIntValue() { return animator.getAnimatedIntValue(); }
@Override public void setDuration(int duration) { animator.setDuration(duration); }
static ViewUtilsAnimator newInstance() { ValueAnimatorCompat animator = ViewUtils.createAnimator(); animator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); return new ViewUtilsAnimator(animator); }