use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AppBarLayout method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method fadeOut.
public static ValueAnimator fadeOut(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());
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 brightnessSaturationFadeOut.
public static ValueAnimator brightnessSaturationFadeOut(final ImageView imageView, Animator.AnimatorListener listener) {
final ValueAnimator animator = ValueAnimator.ofFloat(1, 0);
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((1 - fraction) * 4 / 3, 1));
brightnessMatrix.setScale(scale, scale, scale, interpolator.getInterpolation(Math.min((1 - fraction) * 2, 1)));
saturationMatrix.preConcat(brightnessMatrix);
imageView.setColorFilter(new ColorMatrixColorFilter(saturationMatrix));
if (imageView.getParent() != null)
((View) imageView.getParent()).postInvalidate();
}
});
animator.start();
return animator;
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class AnimUtils method popIn.
public static ValueAnimator popIn(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.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 fadeIn.
public static ValueAnimator fadeIn(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());
if (view.getParent() != null)
((View) view.getParent()).postInvalidate();
});
animator.start();
return animator;
}
Aggregations