Example usage for android.animation ValueAnimator INFINITE

List of usage examples for android.animation ValueAnimator INFINITE

Introduction

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

Prototype

int INFINITE

To view the source code for android.animation ValueAnimator INFINITE.

Click Source Link

Document

This value used used with the #setRepeatCount(int) property to repeat the animation indefinitely.

Usage

From source file:Main.java

public static void startRotateAnimation(View v, int duration) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f);
    oa.setDuration(duration);/*from  www.  ja v a 2  s .com*/
    oa.setInterpolator(null);
    oa.setRepeatCount(ValueAnimator.INFINITE);
    oa.start();
}

From source file:Main.java

public static void breath(View v, float fromRange, float toRange, long duration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.ALPHA, fromRange, toRange);
    animator.setDuration(duration);// w w  w.  j  a v  a 2s .  com
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();
}

From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java

private void setupAnimators() {
    AnimatorSet set = new AnimatorSet();
    for (int i = 0; i < mSpinnerCount; i++) {
        final int index = i;
        final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE);
        sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR);
        sweepAnimator.setDuration(mSweepAnimatorDuration);
        sweepAnimator.setRepeatMode(ValueAnimator.RESTART);
        sweepAnimator.setRepeatCount(ValueAnimator.INFINITE);
        sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY);
        sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override/*from   ww w .j ava2  s. c  o m*/
            public void onAnimationUpdate(ValueAnimator animation) {
                mSpinners[index].sweepAngle = (float) animation.getAnimatedValue();
                mSpinners[index].updatePath();
                invalidateSelf();
            }
        });
        sweepAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationRepeat(Animator animation) {
                mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360;
                mSpinners[index].updatePath();
            }
        });
        set.playTogether(sweepAnimator);
    }
    mSweepAnimator = set;

    mAngleAnimator = ValueAnimator.ofFloat(0, 360);
    mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR);
    mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mAngleAnimator.setRepeatMode(ValueAnimator.RESTART);
    mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION);
    mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mGlobalAngle = (float) animation.getAnimatedValue();
            updatePath();
            invalidateSelf();
        }
    });
}

From source file:org.chromium.chrome.browser.widget.MaterialProgressBar.java

private void initialize(Context context, AttributeSet attrs, int defStyle) {
    Resources resources = context.getResources();
    int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.progress_bar_background);
    int progressColor = ApiCompatibilityUtils.getColor(resources, R.color.progress_bar_foreground);
    int secondaryProgressColor = ApiCompatibilityUtils.getColor(resources, R.color.progress_bar_secondary);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressBar, defStyle, 0);
        backgroundColor = a.getColor(R.styleable.MaterialProgressBar_colorBackground, backgroundColor);
        progressColor = a.getColor(R.styleable.MaterialProgressBar_colorProgress, progressColor);
        secondaryProgressColor = a.getColor(R.styleable.MaterialProgressBar_colorSecondaryProgress,
                secondaryProgressColor);
        a.recycle();//from ww  w  .  j a  v  a  2s. c o  m
    }

    setBackgroundColor(backgroundColor);
    setProgressColor(progressColor);
    setSecondaryProgressColor(secondaryProgressColor);

    mIndeterminateAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mIndeterminateAnimator.setDuration(INDETERMINATE_ANIMATION_DURATION_MS);
    mIndeterminateAnimator.addUpdateListener(this);
}

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/* ww w  . j  a  va2s.  c om*/
        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:com.arsy.maps_library.MapRadar.java

private void AnimateSweep() {
    mAnimatorSweep = ValueAnimator.ofInt(0, 360);
    mAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE);
    mAnimatorSweep.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//w  w w .j av a 2 s  .c  o  m
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            if (mSweepAnimationClockwiseAnticlockwise) {
                if ((mCurrentAngle) >= (360 * 2 * mSweepAnimationClockwiseAnticlockwiseDuration)) {
                    isThreeSixty = true;
                }
                if (mCurrentAngle <= 0) {
                    isThreeSixty = false;
                }
                if (isThreeSixty) {
                    mRotationAngle = (mRotationAngle - mSweepSpeed) % 360;
                    mCurrentAngle = mCurrentAngle - mSweepSpeed;
                } else {
                    mRotationAngle = (mRotationAngle + mSweepSpeed) % 360;
                    mCurrentAngle = mCurrentAngle + mSweepSpeed;
                }
            } else {
                mRotationAngle = (mRotationAngle + mSweepSpeed) % 360;
            }
            mGroundOverlaySweep.setBearing(mRotationAngle);
            if (mLatLng != mPrevLatLng) {
                mGroundOverlaySweep.setPosition(mLatLng);
            }
        }
    });
    mAnimatorSweep.start();
}

From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java

private void starAnimation() {
    View pulseView = findViewById(R.id.pulse);
    View pulseDismiss = findViewById(R.id.pulseDismiss);
    View pulseSnooze = findViewById(R.id.pulseSnooze);
    ValueAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView,
            PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f));
    pulseAnimator.setDuration(2000);//from   w w  w.  j  a v  a2  s  .c  o  m
    pulseAnimator.setRepeatCount(ValueAnimator.INFINITE);
    Interpolator interpolator = PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f);
    pulseAnimator.setInterpolator(interpolator);
    pulseAnimator.start();
    ValueAnimator dismissAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseDismiss,
            PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f));
    dismissAnimator.setDuration(1000);
    dismissAnimator.setRepeatCount(ValueAnimator.INFINITE);
    dismissAnimator.setInterpolator(interpolator);
    dismissAnimator.start();
    ValueAnimator snoozeAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseSnooze,
            PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f),
            PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f));
    snoozeAnimator.setDuration(1000);
    snoozeAnimator.setRepeatCount(ValueAnimator.INFINITE);
    snoozeAnimator.setInterpolator(interpolator);
    snoozeAnimator.start();
}

From source file:com.microsoft.mimickeralarm.mimics.ProgressButton.java

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mCenterX = w / 2;/*from  ww w . jav  a2 s  . co  m*/
    mCenterY = h / 2;
    mInitialRadius = Math.min(w, h) / 2
            - getContext().getResources().getDimensionPixelSize(R.dimen.progress_button_padding);
    mRadius = mInitialRadius;
    prepareDrawText(sWhite);

    float radius = mInitialRadius / 2f;
    mLoadingAnimationRect = new RectF(mCenterX - radius, mCenterY - radius, mCenterX + radius,
            mCenterY + radius);

    mInteractionHintAnimation = ObjectAnimator.ofFloat(this, "radius", mInitialRadius,
            mInitialRadius * INTERACTION_HINT_GROW_FACTOR, mInitialRadius);
    mInteractionHintAnimation.setDuration(INTERACTION_HINT_ANIMATION_DURATION);
    mInteractionHintAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mInteractionHintAnimation.setRepeatCount(ValueAnimator.INFINITE);
    mInteractionHintAnimation.start();
}

From source file:ch.berta.fabio.fabprogress.FabProgress.java

private void setupRotateAnimation() {
    mRotateAnim = ValueAnimator.ofFloat(0f, 360f);
    mRotateAnim.setInterpolator(LINEAR_INTERPOLATOR);
    mRotateAnim.setDuration(ROTATE_ANIMATOR_DURATION);
    mRotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from  w  w w  .  ja v  a  2s .  c  o m*/
        public void onAnimationUpdate(ValueAnimator animation) {
            float angle = getAnimatedFraction(animation) * 360f;
            updateCurrentRotationAngle(angle);
        }
    });
    mRotateAnim.setRepeatCount(ValueAnimator.INFINITE);
    mRotateAnim.setRepeatMode(ValueAnimator.RESTART);
}

From source file:com.xixicm.de.presentation.view.activity.MainActivity.java

@Override
public void updateManualFetchFabAnimator(boolean needToEnd, boolean needToStart) {
    if (mManualFetchFabAnimator == null) {
        mManualFetchFabAnimator = ObjectAnimator.ofInt(mManualFetchFab.getDrawable(), "level", 0, 10000);
        mManualFetchFabAnimator.setDuration(1000);
        mManualFetchFabAnimator.setRepeatCount(ValueAnimator.INFINITE);
    }/*from  www  .  ja va  2 s  . c o  m*/
    if (needToEnd) {
        mManualFetchFabAnimator.end();
    } else if (needToStart && !mManualFetchFabAnimator.isStarted()) {
        mManualFetchFabAnimator.start();
    }
}