com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener Java Examples

The following examples show how to use com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener. 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: PlayerDiscView.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
private void startDiscAnimator(float animatedValue) {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", animatedValue, 360 + animatedValue);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_ANIMATOR_TIME);
    mDiscLayoutAnimator.setRepeatCount(DISC_ANIMATOR_REPEAT_COUNT);
    mDiscLayoutAnimator.setInterpolator(new LinearInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
 
Example #2
Source File: PlayerDiscView.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
private void reverseDiscAnimator() {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", mDiscLayoutAnimatorValue, 360);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_REVERSE_ANIMATOR_TIME);
    mDiscLayoutAnimator.setInterpolator(new AccelerateInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
 
Example #3
Source File: DemoActivity_1.java    From android-art-res with Apache License 2.0 6 votes vote down vote up
private void performAnimate(final View target, final int start, final int end) {
    ValueAnimator valueAnimator = ValueAnimator.ofInt(1, 100);
    valueAnimator.addUpdateListener(new AnimatorUpdateListener() {

        // 持有一个IntEvaluator对象,方便下面估值的时候使用
        private IntEvaluator mEvaluator = new IntEvaluator();

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            // 获得当前动画的进度值,整型,1-100之间
            int currentValue = (Integer) animator.getAnimatedValue();
            Log.d(TAG, "current value: " + currentValue);

            // 获得当前进度占整个动画过程的比例,浮点型,0-1之间
            float fraction = animator.getAnimatedFraction();
            // 直接调用整型估值器通过比例计算出宽度,然后再设给Button
            target.getLayoutParams().width = mEvaluator.evaluate(fraction, start, end);
            target.requestLayout();
        }
    });

    valueAnimator.setDuration(5000).start();
}
 
Example #4
Source File: FancyProgress2.java    From FancyProgress with Apache License 2.0 6 votes vote down vote up
public FancyProgress2 show(){
	setVisibility(View.VISIBLE);
	mAnim = ValueAnimator.ofFloat(1.0f);
	mAnim.setInterpolator(new LinearInterpolator());
	mAnim.setDuration(2000);
	mAnim.setRepeatCount(ValueAnimator.INFINITE);
	mAnim.addUpdateListener(new AnimatorUpdateListener() {
		
		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			mPercent = animation.getAnimatedFraction();
			isFront = mPercent < 0.5f;
			invalidate();
		}
	});
	mAnim.start();
	invalidate();
	
	return this;
}
 
Example #5
Source File: CardFaceView.java    From CardView with Apache License 2.0 6 votes vote down vote up
private void onFlagChanged(final CardFlag oldFlag, final CardFlag newFlag) {
	int flagColor = CARD_BACKGROUND_COLOR_NOFLAG;
	if (newFlag != null) {
		flagColor = newFlag.getColor();
	}
	
	ValueAnimator fade = ObjectAnimator.ofInt(mCardPaint,
			"color", mCardPaint.getColor(), flagColor);
	fade.setDuration(500);
	fade.setEvaluator(new ArgbEvaluator());
	fade.addUpdateListener(new AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator value) {
			onFlagChangedUpdate(oldFlag, newFlag, value);
			invalidate();
		}
	});
	
	fade.start();
}
 
Example #6
Source File: TransferControlView.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: RoundProgressBar.java    From Conquer with Apache License 2.0 5 votes vote down vote up
/**
     * 设置进度,此为线程安全控件,由于考虑多线的问题,需要同步 刷新界面调用postInvalidate()能在非UI线程刷新
     *
     * @param progress
     */

    public synchronized void setProgress(int progress) {
        if (this.progress == progress) {
            return;
        }

//        hasShowing = true;
        if (progress < 0) {
//			throw new IllegalArgumentException("progress not less than 0");
            return;
        }
        if (progress > max) {
            progress = max;
        }
        ValueAnimator va = ValueAnimator.ofInt(this.progress, progress);
        va.setDuration(1000);
        va.setInterpolator(new AccelerateInterpolator());
        va.start();
        va.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator arg0) {
                int value = (Integer) arg0.getAnimatedValue();
                if (value <= max) {
                    RoundProgressBar.this.progress = value;
                    invalidate();
                }
            }
        });

    }
 
Example #8
Source File: FancyProgress4.java    From FancyProgress with Apache License 2.0 5 votes vote down vote up
public void show(){
	mAnim = ValueAnimator.ofFloat(1.0f);
	mAnim.addUpdateListener(new AnimatorUpdateListener() {
		
		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			mPercent = animation.getAnimatedFraction();
			invalidate();
		}
	});
	mAnim.setInterpolator(new LinearInterpolator());
	mAnim.setRepeatCount(ValueAnimator.INFINITE);
	mAnim.setDuration(mOneShotDuration * 4);
	mAnim.start();
}