package c.a.g;

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.c.c.b.e;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f4999a;

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

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

    public l0(Context context, TypedArray typedArray) {
        this.f4999a = context;
        this.f5000b = typedArray;
    }

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

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

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

    public ColorStateList b(int i2) {
        int resourceId;
        if (this.f5000b.hasValue(i2) && (resourceId = this.f5000b.getResourceId(i2, 0)) != 0) {
            Context context = this.f4999a;
            ThreadLocal<TypedValue> threadLocal = c.a.d.a.a.f4778a;
            ColorStateList colorStateList = context.getColorStateList(resourceId);
            if (colorStateList != null) {
                return colorStateList;
            }
        }
        return this.f5000b.getColorStateList(i2);
    }

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

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

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

    public Typeface f(int i2, int i3, e.a aVar) {
        StringBuilder sb;
        String str;
        int resourceId = this.f5000b.getResourceId(i2, 0);
        if (resourceId == 0) {
            return null;
        }
        if (this.f5001c == null) {
            this.f5001c = new TypedValue();
        }
        Context context = this.f4999a;
        TypedValue typedValue = this.f5001c;
        ThreadLocal<TypedValue> threadLocal = c.c.c.b.e.f5188a;
        if (context.isRestricted()) {
            return null;
        }
        Resources resources = context.getResources();
        resources.getValue(resourceId, typedValue, true);
        CharSequence charSequence = typedValue.string;
        if (charSequence == null) {
            StringBuilder sbC = a.b.c.a.a.C("Resource \"");
            sbC.append(resources.getResourceName(resourceId));
            sbC.append("\" (");
            sbC.append(Integer.toHexString(resourceId));
            sbC.append(") is not a Font: ");
            sbC.append(typedValue);
            throw new Resources.NotFoundException(sbC.toString());
        }
        String string = charSequence.toString();
        if (string.startsWith("res/")) {
            Typeface typefaceA = c.c.d.c.f5202b.a(c.c.d.c.c(resources, resourceId, i3));
            if (typefaceA != null) {
                aVar.b(typefaceA, null);
                return typefaceA;
            }
            try {
                if (!string.toLowerCase().endsWith(".xml")) {
                    Typeface typefaceB = c.c.d.c.b(context, resources, resourceId, string, i3);
                    if (typefaceB != null) {
                        aVar.b(typefaceB, null);
                    } else {
                        aVar.a(-3, null);
                    }
                    return typefaceB;
                }
                c.c.c.b.a aVarU = c.c.b.a.u(resources.getXml(resourceId), resources);
                if (aVarU != null) {
                    return c.c.d.c.a(context, aVarU, resources, resourceId, i3, aVar, null, true);
                }
                Log.e("ResourcesCompat", "Failed to find font-family tag");
                aVar.a(-3, null);
                return null;
            } catch (IOException e2) {
                e = e2;
                sb = new StringBuilder();
                str = "Failed to read xml resource ";
                sb.append(str);
                sb.append(string);
                Log.e("ResourcesCompat", sb.toString(), e);
                aVar.a(-3, null);
                return null;
            } catch (XmlPullParserException e3) {
                e = e3;
                sb = new StringBuilder();
                str = "Failed to parse xml resource ";
                sb.append(str);
                sb.append(string);
                Log.e("ResourcesCompat", sb.toString(), e);
                aVar.a(-3, null);
                return null;
            }
        }
        aVar.a(-3, null);
        return null;
    }

    public int g(int i2, int i3) {
        return this.f5000b.getInt(i2, i3);
    }

    public int h(int i2, int i3) {
        return this.f5000b.getLayoutDimension(i2, i3);
    }

    public int i(int i2, int i3) {
        return this.f5000b.getResourceId(i2, i3);
    }

    public String j(int i2) {
        return this.f5000b.getString(i2);
    }

    public CharSequence k(int i2) {
        return this.f5000b.getText(i2);
    }

    public boolean l(int i2) {
        return this.f5000b.hasValue(i2);
    }
}
