package X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.StateSet;
import android.util.Xml;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* compiled from: ColorStateListInflaterCompat.java */
/* loaded from: classes.dex */
public final class KQgRr5e_0 {
    public static ColorStateList KQgRr5e_0(Resources resources, XmlPullParser xmlPullParser, Resources.Theme theme) throws XmlPullParserException, IOException {
        int next;
        AttributeSet asAttributeSet = Xml.asAttributeSet(xmlPullParser);
        do {
            next = xmlPullParser.next();
            if (next == 2) {
                break;
            }
        } while (next != 1);
        if (next == 2) {
            return KQgRr5e_0(resources, xmlPullParser, asAttributeSet, theme);
        }
        throw new XmlPullParserException("No start tag found");
    }

    public static ColorStateList QxJ9d_1(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
        int depth;
        int i = 1;
        int depth2 = xmlPullParser.getDepth() + 1;
        int[][] iArr = new int[20];
        int[] iArr2 = new int[20];
        int i2 = 0;
        while (true) {
            int next = xmlPullParser.next();
            if (next == i || ((depth = xmlPullParser.getDepth()) < depth2 && next == 3)) {
                break;
            }
            if (next == 2 && depth <= depth2 && xmlPullParser.getName().equals("item")) {
                TypedArray KQgRr5e_0 = KQgRr5e_0(resources, theme, attributeSet, X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem);
                int color = KQgRr5e_0.getColor(X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem_android_color, -65281);
                float f = 1.0f;
                if (KQgRr5e_0.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem_android_alpha)) {
                    f = KQgRr5e_0.getFloat(X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem_android_alpha, 1.0f);
                } else if (KQgRr5e_0.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem_alpha)) {
                    f = KQgRr5e_0.getFloat(X6FRs_4.IMuAHx_6.PGPF6hQ_2.ColorStateListItem_alpha, 1.0f);
                }
                KQgRr5e_0.recycle();
                int attributeCount = attributeSet.getAttributeCount();
                int[] iArr3 = new int[attributeCount];
                int i3 = 0;
                for (int i4 = 0; i4 < attributeCount; i4++) {
                    int attributeNameResource = attributeSet.getAttributeNameResource(i4);
                    if (attributeNameResource != 16843173 && attributeNameResource != 16843551 && attributeNameResource != X6FRs_4.IMuAHx_6.KQgRr5e_0.alpha) {
                        int i5 = i3 + 1;
                        if (!attributeSet.getAttributeBooleanValue(i4, false)) {
                            attributeNameResource = -attributeNameResource;
                        }
                        iArr3[i3] = attributeNameResource;
                        i3 = i5;
                    }
                }
                int[] trimStateSet = StateSet.trimStateSet(iArr3, i3);
                iArr2 = X6FRs_4.KQgRr5e_0(iArr2, i2, KQgRr5e_0(color, f));
                iArr = (int[][]) X6FRs_4.KQgRr5e_0(iArr, i2, trimStateSet);
                i2++;
            }
            i = 1;
        }
        int[] iArr4 = new int[i2];
        int[][] iArr5 = new int[i2];
        System.arraycopy(iArr2, 0, iArr4, 0, i2);
        System.arraycopy(iArr, 0, iArr5, 0, i2);
        return new ColorStateList(iArr5, iArr4);
    }

    public static ColorStateList KQgRr5e_0(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
        String name = xmlPullParser.getName();
        if (name.equals("selector")) {
            return QxJ9d_1(resources, xmlPullParser, attributeSet, theme);
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid color state list tag " + name);
    }

    public static TypedArray KQgRr5e_0(Resources resources, Resources.Theme theme, AttributeSet attributeSet, int[] iArr) {
        if (theme == null) {
            return resources.obtainAttributes(attributeSet, iArr);
        }
        return theme.obtainStyledAttributes(attributeSet, iArr, 0, 0);
    }

    public static int KQgRr5e_0(int i, float f) {
        return (i & 16777215) | (Math.round(Color.alpha(i) * f) << 24);
    }
}
