Java Code Examples for android.animation.ValueAnimator#setIntValues()

The following examples show how to use android.animation.ValueAnimator#setIntValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonthWeekMaterialCalendarView.java    From monthweekmaterialcalendarview with Apache License 2.0 6 votes vote down vote up
private void setUpdateBottomAndTopAnimator(int fromY, int toY, long duration, final SlideOffsetAnimatorlistener listener) {
        ValueAnimator animator = new ValueAnimator();
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
//        animator.setEvaluator(new TypeEvaluator<Integer>() {
//            @Override
//            public Integer evaluate(float fraction, Integer start, Integer end) {
//                return (int) (start + (end - start) * fraction);
//            }
//        });
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                if (listener != null) {
                    listener.onAnimationUpdate(valueAnimator);
                }
            }
        });
        animator.setIntValues(fromY, toY);
        animator.setDuration(duration);
        animator.start();
    }
 
Example 2
Source File: SLTouchListener.java    From SphereLayout with MIT License 6 votes vote down vote up
public SLTouchListener(SphereLayout sphereLayout) {
    mSphereLayout = sphereLayout;
    mTouchSlop = ViewConfiguration.get(mSphereLayout.getContext()).getScaledTouchSlop();
    mInterpolator = new SpringInterpolator();
    mState = new RotateState();

    mRotateAnimator = new ValueAnimator();
    mRotateAnimator.setInterpolator(mInterpolator);
    mRotateAnimator.setIntValues(MAX_ROTATE_DEGREE, 0);
    mRotateAnimator.setDuration(DURATION);

    mRotateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mState.rotateDegree = (Integer) animation.getAnimatedValue();
            mSphereLayout.rotate(mState.direction, mState.rotateDegree);
        }
    });

    mFixAnimator = new ValueAnimator();
    mFixAnimator.setInterpolator(new DecelerateInterpolator());
}
 
Example 3
Source File: LineFadeIndicator.java    From Dachshund-Tab-Layout with MIT License 6 votes vote down vote up
public LineFadeIndicator(DachshundTabLayout dachshundTabLayout) {
    this.dachshundTabLayout = dachshundTabLayout;

    valueAnimator = new ValueAnimator();
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(DEFAULT_DURATION);
    valueAnimator.addUpdateListener(this);
    valueAnimator.setIntValues(0,255);

    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);

    rectF = new RectF();

    startXLeft = (int) dachshundTabLayout.getChildXLeft(dachshundTabLayout.getCurrentPosition());
    startXRight = (int) dachshundTabLayout.getChildXRight(dachshundTabLayout.getCurrentPosition());

    edgeRadius = -1;
}
 
Example 4
Source File: AnimationUtils.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
private static void startBackgroundColorAnimation(final View view, int startColor, int endColor, int duration) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, endColor);
    anim.setEvaluator(new ArgbEvaluator());
    anim.setDuration(duration);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            view.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        }
    });
    anim.start();
}
 
Example 5
Source File: AnimationUtils.java    From SearchPreference with MIT License 5 votes vote down vote up
private static void startColorAnimation(final View view, final int startColor, final int endColor, int duration) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, endColor);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            view.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        }
    });
    anim.setDuration(duration);
    anim.start();
}
 
Example 6
Source File: PointFadeIndicator.java    From Dachshund-Tab-Layout with MIT License 5 votes vote down vote up
public PointFadeIndicator(DachshundTabLayout dachshundTabLayout) {
    this.dachshundTabLayout = dachshundTabLayout;

    valueAnimator = new ValueAnimator();
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(DEFAULT_DURATION);
    valueAnimator.addUpdateListener(this);
    valueAnimator.setIntValues(0,255);

    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);

    startX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
}
 
Example 7
Source File: BottomBarTab.java    From BottomBar with Apache License 2.0 5 votes vote down vote up
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
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setColors((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim.setDuration(150);
    anim.start();
}
 
Example 8
Source File: LyricView.java    From RhymeMusic with Apache License 2.0 5 votes vote down vote up
private void initView()
{
    mPaint = new TextPaint();
    mPaint.setTextSize(mTextSize);
    mPaint.setTextAlign(Align.CENTER);
    mPaint.setAntiAlias(true);

    // 计算字体高度
    FontMetrics fm = mPaint.getFontMetrics();
    mTextHeight = (int) (fm.bottom - fm.top);

    // 滚动动画
    mLineAnimator = new ValueAnimator();
    mLineAnimator.setIntValues(0, 100);
    mLineAnimator.setDuration(mLineAnimDuration);
    mLineAnimator.addUpdateListener(new AnimatorUpdateListener()
    {
        @Override
        public void onAnimationUpdate(ValueAnimator animation)
        {
            int value = (Integer) animation.getAnimatedValue();
            float percent = 1 - (float) value / 100;
            mLineOffset = (int) (mAnimOffset * percent); // 更新偏移值,重绘View
            invalidate();
        }
    });
}
 
Example 9
Source File: Actions.java    From AndroidAnimationsActions with MIT License 5 votes vote down vote up
/**
 * Runs specified runnable
 *
 * @param runnable runnable to run
 */
@NonNull
public static Animator run(@NonNull final Runnable runnable) {
    ValueAnimator animator = new ValueAnimator();
    animator.setIntValues(1);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            runnable.run();
        }
    });
    return animator;
}
 
Example 10
Source File: Actions.java    From AndroidAnimationsActions with MIT License 5 votes vote down vote up
/**
 * Inserts pause to sequence with specified duration
 *
 * @param duration duration in seconds
 */
@NonNull
public static Animator delay(float duration) {
    ValueAnimator animator = new ValueAnimator();
    setPropertiesForAnimator(animator, duration, null);
    animator.setIntValues(1);
    return animator;
}
 
Example 11
Source File: PulsateAnimation.java    From Kore with Apache License 2.0 5 votes vote down vote up
private ValueAnimator createValueAnimator(int startColor, int endColor) {
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setDuration(1000);
    valueAnimator.setIntValues(startColor, endColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            int color = (int) animator.getAnimatedValue();
            view.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        }
    });
    return valueAnimator;
}
 
Example 12
Source File: BasePermissionActivity.java    From PermissionHelper with Apache License 2.0 5 votes vote down vote up
private void animateColorChange(final View view, final int color) {
    ValueAnimator animator = new ValueAnimator();
    animator.setIntValues(((ColorDrawable) view.getBackground()).getColor(), color);
    animator.setEvaluator(new ArgbEvaluator());
    animator.setDuration(600);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setBackgroundColor((Integer) animation.getAnimatedValue());
            onStatusBarColorChange((Integer) animation.getAnimatedValue());
        }
    });
    animator.start();
}
 
Example 13
Source File: AnimatedDrawable2ValueAnimatorHelper.java    From fresco with MIT License 5 votes vote down vote up
public static ValueAnimator createValueAnimator(AnimatedDrawable2 animatedDrawable) {
  int loopCount = animatedDrawable.getLoopCount();
  ValueAnimator animator = new ValueAnimator();
  animator.setIntValues(0, (int) animatedDrawable.getLoopDurationMs());
  animator.setDuration(animatedDrawable.getLoopDurationMs());
  animator.setRepeatCount(
      loopCount != AnimationInformation.LOOP_COUNT_INFINITE ? loopCount : ValueAnimator.INFINITE);
  animator.setRepeatMode(ValueAnimator.RESTART);
  // Use a linear interpolator
  animator.setInterpolator(null);
  ValueAnimator.AnimatorUpdateListener animatorUpdateListener =
      createAnimatorUpdateListener(animatedDrawable);
  animator.addUpdateListener(animatorUpdateListener);
  return animator;
}