package defpackage;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import defpackage.w28;

/* JADX INFO: loaded from: classes.dex */
@m38
public class fp9 {
    public final Context a;
    public final TypedArray b;
    public TypedValue c;

    @l18
    public static class a {
        @wd2
        public static int a(TypedArray typedArray) {
            return typedArray.getChangingConfigurations();
        }

        @wd2
        public static int b(TypedArray typedArray, int i) {
            return typedArray.getType(i);
        }
    }

    public fp9(Context context, TypedArray typedArray) {
        this.a = context;
        this.b = typedArray;
    }

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

    public static fp9 f(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2) {
        return new fp9(context, context.obtainStyledAttributes(attributeSet, iArr, i, i2));
    }

    public final ColorStateList a(int i) {
        int resourceId;
        ColorStateList colorStateList;
        TypedArray typedArray = this.b;
        return (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0 || (colorStateList = sf1.getColorStateList(this.a, resourceId)) == null) ? typedArray.getColorStateList(i) : colorStateList;
    }

    public final Drawable b(int i) {
        int resourceId;
        TypedArray typedArray = this.b;
        return (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0) ? typedArray.getDrawable(i) : gp.a(this.a, resourceId);
    }

    public final Drawable c(int i) {
        int resourceId;
        Drawable drawableE;
        if (!this.b.hasValue(i) || (resourceId = this.b.getResourceId(i, 0)) == 0) {
            return null;
        }
        po poVarA = po.a();
        Context context = this.a;
        synchronized (poVarA) {
            drawableE = poVarA.a.e(context, resourceId, true);
        }
        return drawableE;
    }

    public final Typeface d(int i, int i2, w28.f fVar) {
        int resourceId = this.b.getResourceId(i, 0);
        if (resourceId == 0) {
            return null;
        }
        if (this.c == null) {
            this.c = new TypedValue();
        }
        TypedValue typedValue = this.c;
        ThreadLocal threadLocal = w28.a;
        Context context = this.a;
        if (context.isRestricted()) {
            return null;
        }
        return w28.c(context, resourceId, typedValue, i2, fVar, true, false);
    }

    public final void g() {
        this.b.recycle();
    }
}
