List of usage examples for android.view.animation RotateAnimation setAnimationListener
public void setAnimationListener(AnimationListener listener)
Binds an animation listener to this animation.
From source file:Main.java
public static void animateRotate(final View animated, float fromDegrees, float toDegrees, AnimationListener listener) {//from w w w . j av a 2s .c o m if (animated == null) { return; } final RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, animated.getWidth() / 2, animated.getHeight() / 2); rotate.setDuration(ANIMATION_DURATION); rotate.setAnimationListener(listener); animated.startAnimation(rotate); }
From source file:Main.java
public static RotateAnimation getRotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue, long durationMillis, AnimationListener animationListener) { RotateAnimation rotateAnimation = new RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue);// w w w . j a v a2 s . c o m rotateAnimation.setDuration(durationMillis); if (animationListener != null) { rotateAnimation.setAnimationListener(animationListener); } return rotateAnimation; }
From source file:Main.java
public static void startRepeatSelfRotateAnimation(View v, long duration, Animation.AnimationListener listener) { RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(duration);/*from w w w . jav a2 s . co m*/ animation.setRepeatCount(-1); // Repeat animation animation.setFillAfter(true); animation.setRepeatMode(Animation.INFINITE); // LinearInterpolator lir = new LinearInterpolator(); animation.setInterpolator(lir); if (listener != null) { animation.setAnimationListener(listener); } v.startAnimation(animation); }
From source file:Main.java
public static void shakeAnimation(final View v) { float rotate = 0; int c = mCount++ % 5; if (c == 0) { rotate = DEGREE_0;/*from www. j av a 2s . com*/ } else if (c == 1) { rotate = DEGREE_1; } else if (c == 2) { rotate = DEGREE_2; } else if (c == 3) { rotate = DEGREE_3; } else { rotate = DEGREE_4; } final RotateAnimation mra = new RotateAnimation(rotate, -rotate, ICON_WIDTH * mDensity / 2, ICON_HEIGHT * mDensity / 2); final RotateAnimation mrb = new RotateAnimation(-rotate, rotate, ICON_WIDTH * mDensity / 2, ICON_HEIGHT * mDensity / 2); mra.setDuration(ANIMATION_DURATION); mrb.setDuration(ANIMATION_DURATION); mra.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mNeedShake) { mra.reset(); v.startAnimation(mrb); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); mrb.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mNeedShake) { mrb.reset(); v.startAnimation(mra); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); v.startAnimation(mra); }