package i0;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.Xml;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

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

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

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

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

    public d(Shader shader, ColorStateList colorStateList, int i10) {
        this.f26487a = shader;
        this.f26488b = colorStateList;
        this.f26489c = i10;
    }

    @NonNull
    private static d createFromXml(@NonNull Resources resources, @ColorRes int i10, @Nullable Resources.Theme theme) throws XmlPullParserException, IOException {
        int next;
        XmlResourceParser xml = resources.getXml(i10);
        AttributeSet attributeSetAsAttributeSet = Xml.asAttributeSet(xml);
        do {
            next = xml.next();
            if (next == 2) {
                break;
            }
        } while (next != 1);
        if (next != 2) {
            throw new XmlPullParserException("No start tag found");
        }
        String name = xml.getName();
        name.getClass();
        if (name.equals("gradient")) {
            return new d(k.createFromXmlInner(resources, xml, attributeSetAsAttributeSet, theme), null, 0);
        }
        if (name.equals("selector")) {
            ColorStateList colorStateListCreateFromXmlInner = c.createFromXmlInner(resources, xml, attributeSetAsAttributeSet, theme);
            return new d(null, colorStateListCreateFromXmlInner, colorStateListCreateFromXmlInner.getDefaultColor());
        }
        throw new XmlPullParserException(xml.getPositionDescription() + ": unsupported complex color tag " + name);
    }

    @Nullable
    public static d inflate(@NonNull Resources resources, @ColorRes int i10, @Nullable Resources.Theme theme) {
        try {
            return createFromXml(resources, i10, theme);
        } catch (Exception unused) {
            return null;
        }
    }

    public final boolean a() {
        ColorStateList colorStateList;
        return this.f26487a == null && (colorStateList = this.f26488b) != null && colorStateList.isStateful();
    }

    @Nullable
    public Shader getShader() {
        return this.f26487a;
    }
}
