Example usage for android.animation ValueAnimator setRepeatCount

List of usage examples for android.animation ValueAnimator setRepeatCount

Introduction

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

Prototype

public void setRepeatCount(int value) 

Source Link

Document

Sets how many times the animation should be repeated.

Usage

From source file:Main.java

public static void setRepeatCount(ValueAnimator animator, int count) {
    animator.setRepeatCount(count);
}

From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java

private static void animateFlashText(final TextView[] textViews, int color1, int color2,
        boolean staySecondColor) {

    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), color1, color2);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        @Override//from   w  w  w.j av  a2 s  . co m
        public void onAnimationUpdate(ValueAnimator animator) {
            for (TextView textView : textViews) {
                textView.setTextColor((Integer) animator.getAnimatedValue());
            }
        }
    });
    anim.setRepeatMode(ValueAnimator.REVERSE);
    anim.setRepeatCount(staySecondColor ? 4 : 5);
    anim.setDuration(180);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.start();

}

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/*from www. java 2s  .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:org.catrobat.paintroid.ui.BottomBar.java

private void delayedAnimateSelectedTool(int startDelay) {
    ImageButton button = getToolButtonByToolType(mCurrentToolType);
    int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated);
    int fadedColor = color & 0x00ffffff;
    ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(500);/*  w  w  w  .  j a va 2s. c  o m*/
    valueAnimator.setRepeatCount(5);
    valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
    valueAnimator.setStartDelay(startDelay);
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (PaintroidApplication.currentTool != null) {
                setActivatedToolButton(PaintroidApplication.currentTool.getToolType());
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    valueAnimator.start();
}

From source file:com.example.waitou.rxjava.LoadingView.java

private void buildAnimator() {
    final ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_DURATION);
    valueAnimator.setRepeatCount(-1);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from  w w w. ja v a 2 s.  c o m*/
        public void onAnimationUpdate(ValueAnimator animation) {
            mRotation = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    animator = valueAnimator;
    animatorSet = buildFlexibleAnimation();
    animatorSet.addListener(animatorListener);
}

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   w  w  w  . j  a va  2s  . 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: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 av a 2 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:me.lizheng.deckview.views.DeckChildViewHeader.java

/**
 * Notifies the associated TaskView has been focused.
 *///from w w w.  j a  v  a 2 s  .com
void onTaskViewFocusChanged(boolean focused, boolean animateFocusedState) {
    // If we are not animating the visible state, just return
    if (!animateFocusedState)
        return;

    boolean isRunning = false;
    if (mFocusAnimator != null) {
        isRunning = mFocusAnimator.isRunning();
        DVUtils.cancelAnimationWithoutCallbacks(mFocusAnimator);
    }

    if (focused) {
        // Pulse the background color
        int currentColor = mBackgroundColor;
        int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
        ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
                lightPrimaryColor);

        backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int color = (int) animation.getAnimatedValue();
                mBackgroundColorDrawable.setColor(color);
                mBackgroundColor = color;
            }
        });

        backgroundColor.setRepeatCount(ValueAnimator.INFINITE);
        backgroundColor.setRepeatMode(ValueAnimator.REVERSE);

        // Pulse the translation
        ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 15f);
        translation.setRepeatCount(ValueAnimator.INFINITE);
        translation.setRepeatMode(ValueAnimator.REVERSE);

        mFocusAnimator = new AnimatorSet();
        mFocusAnimator.playTogether(backgroundColor, translation);
        mFocusAnimator.setStartDelay(750);
        mFocusAnimator.setDuration(750);
        mFocusAnimator.start();
    } else if (isRunning) {
        // Restore the background color
        int currentColor = mBackgroundColor;
        ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
                mCurrentPrimaryColor);
        backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int color = (int) animation.getAnimatedValue();
                mBackgroundColorDrawable.setColor(color);
                mBackgroundColor = color;
            }
        });

        // Restore the translation
        ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 0f);

        mFocusAnimator = new AnimatorSet();
        mFocusAnimator.playTogether(backgroundColor, translation);
        mFocusAnimator.setDuration(150);
        mFocusAnimator.start();
    }
}

From source file:cs.umass.edu.prepare.view.activities.CalendarActivity.java

private void transition() {
    int transitionColor = ContextCompat.getColor(this, R.color.color_transition_details_swipe);
    ValueAnimator colorAnim = ObjectAnimator.ofInt(detailsView, "backgroundColor", transitionColor,
            Color.TRANSPARENT);//from  w w w . ja  v a2  s.  c  o  m
    colorAnim.setDuration(250);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setRepeatCount(0);
    colorAnim.setRepeatMode(ValueAnimator.REVERSE);
    colorAnim.start();
}

From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) {
    super(fm);//from w  ww . ja  va2s .  c  o  m
    this.mActivity = activity;
    mPager = ((ViewPager) mActivity.findViewById(R.id.pager));
    mPager.setOnTouchListener(exitTouchListener);
    if (Build.VERSION.SDK_INT >= 17)
        rightToLeft = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1;
    if (rightToLeft) {
        List<Integer> list = Arrays.asList(colors);
        Collections.reverse(list);
        colors = (Integer[]) list.toArray();
    }
    ImageButton pagerArrow = ((ImageButton) mActivity.findViewById(R.id.pager_arrow));
    Button okButton = ((Button) mActivity.findViewById(R.id.pager_ok));
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Tutorial_5.nlEnabled) {
                final ViewGroup nlFrame = (ViewGroup) activity.findViewById(R.id.NL_frame);
                final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        Color.parseColor("#30000000"), Color.parseColor("#80FFFFFF"));
                colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        nlFrame.setBackgroundColor((int) animation.getAnimatedValue());
                    }
                });
                colorAnimation.setInterpolator(new LinearOutSlowInInterpolator());
                colorAnimation.setRepeatCount(3);
                colorAnimation.setRepeatMode(ValueAnimator.REVERSE);
                colorAnimation.setDuration(650L);
                colorAnimation.start();
            } else if (!hasClicked) {
                exitAction();
                hasClicked = true;
            }
        }
    });
    pagerArrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nextAction();
        }
    });
}