ValueAnimator setDuration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ValueAnimator setDuration method.

This code example shows how to use the following methods:addUpdateListener, setDuration, start
            if (bounceAnim == null) {
                XYHolder startXY = new XYHolder(0f, 0f);
                XYHolder endXY = new XYHolder(300f, 500f);
                bounceAnim = ObjectAnimator.ofObject(ballHolder, "xY",
                        new XYEvaluator(), endXY);
                bounceAnim.setDuration(1500);
                bounceAnim.addUpdateListener(this);
            } 
        } 
 
        public void startAnimation() { 
            createAnimation(); 
            bounceAnim.start();
        } 
 
        private ShapeHolder createBall(float x, float y) {
            OvalShape circle = new OvalShape();
            circle.resize(50f, 50f);
            ShapeDrawable drawable = new ShapeDrawable(circle);
            ShapeHolder shapeHolder = new ShapeHolder(drawable);
7
CodeRank
This code example shows how to use the following methods:addUpdateListener, setDuration, start
            if (bounceAnim == null) {
                XYHolder startXY = new XYHolder(0f, 0f);
                XYHolder endXY = new XYHolder(300f, 500f);
                bounceAnim = ObjectAnimator.ofObject(ballHolder, "xY",
                        new XYEvaluator(), endXY);
                bounceAnim.setDuration(1500);
                bounceAnim.addUpdateListener(this);
            } 
        } 
 
        public void startAnimation() { 
            createAnimation(); 
            bounceAnim.start();
        } 
 
        private ShapeHolder createBall(float x, float y) {
            OvalShape circle = new OvalShape();
            circle.resize(50f, 50f);
            ShapeDrawable drawable = new ShapeDrawable(circle);
            ShapeHolder shapeHolder = new ShapeHolder(drawable);
7
CodeRank
This code example shows how to use the following methods:addListener, addUpdateListener, setDuration, start
This code example shows how to use the following methods:addListener, addUpdateListener, setDuration, setInterpolator, start
            mAnimator.cancel();
        } 
        float from = mLeftToRight ? 0f : 1f;
        float to = mLeftToRight ? 1f : 0f;
        mAnimator = ValueAnimator.ofFloat(from, to);
        mAnimator.setDuration(DURATION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addListener(new AnimatorListenerAdapter() {
            @Override 
            public void onAnimationEnd(Animator animation) {
                mDrawDots = false;
                // make sure we draw one frame at the end with everything gone. 
                invalidate();
            } 
 
            @Override 
            public void onAnimationStart(Animator animation) {
                mDrawDots = true;
            } 
        }); 

7
CodeRank
This code example shows how to use the following methods:cancel, getAnimatedValue, getCurrentPlayTime, setDuration, setFloatValues
            } 
        }); 
    } 
 
    private void animate(int direction) {
        final long currentPlayTime = mAnimator.getCurrentPlayTime();
        final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
        final float startValue = mFirstRun ? mOriginalFromValue :
                (Float) mAnimator.getAnimatedValue();
 
        // Make sure it's stopped before we modify any values 
        cancel(); 
 
        // TODO: We don't really need to do the animation if startValue == toValue, but 
        // somehow that doesn't seem to work, possibly a quirk of the animation framework 
        mDirection = direction;
 
        // Ensure we don't calculate a non-sensical duration 
        long duration = mOriginalDuration - currentPlayTime;
        mAnimator.setDuration(Math.max(0, Math.min(duration, mOriginalDuration)));

6
CodeRank
This code example shows how to use the following methods:cancel, getAnimatedValue, getCurrentPlayTime, setDuration, setFloatValues
            } 
        }); 
    } 
 
    private void animate(int direction) {
        final long currentPlayTime = mAnimator.getCurrentPlayTime();
        final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
        final float startValue = mFirstRun ? mOriginalFromValue :
                ((Float) mAnimator.getAnimatedValue()).floatValue();
 
        // Make sure it's stopped before we modify any values 
        cancel(); 
 
        // TODO: We don't really need to do the animation if startValue == toValue, but 
        // somehow that doesn't seem to work, possibly a quirk of the animation framework 
        mDirection = direction;
 
        // Ensure we don't calculate a non-sensical duration 
        long duration = mOriginalDuration - currentPlayTime;
        mAnimator.setDuration(Math.max(0, Math.min(duration, mOriginalDuration)));

6
CodeRank
This code example shows how to use the following methods:addUpdateListener, setDuration, setInterpolator, setRepeatCount, setRepeatMode
	matrix = new Matrix();
 
	// Create animator 
 
	animator = ValueAnimator.ofFloat(0, size * 16);
	animator.setInterpolator(new LinearInterpolator());
	animator.setRepeatCount(ValueAnimator.INFINITE);
	animator.setRepeatMode(ValueAnimator.RESTART);
	animator.setDuration(10000);
	 
	animator.addUpdateListener(this);
 
	animator.start();
 
	// Create the shaders 
 
	createShaders(); 
    } 
 
    // Animation update 
7
CodeRank
This code example shows how to use the following methods:addUpdateListener, setDuration, setInterpolator, start
    } 
 
    private void createAnimation() { 
        long duration = (long) (2000 * (mUsedPercent + mOriginalPercent));
        mAnimation = ValueAnimator.ofFloat(mOriginalPercent, 0, mUsedPercent);
        mAnimation.setDuration(duration);
        mAnimation.setInterpolator(mInterpolator);
        mAnimation.addUpdateListener(this);
    } 
 
    public void start() { 
        createAnimation(); 
        mAnimation.start();
    } 
 
    public void end() { 
        if (mAnimation != null) {
            mAnimation.end();
            mAnimation = null;
        } 
5
CodeRank
This code example shows how to use the following methods:addListener, addUpdateListener, setDuration, setInterpolator, start
            mAnimator.cancel();
        } 
        float from = mLeftToRight ? 0f : 1f;
        float to = mLeftToRight ? 1f : 0f;
        mAnimator = ValueAnimator.ofFloat(from, to);
        mAnimator.setDuration(DURATION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addListener(new AnimatorListenerAdapter() {
            @Override 
            public void onAnimationEnd(Animator animation) {
                mDrawDots = false;
                // make sure we draw one frame at the end with everything gone. 
                invalidate();
            } 
 
            @Override 
            public void onAnimationStart(Animator animation) {
                mDrawDots = true;
            } 
        }); 

6
CodeRank
This code example shows how to use the following methods:addUpdateListener, setDuration, setFloatValues, setInterpolator, start
        if (button.mHintAnimationDirection == in) {
            return; 
        } 
 
        button.mHintAnimationDirection = in;
        ValueAnimator anim = new ValueAnimator();
        anim.setDuration(200);
        anim.setFloatValues(in ? 0 : 1, in ? 1 : 0);
        anim.addUpdateListener(new AnimatorUpdateListener() {
            @Override 
            public void onAnimationUpdate(ValueAnimator arg0) {
                button.mHintTextAlpha = (Float) arg0.getAnimatedValue();
                invalidate();
            } 
        }); 
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.start();
    } 
 
    public void notifyOrientationChanged(float orientation) {

6
CodeRank

Related ValueAnimator setDuration Questions & Answers:

setDuration Method Overview
Sets the length of the animation.
See Code Examples for other Android ValueAnimator Methods: