package X6FRs_4.KQgRr5e_0.KNBe_11.KQgRr5e_0;

import X6FRs_4.KQgRr5e_0.LGe8pk_15.IFxWkV_5;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import java.util.WeakHashMap;
/* compiled from: AppCompatResources.java */
/* loaded from: classes.dex */
public final class KQgRr5e_0 {

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final ThreadLocal<TypedValue> f652KQgRr5e_0 = new ThreadLocal<>();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final WeakHashMap<Context, SparseArray<C0055KQgRr5e_0>> f653KQgRr5e_0 = new WeakHashMap<>(0);
    public static final Object KQgRr5e_0 = new Object();

    /* compiled from: AppCompatResources.java */
    /* renamed from: X6FRs_4.KQgRr5e_0.KNBe_11.KQgRr5e_0.KQgRr5e_0$KQgRr5e_0  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static class C0055KQgRr5e_0 {
        public final ColorStateList KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final Configuration f654KQgRr5e_0;

        public C0055KQgRr5e_0(ColorStateList colorStateList, Configuration configuration) {
            this.KQgRr5e_0 = colorStateList;
            this.f654KQgRr5e_0 = configuration;
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static Drawable m380KQgRr5e_0(Context context, int i) {
        return IFxWkV_5.KQgRr5e_0().m394QxJ9d_1(context, i);
    }

    public static ColorStateList PGPF6hQ_2(Context context, int i) {
        if (m381KQgRr5e_0(context, i)) {
            return null;
        }
        Resources resources = context.getResources();
        try {
            return X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2.KQgRr5e_0.KQgRr5e_0(resources, resources.getXml(i), context.getTheme());
        } catch (Exception e) {
            Log.e("AppCompatResources", "Failed to inflate ColorStateList, leaving it to the framework", e);
            return null;
        }
    }

    public static ColorStateList QxJ9d_1(Context context, int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            return context.getColorStateList(i);
        }
        ColorStateList KQgRr5e_02 = KQgRr5e_0(context, i);
        if (KQgRr5e_02 != null) {
            return KQgRr5e_02;
        }
        ColorStateList PGPF6hQ_2 = PGPF6hQ_2(context, i);
        if (PGPF6hQ_2 != null) {
            KQgRr5e_0(context, i, PGPF6hQ_2);
            return PGPF6hQ_2;
        }
        return X6FRs_4.IMuAHx_6.X6FRs_4.KQgRr5e_0.m331KQgRr5e_0(context, i);
    }

    public static ColorStateList KQgRr5e_0(Context context, int i) {
        C0055KQgRr5e_0 c0055KQgRr5e_0;
        synchronized (KQgRr5e_0) {
            SparseArray<C0055KQgRr5e_0> sparseArray = f653KQgRr5e_0.get(context);
            if (sparseArray != null && sparseArray.size() > 0 && (c0055KQgRr5e_0 = sparseArray.get(i)) != null) {
                if (c0055KQgRr5e_0.f654KQgRr5e_0.equals(context.getResources().getConfiguration())) {
                    return c0055KQgRr5e_0.KQgRr5e_0;
                }
                sparseArray.remove(i);
            }
            return null;
        }
    }

    public static void KQgRr5e_0(Context context, int i, ColorStateList colorStateList) {
        synchronized (KQgRr5e_0) {
            SparseArray<C0055KQgRr5e_0> sparseArray = f653KQgRr5e_0.get(context);
            if (sparseArray == null) {
                sparseArray = new SparseArray<>();
                f653KQgRr5e_0.put(context, sparseArray);
            }
            sparseArray.append(i, new C0055KQgRr5e_0(colorStateList, context.getResources().getConfiguration()));
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m381KQgRr5e_0(Context context, int i) {
        Resources resources = context.getResources();
        TypedValue KQgRr5e_02 = KQgRr5e_0();
        resources.getValue(i, KQgRr5e_02, true);
        int i2 = KQgRr5e_02.type;
        return i2 >= 28 && i2 <= 31;
    }

    public static TypedValue KQgRr5e_0() {
        TypedValue typedValue = f652KQgRr5e_0.get();
        if (typedValue == null) {
            TypedValue typedValue2 = new TypedValue();
            f652KQgRr5e_0.set(typedValue2);
            return typedValue2;
        }
        return typedValue;
    }
}
