package X6FRs_4.JZJr_16;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.graphics.Matrix;
import android.os.Build;
import android.util.Log;
import android.widget.ImageView;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* compiled from: ImageViewUtils.java */
/* loaded from: classes.dex */
public class Xgtqvk_8 {
    public static Method KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static boolean f599KQgRr5e_0;

    /* compiled from: ImageViewUtils.java */
    /* loaded from: classes.dex */
    public static class KQgRr5e_0 extends AnimatorListenerAdapter {
        public final /* synthetic */ ImageView KQgRr5e_0;

        public KQgRr5e_0(ImageView imageView) {
            this.KQgRr5e_0 = imageView;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            ImageView.ScaleType scaleType = (ImageView.ScaleType) this.KQgRr5e_0.getTag(WwEq_13.save_scale_type);
            this.KQgRr5e_0.setScaleType(scaleType);
            this.KQgRr5e_0.setTag(WwEq_13.save_scale_type, null);
            if (scaleType == ImageView.ScaleType.MATRIX) {
                ImageView imageView = this.KQgRr5e_0;
                imageView.setImageMatrix((Matrix) imageView.getTag(WwEq_13.save_image_matrix));
                this.KQgRr5e_0.setTag(WwEq_13.save_image_matrix, null);
            }
            animator.removeListener(this);
        }
    }

    public static void KQgRr5e_0(ImageView imageView) {
        if (Build.VERSION.SDK_INT < 21) {
            ImageView.ScaleType scaleType = imageView.getScaleType();
            imageView.setTag(WwEq_13.save_scale_type, scaleType);
            ImageView.ScaleType scaleType2 = ImageView.ScaleType.MATRIX;
            if (scaleType == scaleType2) {
                imageView.setTag(WwEq_13.save_image_matrix, imageView.getImageMatrix());
            } else {
                imageView.setScaleType(scaleType2);
            }
            imageView.setImageMatrix(XnFJ5_9.KQgRr5e_0);
        }
    }

    public static void KQgRr5e_0(ImageView imageView, Matrix matrix) {
        if (Build.VERSION.SDK_INT < 21) {
            imageView.setImageMatrix(matrix);
            return;
        }
        KQgRr5e_0();
        Method method = KQgRr5e_0;
        if (method != null) {
            try {
                method.invoke(imageView, matrix);
            } catch (IllegalAccessException unused) {
            } catch (InvocationTargetException e) {
                throw new RuntimeException(e.getCause());
            }
        }
    }

    public static void KQgRr5e_0() {
        if (f599KQgRr5e_0) {
            return;
        }
        try {
            Method declaredMethod = ImageView.class.getDeclaredMethod("animateTransform", Matrix.class);
            KQgRr5e_0 = declaredMethod;
            declaredMethod.setAccessible(true);
        } catch (NoSuchMethodException e) {
            Log.i("ImageViewUtils", "Failed to retrieve animateTransform method", e);
        }
        f599KQgRr5e_0 = true;
    }

    public static void KQgRr5e_0(ImageView imageView, Animator animator) {
        if (Build.VERSION.SDK_INT < 21) {
            animator.addListener(new KQgRr5e_0(imageView));
        }
    }
}
