package r3;

import android.graphics.Matrix;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Field;

/* JADX INFO: loaded from: classes.dex */
public abstract class o0 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static boolean f32405b = true;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static Field f32406c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static boolean f32407d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public float[] f32408a;

    public float a(View view) {
        if (f32405b) {
            try {
                return n0.a(view);
            } catch (NoSuchMethodError unused) {
                f32405b = false;
            }
        }
        return view.getAlpha();
    }

    public void b(View view, float f10) {
        if (f32405b) {
            try {
                n0.b(view, f10);
                return;
            } catch (NoSuchMethodError unused) {
                f32405b = false;
            }
        }
        view.setAlpha(f10);
    }

    public void c(View view, int i10) {
        if (!f32407d) {
            try {
                Field declaredField = View.class.getDeclaredField("mViewFlags");
                f32406c = declaredField;
                declaredField.setAccessible(true);
            } catch (NoSuchFieldException unused) {
            }
            f32407d = true;
        }
        Field field = f32406c;
        if (field != null) {
            try {
                f32406c.setInt(view, i10 | (field.getInt(view) & (-13)));
            } catch (IllegalAccessException unused2) {
            }
        }
    }

    public void setAnimationMatrix(@NonNull View view, @Nullable Matrix matrix) {
        if (matrix == null || matrix.isIdentity()) {
            view.setPivotX(view.getWidth() / 2);
            view.setPivotY(view.getHeight() / 2);
            view.setTranslationX(0.0f);
            view.setTranslationY(0.0f);
            view.setScaleX(1.0f);
            view.setScaleY(1.0f);
            view.setRotation(0.0f);
            return;
        }
        float[] fArr = this.f32408a;
        if (fArr == null) {
            fArr = new float[9];
            this.f32408a = fArr;
        }
        matrix.getValues(fArr);
        float f10 = fArr[3];
        float fSqrt = ((float) Math.sqrt(1.0f - (f10 * f10))) * (fArr[0] < 0.0f ? -1 : 1);
        float degrees = (float) Math.toDegrees(Math.atan2(f10, fSqrt));
        float f11 = fArr[0] / fSqrt;
        float f12 = fArr[4] / fSqrt;
        float f13 = fArr[2];
        float f14 = fArr[5];
        view.setPivotX(0.0f);
        view.setPivotY(0.0f);
        view.setTranslationX(f13);
        view.setTranslationY(f14);
        view.setRotation(degrees);
        view.setScaleX(f11);
        view.setScaleY(f12);
    }
}
