package i;

import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.TypedValue;
import com.debridstream.tv.R;
import java.lang.ref.WeakReference;
import java.util.WeakHashMap;
import n.C2592t;
import x1.AbstractC3209a;

/* JADX INFO: renamed from: i.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2236c {

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final WeakHashMap f18786a = new WeakHashMap(0);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public TypedValue f18787b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f18788c;

    static {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        new C2235b(6);
    }

    public static synchronized C2236c a() {
        try {
            if (f18785d == null) {
                f18785d = new C2236c();
            }
        } catch (Throwable th) {
            throw th;
        }
        return f18785d;
    }

    public final synchronized Drawable b(Context context, long j4) {
        C2592t c2592t = (C2592t) this.f18786a.get(context);
        if (c2592t == null) {
            return null;
        }
        WeakReference weakReference = (WeakReference) c2592t.b(j4);
        if (weakReference != null) {
            Drawable.ConstantState constantState = (Drawable.ConstantState) weakReference.get();
            if (constantState != null) {
                return constantState.newDrawable(context.getResources());
            }
            c2592t.f(j4);
        }
        return null;
    }

    public final synchronized Drawable c(Context context, int i6) {
        return d(context, i6);
    }

    public final synchronized Drawable d(Context context, int i6) {
        Drawable drawableB;
        try {
            if (!this.f18788c) {
                this.f18788c = true;
                Drawable drawableC = c(context, R.drawable.abc_vector_test);
                if (drawableC == null || (!(drawableC instanceof w2.b) && !"android.graphics.drawable.VectorDrawable".equals(drawableC.getClass().getName()))) {
                    this.f18788c = false;
                    throw new IllegalStateException("This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.");
                }
            }
            if (this.f18787b == null) {
                this.f18787b = new TypedValue();
            }
            TypedValue typedValue = this.f18787b;
            context.getResources().getValue(i6, typedValue, true);
            drawableB = b(context, (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data));
            if (drawableB == null) {
                drawableB = null;
            }
            if (drawableB == null) {
                drawableB = AbstractC3209a.getDrawable(context, i6);
            }
            if (drawableB != null) {
                synchronized (this) {
                }
            }
            if (drawableB != null) {
                int[] iArr = AbstractC2234a.f18783a;
                String name = drawableB.getClass().getName();
                int i7 = Build.VERSION.SDK_INT;
                if (i7 >= 29 && i7 < 31 && "android.graphics.drawable.ColorStateListDrawable".equals(name)) {
                    int[] state = drawableB.getState();
                    if (state == null || state.length == 0) {
                        drawableB.setState(AbstractC2234a.f18783a);
                    } else {
                        drawableB.setState(AbstractC2234a.f18784b);
                    }
                    drawableB.setState(state);
                }
            }
        } finally {
        }
        return drawableB;
    }
}
