package zj.xuitls.image; import android.graphics.drawable.Drawable; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import java.lang.reflect.Method; import zj.xuitls.common.util.LogUtil; public final class ImageAnimationHelper { private static final Method cloneMethod; static { Method method; try { method = Animation.class.getDeclaredMethod("clone", new Class[0]); method.setAccessible(true); } catch (Throwable th) { LogUtil.w(th.getMessage(), th); method = null; } cloneMethod = method; } private ImageAnimationHelper() { } public static void fadeInDisplay(ImageView imageView, Drawable drawable) { AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f); alphaAnimation.setDuration(300); alphaAnimation.setInterpolator(new DecelerateInterpolator()); imageView.setImageDrawable(drawable); imageView.startAnimation(alphaAnimation); } public static void animationDisplay(ImageView imageView, Drawable drawable, Animation animation) { imageView.setImageDrawable(drawable); Method method = cloneMethod; if (method == null || animation == null) { imageView.startAnimation(animation); return; } try { imageView.startAnimation((Animation) method.invoke(animation, new Object[0])); } catch (Throwable unused) { imageView.startAnimation(animation); } } }