Search in sources :

Example 16 with ValueAnimator

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;
}
Also used : FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) AnimatorUpdateListener(com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 17 with ValueAnimator

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;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 18 with ValueAnimator

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;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 19 with ValueAnimator

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;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 20 with ValueAnimator

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;
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ColorMatrix(android.graphics.ColorMatrix) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) ImageView(android.widget.ImageView) View(android.view.View) ShadowView(carbon.shadow.ShadowView)

Aggregations

ValueAnimator (com.nineoldandroids.animation.ValueAnimator)105 Animator (com.nineoldandroids.animation.Animator)55 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)46 StateAnimator (carbon.animation.StateAnimator)30 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)19 View (android.view.View)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)15 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 Paint (android.graphics.Paint)7 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 RecyclerView (android.support.v7.widget.RecyclerView)4 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 FrameLayout (android.widget.FrameLayout)4 ImageView (android.widget.ImageView)4 ArrayList (java.util.ArrayList)4 MotionEvent (android.view.MotionEvent)3 TouchInterceptionFrameLayout (com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout)3 AnimatorUpdateListener (com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)3