AnimationNewUtils.java 967 Bytes
package com.wd.comment.utils;

/**
 * @Author :张泽昊
 * @Email :1064771680@qq.com
 * @Date :on 2023/8/26 20:25.
 * @Description :描述
 */
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
public class AnimationNewUtils {
    private static RotateAnimation rotateAnimation;
    public static void startRotationAnimation(View view) {
        if (rotateAnimation == null) {
            rotateAnimation = new RotateAnimation(0, 360,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotateAnimation.setDuration(1000);
            rotateAnimation.setRepeatCount(Animation.INFINITE);
        }
        view.startAnimation(rotateAnimation);
    }
    public static void stopRotationAnimation(View view) {
        if (rotateAnimation != null) {
            view.clearAnimation();
            rotateAnimation = null;
        }
    }
}