List of usage examples for android.animation ValueAnimator setRepeatMode
public void setRepeatMode(@RepeatMode int value)
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/*ww w . j a va2s .com*/ 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 w ww. j av a 2 s .co m*/ 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: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/*w w w . java2s. co 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.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);//from w w w . ja v a 2 s . co 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: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 ww w. ja v a 2 s . c o m colorAnim.setDuration(250); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setRepeatCount(0); colorAnim.setRepeatMode(ValueAnimator.REVERSE); colorAnim.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. c o m*/ 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:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java
public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) { super(fm);//from w ww. j ava 2 s.c om 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(); } }); }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void animateIdleStateButtonAfterClick() { int textColorChangeDuration = 10; ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()), mIdleStateTextColorAfterClick); colorAnim.setDuration(textColorChangeDuration); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start();/*from w w w .j a v a 2s.c o m*/ ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick, getNormalColor(this.getTextColors())); colorAnim1.setDuration(0); colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration); colorAnim1.setEvaluator(new ArgbEvaluator()); colorAnim1.setInterpolator(new BounceInterpolator()); colorAnim1.start(); ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState), mIdleStateBackgroundColorAfterClick); bgAnim.setDuration(0); bgAnim.setEvaluator(new ArgbEvaluator()); bgAnim.start(); int textSizeAnimationDuration = 150; ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4); animator.setDuration(textSizeAnimationDuration); animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); setTextSize(animatedValue); } }); animator.start(); }
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
/** * @param anim The animator, must not be null * @param arrayAnimator Incoming typed array for Animator's attributes. * @param arrayObjectAnimator Incoming typed array for Object Animator's * attributes. * @param pixelSize The relative pixel size, used to calculate the * maximum error for path animations. */// w w w . ja v a 2s . c o m private static void parseAnimatorFromTypeArray(ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator, float pixelSize, XmlPullParser parser) { long duration = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "duration", AndroidResources.STYLEABLE_ANIMATOR_DURATION, 300); long startDelay = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "startOffset", AndroidResources.STYLEABLE_ANIMATOR_START_OFFSET, 0); int valueType = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "valueType", AndroidResources.STYLEABLE_ANIMATOR_VALUE_TYPE, VALUE_TYPE_UNDEFINED); // Change to requiring both value from and to, otherwise, throw exception for now. if (TypedArrayUtils.hasAttribute(parser, "valueFrom") && TypedArrayUtils.hasAttribute(parser, "valueTo")) { if (valueType == VALUE_TYPE_UNDEFINED) { valueType = inferValueTypeFromValues(arrayAnimator, AndroidResources.STYLEABLE_ANIMATOR_VALUE_FROM, AndroidResources.STYLEABLE_ANIMATOR_VALUE_TO); } PropertyValuesHolder pvh = getPVH(arrayAnimator, valueType, AndroidResources.STYLEABLE_ANIMATOR_VALUE_FROM, AndroidResources.STYLEABLE_ANIMATOR_VALUE_TO, ""); if (pvh != null) { anim.setValues(pvh); } } anim.setDuration(duration); anim.setStartDelay(startDelay); anim.setRepeatCount(TypedArrayUtils.getNamedInt(arrayAnimator, parser, "repeatCount", AndroidResources.STYLEABLE_ANIMATOR_REPEAT_COUNT, 0)); anim.setRepeatMode(TypedArrayUtils.getNamedInt(arrayAnimator, parser, "repeatMode", AndroidResources.STYLEABLE_ANIMATOR_REPEAT_MODE, ValueAnimator.RESTART)); if (arrayObjectAnimator != null) { setupObjectAnimator(anim, arrayObjectAnimator, valueType, pixelSize, parser); } }
From source file:com.gu.swiperefresh.ProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final ValueAnimator animator = ObjectAnimator.ofFloat(0f, 1f); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from www .j a va 2 s .co m*/ public void onAnimationUpdate(ValueAnimator animation) { float interpolatedTime = Float.valueOf(animation.getAnimatedValue().toString()); if (mFinishing) { applyFinishTranslation(interpolatedTime, ring); } else { // The minProgressArc is calculated from 0 to create an // angle that matches the stroke width. final float minProgressArc = getMinProgressArc(ring); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); updateRingColor(interpolatedTime, ring); // Moving the start trim only occurs in the first 50% of a // single ring animation if (interpolatedTime <= START_TRIM_DURATION_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET); final float startTrim = startingTrim + ((MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setStartTrim(startTrim); } // Moving the end trim starts after 50% of a single ring // animation completes if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time final float minArc = MAX_PROGRESS_ARC - minProgressArc; float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setEndTrim(endTrim); } final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((FULL_ROTATION / NUM_POINTS) * interpolatedTime) + (FULL_ROTATION * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } } }); animator.setRepeatCount(Animation.INFINITE); animator.setRepeatMode(ValueAnimator.RESTART); animator.setInterpolator(LINEAR_INTERPOLATOR); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationStart(Animator animation) { mRotationCount = 0; } @Override public void onAnimationRepeat(Animator animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); if (mFinishing) { // finished closing the last ring from the swipe gesture; go // into progress mode mFinishing = false; animation.setDuration(ANIMATION_DURATION); ring.setShowArrow(false); } else { mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } } }); mAnimation = animator; }