Example usage for android.animation ValueAnimator setEvaluator

List of usage examples for android.animation ValueAnimator setEvaluator

Introduction

In this page you can find the example usage for android.animation ValueAnimator setEvaluator.

Prototype

public void setEvaluator(TypeEvaluator value) 

Source Link

Document

The type evaluator to be used when calculating the animated values of this animation.

Usage

From source file:com.yoloo.android.util.AnimUtils.java

public static ValueAnimator ofArgb(int... values) {
    if (VersionUtil.hasL()) {
        return ValueAnimator.ofArgb(values);
    } else {//ww  w.j a v  a 2  s.co  m
        ValueAnimator anim = new ValueAnimator();
        anim.setIntValues(values);
        anim.setEvaluator(AnimUtils.getArgbEvaluator());
        return anim;
    }
}

From source file:com.pdftron.pdf.utils.ViewerUtils.java

/**
 * Creates an Animator object that varies the alpha property of the view. The
 * interpolation used is linear.// ww w.  ja  va 2s.c  om
 *
 * @param view the view to be animated
 * @param listener the listener to be used by this Animator
 *
 * @return a new Animator object that will change the "alpha" property
 * of the view.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static Animator createAlphaAnimator(View view, Animator.AnimatorListener listener) {
    if (view == null) {
        return null;
    }
    // We animate only the opacity of the view.
    ValueAnimator fader = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f, 0.4f, 1.0f, 0.0f);
    fader.setDuration(1500);
    fader.setEvaluator(new FloatEvaluator());
    if (listener != null) {
        fader.addListener(listener);
    }
    return fader;
}

From source file:io.digibyte.tools.animation.BRAnimator.java

public static void animateBackgroundDim(final ViewGroup backgroundLayout, boolean reverse) {
    int transColor = reverse ? R.color.black_trans : android.R.color.transparent;
    int blackTransColor = reverse ? android.R.color.transparent : R.color.black_trans;

    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(transColor, blackTransColor);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from  w  w  w .  j  a v  a  2  s  .  com
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            backgroundLayout.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim.setDuration(SLIDE_ANIMATION_DURATION);
    anim.start();
}

From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java

private void animateBackgroundColor(int from, int to, Interpolator interpolator) {
    final ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(from, to);//from w w  w. j a  v  a 2 s . c o m
    anim.setEvaluator(new ArgbEvaluator());
    anim.setInterpolator(interpolator);
    anim.addUpdateListener(valueAnimator -> {
        toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
    });
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            isUpdatingBackground = false;
        }
    });

    anim.setDuration(ANIMATION_DURATION);
    anim.start();
    isUpdatingBackground = true;
}

From source file:xyz.klinker.android.article.ArticleScrollListener.java

private void animateBackgroundColor(int from, int to, Interpolator interpolator) {
    final ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(from, to);/*from   www.  j av  a2 s.c  o  m*/
    anim.setEvaluator(new ArgbEvaluator());
    anim.setInterpolator(interpolator);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
            statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            isUpdatingBackground = false;
        }
    });

    anim.setDuration(ANIMATION_DURATION);
    anim.start();
    isUpdatingBackground = true;
}

From source file:org.catrobat.paintroid.ui.BottomBar.java

private void delayedAnimateSelectedTool(int startDelay) {
    ImageButton button = getToolButtonByToolType(mCurrentToolType);
    int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated);
    int fadedColor = color & 0x00ffffff;
    ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(500);// ww w.  j  a va 2s .  c  o  m
    valueAnimator.setRepeatCount(5);
    valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
    valueAnimator.setStartDelay(startDelay);
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (PaintroidApplication.currentTool != null) {
                setActivatedToolButton(PaintroidApplication.currentTool.getToolType());
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    valueAnimator.start();
}

From source file:com.advaitaworld.widgets.SlidingTabLayout.java

private void updateTitleColors(int prevSelectedPosition, int newSelectedPosition) {
    if (mSelectedTabColor == 0 && mDefaultTabColor == 0) {
        return;/*from  w w  w  .ja  v a2  s  . c  om*/
    }
    View tabViewPrev = mTabStrip.getChildAt(prevSelectedPosition);
    View tabViewNew = mTabStrip.getChildAt(newSelectedPosition);
    final TextView tabTitlePrev = getTabTitleView(tabViewPrev);
    final TextView tabTitleNew = getTabTitleView(tabViewNew);

    ArgbEvaluator evaluator = new ArgbEvaluator();
    ValueAnimator anim1 = new ValueAnimator();
    anim1.setIntValues(mDefaultTabColor, mSelectedTabColor);
    anim1.setEvaluator(evaluator);
    anim1.setDuration(300);
    anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitleNew.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    ValueAnimator anim2 = new ValueAnimator();
    anim2.setIntValues(mSelectedTabColor, mDefaultTabColor);
    anim2.setEvaluator(evaluator);
    anim2.setDuration(300);
    anim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitlePrev.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim1.start();
    anim2.start();
}

From source file:com.arsy.maps_library.MapRipple.java

private void startAnimation(final int numberOfRipple) {
    ValueAnimator animator = ValueAnimator.ofInt(0, (int) mDistance);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.setDuration(mRippleDuration);
    animator.setEvaluator(new IntEvaluator());
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  w  w w .  java2 s. co  m
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int animated = (int) valueAnimator.getAnimatedValue();
            mGroundOverlays[numberOfRipple].setDimensions(animated);
            if (mDistance - animated <= 10) {
                if (mLatLng != mPrevLatLng) {
                    mGroundOverlays[numberOfRipple].setPosition(mLatLng);
                }
            }
        }
    });
    animator.start();
    mAnimators[numberOfRipple] = animator;
}

From source file:bottombar.BottomBarTab.java

private void animateColors(int previousColor, int color) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(previousColor, color);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from w w w . j  av  a  2  s  .co  m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setColors((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim.setDuration(150);
    anim.start();
}

From source file:cs.umass.edu.prepare.view.activities.CalendarActivity.java

private void transition() {
    int transitionColor = ContextCompat.getColor(this, R.color.color_transition_details_swipe);
    ValueAnimator colorAnim = ObjectAnimator.ofInt(detailsView, "backgroundColor", transitionColor,
            Color.TRANSPARENT);/* ww w  . j  a va2s.  c o  m*/
    colorAnim.setDuration(250);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setRepeatCount(0);
    colorAnim.setRepeatMode(ValueAnimator.REVERSE);
    colorAnim.start();
}