Java Code Examples for android.animation.ValueAnimator#setRepeatCount()
The following examples show how to use
android.animation.ValueAnimator#setRepeatCount() .
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: ProgressIndicatorView.java From 920-text-editor-v2 with Apache License 2.0 | 6 votes |
public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); int[] delays = new int[]{120, 240, 360}; for (int i = 0; i < 3; i++) { final int index = i; ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1); scaleAnim.setDuration(750); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); scaleAnim.start(); animators.add(scaleAnim); } return animators; }
Example 2
Source File: Pulse.java From mkloader with Apache License 2.0 | 6 votes |
@Override public void setUpAnimation() { for (int i = 0; i < numberOfLines; i++) { final int index = i; ValueAnimator scaleAnimator = ValueAnimator.ofFloat(1f, 1.5f, 1f); scaleAnimator.setDuration(1000); scaleAnimator.setStartDelay(i * 120); scaleAnimator.setRepeatCount(ValueAnimator.INFINITE); scaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleY[index] = (float)animation.getAnimatedValue(); if (invalidateListener != null) { invalidateListener.reDraw(); } } }); scaleAnimator.start(); } }
Example 3
Source File: BallGridBeatIndicator.java From LazyRecyclerAdapter with MIT License | 6 votes |
@Override public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); int[] durations = {960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190}; int[] delays = {360, 400, 680, 410, 710, -150, -120, 10, 320}; for (int i = 0; i < 9; i++) { final int index = i; ValueAnimator alphaAnim = ValueAnimator.ofInt(255, 168, 255); alphaAnim.setDuration(durations[i]); alphaAnim.setRepeatCount(-1); alphaAnim.setStartDelay(delays[i]); alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { alphas[index] = (int) animation.getAnimatedValue(); postInvalidate(); } }); alphaAnim.start(); animators.add(alphaAnim); } return animators; }
Example 4
Source File: OvercastType.java From FakeWeather with Apache License 2.0 | 6 votes |
@Override public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) { super.endAnimation(dynamicWeatherView, listener); ValueAnimator animator = ValueAnimator.ofFloat(1, -1); animator.setDuration(1000); animator.setRepeatCount(0); animator.setInterpolator(new AccelerateInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { hillTransFactor = (float) animation.getAnimatedValue(); } }); if (listener != null) { animator.addListener(listener); } animator.start(); }
Example 5
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
private ValueAnimator animatePointer(long orbitDuration) { ValueAnimator anim = ValueAnimator.ofInt(0, 359); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) imgPointer.getLayoutParams(); layoutParams.circleAngle = val; imgPointer.setLayoutParams(layoutParams); } }); anim.setDuration(orbitDuration); anim.setInterpolator(new LinearInterpolator()); anim.setRepeatMode(ValueAnimator.RESTART); anim.setRepeatCount(ValueAnimator.INFINITE); return anim; }
Example 6
Source File: BallPulseSyncIndicator.java From LRecyclerView with Apache License 2.0 | 6 votes |
@Override public ArrayList<ValueAnimator> onCreateAnimators() { ArrayList<ValueAnimator> animators=new ArrayList<>(); float circleSpacing=4; float radius=(getWidth()-circleSpacing*2)/6; int[] delays=new int[]{70,140,210}; for (int i = 0; i < 3; i++) { final int index=i; ValueAnimator scaleAnim= ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2); scaleAnim.setDuration(600); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { translateYFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); animators.add(scaleAnim); } return animators; }
Example 7
Source File: BallPulseRiseIndicator.java From LRecyclerView with Apache License 2.0 | 6 votes |
@Override public ArrayList<ValueAnimator> onCreateAnimators() { ArrayList<ValueAnimator> animators=new ArrayList<>(); ValueAnimator animator= ValueAnimator.ofFloat(0,360); addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { degress = (float) animation.getAnimatedValue(); postInvalidate(); } }); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(-1); animator.setDuration(1500); animators.add(animator); return animators; }
Example 8
Source File: LineScalePulseOutIndicator.java From LazyRecyclerAdapter with MIT License | 6 votes |
@Override public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); long[] delays = new long[]{500, 250, 0, 250, 500}; for (int i = 0; i < 5; i++) { final int index = i; ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1); scaleAnim.setDuration(900); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleYFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); scaleAnim.start(); animators.add(scaleAnim); } return animators; }
Example 9
Source File: TwinFishesSpinner.java From mkloader with Apache License 2.0 | 6 votes |
@Override public void setUpAnimation() { for (int i = 0; i < numberOfCircle; i++) { final int index = i; ValueAnimator fadeAnimator = ValueAnimator.ofFloat(0, 360); fadeAnimator.setRepeatCount(ValueAnimator.INFINITE); fadeAnimator.setDuration(1700); fadeAnimator.setStartDelay((index >= 5 ? index - 5 : index) * 100); fadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { rotates[index] = (float)animation.getAnimatedValue(); if (invalidateListener != null) { invalidateListener.reDraw(); } } }); fadeAnimator.start(); } }
Example 10
Source File: LineSpinner.java From mkloader with Apache License 2.0 | 6 votes |
@Override public void setUpAnimation() { for (int i = 0; i < numberOfLine; i++) { final int index = i; ValueAnimator fadeAnimator = ValueAnimator.ofInt(126, 255, 126); fadeAnimator.setRepeatCount(ValueAnimator.INFINITE); fadeAnimator.setDuration(1000); fadeAnimator.setStartDelay(index * 120); fadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { lines[index].setAlpha((int)animation.getAnimatedValue()); if (invalidateListener != null) { invalidateListener.reDraw(); } } }); fadeAnimator.start(); } }
Example 11
Source File: DownloadProgressButton.java From DownloadProgressButton with Apache License 2.0 | 6 votes |
public ArrayList<ValueAnimator> createBallPulseAnimators() { ArrayList<ValueAnimator> animators = new ArrayList<>(); int[] delays = new int[]{120, 240, 360}; for (int i = 0; i < 3; i++) { final int index = i; ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1); scaleAnim.setDuration(750); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); animators.add(scaleAnim); } return animators; }
Example 12
Source File: MainActivity.java From ProgressableImageView with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressableImageView = findViewById(R.id.top); ValueAnimator firstProgress = ValueAnimator.ofInt(0, 100); firstProgress.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animatedValue = (int) animation.getAnimatedValue(); /*int value = animatedValue / 20; int[] colors = getResources().getIntArray(R.array.rainbow); if (value >= colors.length) return; int color = colors[value]; progressableImageView.setDividerColor(color);*/ //float value = (float)animatedValue / 5; //progressableImageView.setDividerWidthAsDp(animatedValue); float value = (float)animatedValue / 100; progressableImageView.setProgress(value); } }); //progressableImageView.setDirection(ProgressDirection.bottom_to_top); firstProgress.setDuration(2500); firstProgress.setRepeatMode(ValueAnimator.REVERSE); firstProgress.setRepeatCount(ValueAnimator.INFINITE); //firstProgress.start(); }
Example 13
Source File: OilTableLine.java From OXChart with Apache License 2.0 | 5 votes |
public void startAnimator() { ValueAnimator animator = ValueAnimator.ofFloat(0, 240); animator.setDuration(40000); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.RESTART); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mCurrentDegree = (int) (0 + (Float) animation.getAnimatedValue()); invalidate(); } }); animator.start(); }
Example 14
Source File: LoadingView.java From star-zone-android with Apache License 2.0 | 5 votes |
private ValueAnimator createAnimator(Interpolator interpolator, long duration) { ValueAnimator animator = ValueAnimator.ofFloat(0, 180f); animator.setInterpolator(interpolator == null ? defaultInterpolator : interpolator); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.RESTART); animator.setDuration(duration == 0 ? DEFAULT_DURATION : duration); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { currentDegree = (float) animation.getAnimatedValue(); invalidate(); } }); return animator; }
Example 15
Source File: SampleActivity.java From CompositionAvatar with MIT License | 5 votes |
private void dynamicGap(CompositionAvatarView view) { ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.setDuration(2000); animator.setStartDelay(1000); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setRepeatMode(ValueAnimator.REVERSE); animator.setRepeatCount(ValueAnimator.INFINITE); animator.addUpdateListener(animation -> view.setGap((Float) animation.getAnimatedValue())); mGapAnimator = animator; }
Example 16
Source File: ElevationAnimationDemoFragment.java From material-components-android with Apache License 2.0 | 5 votes |
private void startTranslationZAnimation( View view, MaterialShapeDrawable materialShapeDrawable, float maxTranslationZ) { ValueAnimator animator = ValueAnimator.ofFloat(0, maxTranslationZ); animator.setDuration(ANIMATION_DURATION_MILLIS); animator.setStartDelay(ANIMATION_START_DELAY_MILLIS); animator.setRepeatMode(ValueAnimator.RESTART); animator.setRepeatCount(ValueAnimator.INFINITE); animator.addUpdateListener( animation -> setTranslationZ(view, materialShapeDrawable, (float) animation.getAnimatedValue())); animator.start(); }
Example 17
Source File: PasswordInput.java From PasswordInput with Apache License 2.0 | 5 votes |
/** * 开始FocusChanged动画 * * @param focused 是否获得焦点 */ private void startFocusChangedAnim(final boolean focused) { final ValueAnimator scanAnim; scanAnim = ValueAnimator.ofFloat(1F, 0.1F, 1F); scanAnim.setDuration(750); scanAnim.setRepeatCount(0); scanAnim.setInterpolator(new AccelerateDecelerateInterpolator()); scanAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float scale = (float) valueAnimator.getAnimatedValue(); for (int i = 0; i < scans.length; i++) { if (scans[i] != 0) { scans[i] = scale; } } if (scale <= 0.15) { if (focused) { mBorderPaint.setColor(borderFocusedColor); mDotPaint.setColor(dotFocusedColor); } else { mBorderPaint.setColor(borderNotFocusedColor); mDotPaint.setColor(dotNotFocusedColor); } } postInvalidate(); } }); scanAnim.start(); }
Example 18
Source File: DotLoader.java From DotLoader with Apache License 2.0 | 5 votes |
private ValueAnimator createValueAnimatorForDot(final Dot dot) { ValueAnimator animator = ValueAnimator.ofFloat( mFromY, mToY ); animator.setInterpolator(bounceAnimationInterpolator); animator.setDuration(BOUNCE_ANIMATION_DURATION); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new DotYUpdater(dot, this)); animator.addListener(new AnimationRepeater(dot, mColors)); return animator; }
Example 19
Source File: LoadingView.java From TigerVideo with Apache License 2.0 | 5 votes |
private void createBallAnimator(Ball ball, int startDelay) { ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setFloatValues(mMinRadius, mMaxRadius); valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); valueAnimator.setDuration(mDuration); valueAnimator.addUpdateListener(new BallUpdateListener(ball)); valueAnimator.setRepeatMode(ValueAnimator.REVERSE); valueAnimator.setRepeatCount(ValueAnimator.INFINITE); valueAnimator.setStartDelay(startDelay); mBallAnimators.add(valueAnimator); valueAnimator.start(); }
Example 20
Source File: TypingIndicator.java From SendBird-Android with MIT License | 4 votes |
/** * Animates all dots in sequential order. */ @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB) public void animate() { int startDelay = 0; mAnimSet = new AnimatorSet(); for (int i = 0; i < mImageViewList.size(); i++) { ImageView dot = mImageViewList.get(i); // ValueAnimator bounce = ObjectAnimator.ofFloat(dot, "y", mAnimMagnitude); ValueAnimator fadeIn = ObjectAnimator.ofFloat(dot, "alpha", 1f, 0.5f); ValueAnimator scaleX = ObjectAnimator.ofFloat(dot, "scaleX", 1f, 0.7f); ValueAnimator scaleY = ObjectAnimator.ofFloat(dot, "scaleY", 1f, 0.7f); fadeIn.setDuration(mAnimDuration); fadeIn.setInterpolator(new AccelerateDecelerateInterpolator()); fadeIn.setRepeatMode(ValueAnimator.REVERSE); fadeIn.setRepeatCount(ValueAnimator.INFINITE); scaleX.setDuration(mAnimDuration); scaleX.setInterpolator(new AccelerateDecelerateInterpolator()); scaleX.setRepeatMode(ValueAnimator.REVERSE); scaleX.setRepeatCount(ValueAnimator.INFINITE); scaleY.setDuration(mAnimDuration); scaleY.setInterpolator(new AccelerateDecelerateInterpolator()); scaleY.setRepeatMode(ValueAnimator.REVERSE); scaleY.setRepeatCount(ValueAnimator.INFINITE); // bounce.setDuration(mAnimDuration); // bounce.setInterpolator(new AccelerateDecelerateInterpolator()); // bounce.setRepeatMode(ValueAnimator.REVERSE); // bounce.setRepeatCount(ValueAnimator.INFINITE); // mAnimSet.play(bounce).after(startDelay); mAnimSet.play(fadeIn).after(startDelay); mAnimSet.play(scaleX).with(fadeIn); mAnimSet.play(scaleY).with(fadeIn); mAnimSet.setStartDelay(500); startDelay += (mAnimDuration / (mImageViewList.size() - 1)); } mAnimSet.start(); }