@Test public void setAnimation() { TestView view = new TestView(buildActivity(Activity.class).create().get()); AlphaAnimation animation = new AlphaAnimation(0, 1); Animation.AnimationListener listener = mock(Animation.AnimationListener.class); animation.setAnimationListener(listener); animation.setStartTime(1000); view.setAnimation(animation); verifyZeroInteractions(listener); Robolectric.getForegroundThreadScheduler().advanceToNextPostedRunnable(); verify(listener).onAnimationStart(animation); verify(listener).onAnimationEnd(animation); }
float alpha = 0.5f; AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha); alphaAnimation.setStartTime(0); alphaAnimation.setDuration(0); alphaAnimation.setFillAfter(true); view.setAnimation(alphaAnimation); view.postInvalidate();`
mAnimation.setDuration(mDuration); mAnimation.setInterpolator(mInterpolator); mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); progressDrawableImageView.startAnimation(mAnimation);
/** * <p>Start the indeterminate progress animation.</p> */ void startAnimation() { if (getVisibility() != VISIBLE) { return; } if (mIndeterminateDrawable instanceof Animatable) { mShouldStartAnimationDrawable = true; mAnimation = null; } else { if (mInterpolator == null) { mInterpolator = new LinearInterpolator(); } mTransformation = new Transformation(); mAnimation = new AlphaAnimation(0.0f, 1.0f); mAnimation.setRepeatMode(mBehavior); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setDuration(mDuration); mAnimation.setInterpolator(mInterpolator); mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); } postInvalidate(); }
/** * <p>Start the indeterminate progress animation.</p> */ void startAnimation() { if (getVisibility() != VISIBLE) { return; } if (mIndeterminateDrawable instanceof Animatable) { mShouldStartAnimationDrawable = true; mAnimation = null; } else { if (mInterpolator == null) { mInterpolator = new LinearInterpolator(); } mTransformation = new Transformation(); mAnimation = new AlphaAnimation(0.0f, 1.0f); mAnimation.setRepeatMode(mBehavior); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setDuration(mDuration); mAnimation.setInterpolator(mInterpolator); mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); } postInvalidate(); }