use of com.nineoldandroids.animation.ValueAnimator in project Signal-Android by WhisperSystems.
the class TransferControlView method getWidthAnimator.
private Animator getWidthAnimator(final int from, final int to) {
final ValueAnimator anim = ValueAnimator.ofInt(from, to);
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int val = (Integer) animation.getAnimatedValue();
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
layoutParams.width = val;
setLayoutParams(layoutParams);
}
});
anim.setInterpolator(new FastOutSlowInInterpolator());
anim.setDuration(TRANSITION_MS);
return anim;
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method flyIn.
public static ValueAnimator flyIn(final View view, Animator.AnimatorListener listener) {
if (view.getVisibility() != View.VISIBLE)
ViewHelper.setAlpha(view, 0);
float start = ViewHelper.getAlpha(view);
ValueAnimator animator = ValueAnimator.ofFloat(start, 1);
animator.setDuration((long) (200 * (1 - start)));
animator.setInterpolator(new DecelerateInterpolator());
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(valueAnimator -> {
ViewHelper.setAlpha(view, (Float) valueAnimator.getAnimatedValue());
ViewHelper.setTranslationY(view, Math.min(view.getHeight() / 2, view.getResources().getDimension(R.dimen.carbon_1dip) * 50.0f) * (1 - (Float) valueAnimator.getAnimatedValue()));
if (view.getParent() != null)
((View) view.getParent()).postInvalidate();
});
animator.start();
return animator;
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method popOut.
public static ValueAnimator popOut(final View view, Animator.AnimatorListener listener) {
float start = ViewHelper.getAlpha(view);
ValueAnimator animator = ValueAnimator.ofFloat(start, 0);
animator.setDuration((long) (200 * start));
animator.setInterpolator(new DecelerateInterpolator());
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(valueAnimator -> {
ViewHelper.setAlpha(view, (Float) valueAnimator.getAnimatedValue());
ViewHelper.setScaleX(view, (Float) valueAnimator.getAnimatedValue());
ViewHelper.setScaleY(view, (Float) valueAnimator.getAnimatedValue());
if (view.getParent() != null)
((View) view.getParent()).postInvalidate();
});
animator.start();
return animator;
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method progressWidthIn.
public static ValueAnimator progressWidthIn(final ProgressBar circularProgress, Animator.AnimatorListener listener) {
final float arcWidth = circularProgress.getBarPadding() + circularProgress.getBarWidth();
float start = circularProgress.getBarWidth();
ValueAnimator animator = ValueAnimator.ofFloat(circularProgress.getBarWidth(), arcWidth);
animator.setDuration((long) (100 * (arcWidth - start)));
animator.setInterpolator(new DecelerateInterpolator());
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(valueAnimator -> {
float value = (Float) valueAnimator.getAnimatedValue();
circularProgress.setBarWidth(value);
circularProgress.setBarPadding(arcWidth - value);
});
animator.start();
return animator;
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method brightnessSaturationFadeIn.
public static ValueAnimator brightnessSaturationFadeIn(final ImageView imageView, Animator.AnimatorListener listener) {
final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
final AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
animator.setInterpolator(interpolator);
animator.setDuration(800);
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
ColorMatrix saturationMatrix = new ColorMatrix();
ColorMatrix brightnessMatrix = new ColorMatrix();
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float fraction = animator.getAnimatedFraction();
saturationMatrix.setSaturation((Float) animator.getAnimatedValue());
float scale = 2 - interpolator.getInterpolation(Math.min(fraction * 4 / 3, 1));
brightnessMatrix.setScale(scale, scale, scale, interpolator.getInterpolation(Math.min(fraction * 2, 1)));
saturationMatrix.preConcat(brightnessMatrix);
imageView.setColorFilter(new ColorMatrixColorFilter(saturationMatrix));
if (imageView.getParent() != null)
((View) imageView.getParent()).postInvalidate();
}
});
animator.start();
return animator;
}
Aggregations