package c.b.f;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import c.f.c.b.k;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: compiled from: TintTypedArray.java */
/* JADX INFO: loaded from: classes.dex */
public class d1 {
    public final Context a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final TypedArray f806b;

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

    public d1(Context context, TypedArray typedArray) {
        this.a = context;
        this.f806b = typedArray;
    }

    public static d1 n(Context context, AttributeSet attributeSet, int[] iArr) {
        return new d1(context, context.obtainStyledAttributes(attributeSet, iArr));
    }

    public static d1 o(Context context, AttributeSet attributeSet, int[] iArr, int i2, int i3) {
        return new d1(context, context.obtainStyledAttributes(attributeSet, iArr, i2, i3));
    }

    public boolean a(int i2, boolean z) {
        return this.f806b.getBoolean(i2, z);
    }

    public ColorStateList b(int i2) {
        int resourceId;
        ColorStateList colorStateListD;
        return (!this.f806b.hasValue(i2) || (resourceId = this.f806b.getResourceId(i2, 0)) == 0 || (colorStateListD = c.b.a.d(this.a, resourceId)) == null) ? this.f806b.getColorStateList(i2) : colorStateListD;
    }

    public int c(int i2, int i3) {
        return this.f806b.getDimensionPixelOffset(i2, i3);
    }

    public int d(int i2, int i3) {
        return this.f806b.getDimensionPixelSize(i2, i3);
    }

    public Drawable e(int i2) {
        int resourceId;
        return (!this.f806b.hasValue(i2) || (resourceId = this.f806b.getResourceId(i2, 0)) == 0) ? this.f806b.getDrawable(i2) : c.b.a.e(this.a, resourceId);
    }

    public Drawable f(int i2) {
        int resourceId;
        Drawable drawableF;
        if (!this.f806b.hasValue(i2) || (resourceId = this.f806b.getResourceId(i2, 0)) == 0) {
            return null;
        }
        m mVarA = m.a();
        Context context = this.a;
        synchronized (mVarA) {
            drawableF = mVarA.f895c.f(context, resourceId, true);
        }
        return drawableF;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r13v10 */
    /* JADX WARN: Type inference failed for: r13v11 */
    /* JADX WARN: Type inference failed for: r13v2, types: [android.graphics.Typeface, android.os.Handler] */
    public Typeface g(int i2, int i3, k.e eVar) {
        ?? r13;
        Typeface typefaceB;
        int resourceId = this.f806b.getResourceId(i2, 0);
        Typeface typeface = null;
        typeface = null;
        typeface = null;
        typeface = null;
        if (resourceId == 0) {
            return null;
        }
        if (this.f807c == null) {
            this.f807c = new TypedValue();
        }
        Context context = this.a;
        TypedValue typedValue = this.f807c;
        ThreadLocal<TypedValue> threadLocal = c.f.c.b.k.a;
        if (context.isRestricted()) {
            return null;
        }
        Resources resources = context.getResources();
        resources.getValue(resourceId, typedValue, true);
        CharSequence charSequence = typedValue.string;
        if (charSequence == null) {
            StringBuilder sbB = d.b.a.a.a.B("Resource \"");
            sbB.append(resources.getResourceName(resourceId));
            sbB.append("\" (");
            sbB.append(Integer.toHexString(resourceId));
            sbB.append(") is not a Font: ");
            sbB.append(typedValue);
            throw new Resources.NotFoundException(sbB.toString());
        }
        String string = charSequence.toString();
        int i4 = -3;
        if (!string.startsWith("res/")) {
            eVar.a(-3, null);
            return null;
        }
        Typeface typefaceA = c.f.d.d.f1336b.a(c.f.d.d.c(resources, resourceId, string, typedValue.assetCookie, i3));
        if (typefaceA != null) {
            eVar.b(typefaceA, null);
            return typefaceA;
        }
        try {
            try {
            } catch (XmlPullParserException e2) {
                e = e2;
            }
        } catch (IOException e3) {
            e = e3;
        }
        try {
            try {
                if (string.toLowerCase().endsWith(".xml")) {
                    c.f.c.b.g gVarY = c.f.b.h.y(resources.getXml(resourceId), resources);
                    if (gVarY == null) {
                        Log.e("ResourcesCompat", "Failed to find font-family tag");
                        eVar.a(-3, null);
                        return null;
                    }
                    typefaceB = c.f.d.d.a(context, gVarY, resources, resourceId, string, typedValue.assetCookie, i3, eVar, null, true);
                } else {
                    typefaceB = c.f.d.d.b(context, resources, resourceId, string, typedValue.assetCookie, i3);
                    if (typefaceB != null) {
                        eVar.b(typefaceB, null);
                    } else {
                        eVar.a(-3, null);
                    }
                }
                typeface = typefaceB;
                return typeface;
            } catch (XmlPullParserException e4) {
                e = e4;
                i4 = -3;
                Log.e("ResourcesCompat", "Failed to parse xml resource " + string, e);
                r13 = typeface;
                eVar.a(i4, r13);
                return r13;
            }
        } catch (IOException e5) {
            e = e5;
            i4 = -3;
            Log.e("ResourcesCompat", "Failed to read xml resource " + string, e);
            r13 = typeface;
            eVar.a(i4, r13);
            return r13;
        }
    }

    public int h(int i2, int i3) {
        return this.f806b.getInt(i2, i3);
    }

    public int i(int i2, int i3) {
        return this.f806b.getLayoutDimension(i2, i3);
    }

    public int j(int i2, int i3) {
        return this.f806b.getResourceId(i2, i3);
    }

    public String k(int i2) {
        return this.f806b.getString(i2);
    }

    public CharSequence l(int i2) {
        return this.f806b.getText(i2);
    }

    public boolean m(int i2) {
        return this.f806b.hasValue(i2);
    }
}
