Example usage for android.animation ObjectAnimator setEvaluator

List of usage examples for android.animation ObjectAnimator setEvaluator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator 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.microntek.music.MusicActivity.java

private void updateStatusBarColor(int color) {
    if (color == Color.TRANSPARENT) {
        color = getResources().getColor(R.color.primary_dark);
    }/*w w w  .java 2s.  c om*/
    final Window window = getWindow();
    ObjectAnimator animator = ObjectAnimator.ofInt(window, "statusBarColor", window.getStatusBarColor(), color);
    animator.setEvaluator(new ArgbEvaluator());
    animator.setDuration(300);
    animator.start();
}

From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java

/**
 * Background color animation builder.//w w w.  j a v a2s  .  c  o m
 *
 * @param colors the colors
 * @return the animation builder
 */
public AnimationBuilder backgroundColor(int... colors) {
    for (View view : views) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors);
        objectAnimator.setEvaluator(new ArgbEvaluator());
        this.animatorList.add(objectAnimator);
    }
    return this;
}

From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java

/**
 * Text color animation builder./*from  ww  w. j a  v  a  2s.  c o m*/
 *
 * @param colors the colors
 * @return the animation builder
 */
public AnimationBuilder textColor(int... colors) {
    for (View view : views) {
        if (view instanceof TextView) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "textColor", colors);
            objectAnimator.setEvaluator(new ArgbEvaluator());
            this.animatorList.add(objectAnimator);
        }
    }
    return this;
}

From source file:com.betterAlarm.deskclock.DeskClock.java

private void setBackgroundColor() {
    final int duration;
    if (mLastHourColor == UNKNOWN_COLOR_ID) {
        mLastHourColor = getResources().getColor(R.color.default_background);
        duration = BACKGROUND_COLOR_INITIAL_ANIMATION_DURATION_MILLIS;
    } else {//from w  ww  . ja  v  a2  s.co  m
        duration = getResources().getInteger(android.R.integer.config_longAnimTime);
    }
    final int currHourColor = Utils.getCurrentHourColor();
    if (mLastHourColor != currHourColor) {
        final ObjectAnimator animator = ObjectAnimator.ofInt(getWindow().getDecorView(), "backgroundColor",
                mLastHourColor, currHourColor);
        animator.setDuration(duration);
        animator.setEvaluator(new ArgbEvaluator());
        animator.start();
        mLastHourColor = currHourColor;
    }
}

From source file:com.phonemetra.deskclock.DeskClock.java

private void setBackgroundColor() {
    final int duration;
    if (mLastHourColor == UNKNOWN_COLOR_ID) {
        mLastHourColor = getResources().getColor(R.color.default_background);
        duration = BACKGROUND_COLOR_INITIAL_ANIMATION_DURATION_MILLIS;
    } else {//w w  w  .ja v  a  2 s . c  o m
        duration = getResources().getInteger(android.R.integer.config_longAnimTime);
    }
    final int currHourColor = Utils.getCurrentHourColor(this);
    if (mLastHourColor != currHourColor) {
        final ObjectAnimator animator = ObjectAnimator.ofInt(getWindow().getDecorView(), "backgroundColor",
                mLastHourColor, currHourColor);
        animator.setDuration(duration);
        animator.setEvaluator(new ArgbEvaluator());
        animator.start();
        mLastHourColor = currHourColor;
    }
}

From source file:android.support.graphics.drawable.AnimatedVectorDrawableCompat.java

/**
 * Utility function to fix color interpolation prior to Lollipop. Without this fix, colors
 * are evaluated as raw integers instead of as colors, which leads to artifacts during
 * fillColor animations.//from w  w w. j a v a2 s .  c  o  m
 */
private void setupColorAnimator(Animator animator) {
    if (animator instanceof AnimatorSet) {
        List<Animator> childAnimators = ((AnimatorSet) animator).getChildAnimations();
        if (childAnimators != null) {
            for (int i = 0; i < childAnimators.size(); ++i) {
                setupColorAnimator(childAnimators.get(i));
            }
        }
    }
    if (animator instanceof ObjectAnimator) {
        ObjectAnimator objectAnim = (ObjectAnimator) animator;
        final String propertyName = objectAnim.getPropertyName();
        if ("fillColor".equals(propertyName) || "strokeColor".equals(propertyName)) {
            if (mArgbEvaluator == null) {
                mArgbEvaluator = new ArgbEvaluator();
            }
            objectAnim.setEvaluator(mArgbEvaluator);
        }
    }
}

From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java

private void animateIdleStateButtonAfterClick() {
    int textColorChangeDuration = 10;
    ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()),
            mIdleStateTextColorAfterClick);
    colorAnim.setDuration(textColorChangeDuration);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.start();//from w  ww  .  ja  v a2s  . c  o m

    ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick,
            getNormalColor(this.getTextColors()));
    colorAnim1.setDuration(0);
    colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration);
    colorAnim1.setEvaluator(new ArgbEvaluator());
    colorAnim1.setInterpolator(new BounceInterpolator());
    colorAnim1.start();

    ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState),
            mIdleStateBackgroundColorAfterClick);
    bgAnim.setDuration(0);
    bgAnim.setEvaluator(new ArgbEvaluator());
    bgAnim.start();

    int textSizeAnimationDuration = 150;
    ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4);
    animator.setDuration(textSizeAnimationDuration);
    animator.setRepeatCount(1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float animatedValue = (float) valueAnimator.getAnimatedValue();
            setTextSize(animatedValue);
        }
    });

    animator.start();
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

private void updateStatusBarColor() {
    if (mScroller == null || !CompatUtils.isLollipopCompatible()) {
        return;//from   ww  w.j a va2s  .  co  m
    }
    final int desiredStatusBarColor;
    // Only use a custom status bar color if QuickContacts touches the top of the viewport.
    if (mScroller.getScrollNeededToBeFullScreen() <= 0) {
        desiredStatusBarColor = mStatusBarColor;
    } else {
        desiredStatusBarColor = Color.TRANSPARENT;
    }
    // Animate to the new color.
    final ObjectAnimator animation = ObjectAnimator.ofInt(getWindow(), "statusBarColor",
            getWindow().getStatusBarColor(), desiredStatusBarColor);
    animation.setDuration(ANIMATION_STATUS_BAR_COLOR_CHANGE_DURATION);
    animation.setEvaluator(new ArgbEvaluator());
    animation.start();
}