package p037.p065.p068.p069;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.LinearGradient;
import android.graphics.RadialGradient;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import android.util.Xml;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p065.C1794;

/* JADX INFO: renamed from: މ.ރ.ރ.ؠ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C1852 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Shader f6229;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final ColorStateList f6230;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public int f6231;

    public C1852(Shader shader, ColorStateList colorStateList, int i) {
        this.f6229 = shader;
        this.f6230 = colorStateList;
        this.f6231 = i;
    }

    /* JADX WARN: Code restructure failed: missing block: B:42:0x014f, code lost:
    
        throw new org.xmlpull.v1.XmlPullParserException(r2.getPositionDescription() + ": <item> tag requires a 'color' attribute and a 'offset' attribute!");
     */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C1852 m3658(Resources resources, int i, Resources.Theme theme) {
        int next;
        float f;
        float f2;
        Shader radialGradient;
        XmlResourceParser xml = resources.getXml(i);
        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();
        byte b = -1;
        int iHashCode = name.hashCode();
        if (iHashCode != 89650992) {
            if (iHashCode == 1191572447 && name.equals("selector")) {
                b = 0;
            }
        } else if (name.equals("gradient")) {
            b = 1;
        }
        if (b == 0) {
            ColorStateList colorStateListM2893 = LayoutInflaterFactory2C1494.C1505.m2893(resources, xml, attributeSetAsAttributeSet, theme);
            return new C1852(null, colorStateListM2893, colorStateListM2893.getDefaultColor());
        }
        if (b != 1) {
            throw new XmlPullParserException(xml.getPositionDescription() + ": unsupported complex color tag " + name);
        }
        String name2 = xml.getName();
        if (!name2.equals("gradient")) {
            throw new XmlPullParserException(xml.getPositionDescription() + ": invalid gradient color tag " + name2);
        }
        TypedArray typedArrayM2894 = LayoutInflaterFactory2C1494.C1505.m2894(resources, theme, attributeSetAsAttributeSet, C1794.GradientColor);
        float fM2868 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "startX", C1794.GradientColor_android_startX, 0.0f);
        float fM28682 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "startY", C1794.GradientColor_android_startY, 0.0f);
        float fM28683 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "endX", C1794.GradientColor_android_endX, 0.0f);
        float fM28684 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "endY", C1794.GradientColor_android_endY, 0.0f);
        float fM28685 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "centerX", C1794.GradientColor_android_centerX, 0.0f);
        float fM28686 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "centerY", C1794.GradientColor_android_centerY, 0.0f);
        int iM2968 = LayoutInflaterFactory2C1494.C1505.m2968(typedArrayM2894, xml, "type", C1794.GradientColor_android_type, 0);
        int iM2874 = LayoutInflaterFactory2C1494.C1505.m2874(typedArrayM2894, (XmlPullParser) xml, "startColor", C1794.GradientColor_android_startColor, 0);
        boolean zM2963 = LayoutInflaterFactory2C1494.C1505.m2963((XmlPullParser) xml, "centerColor");
        int iM28742 = LayoutInflaterFactory2C1494.C1505.m2874(typedArrayM2894, (XmlPullParser) xml, "centerColor", C1794.GradientColor_android_centerColor, 0);
        int iM28743 = LayoutInflaterFactory2C1494.C1505.m2874(typedArrayM2894, (XmlPullParser) xml, "endColor", C1794.GradientColor_android_endColor, 0);
        int iM29682 = LayoutInflaterFactory2C1494.C1505.m2968(typedArrayM2894, xml, "tileMode", C1794.GradientColor_android_tileMode, 0);
        float fM28687 = LayoutInflaterFactory2C1494.C1505.m2868(typedArrayM2894, (XmlPullParser) xml, "gradientRadius", C1794.GradientColor_android_gradientRadius, 0.0f);
        typedArrayM2894.recycle();
        int depth = xml.getDepth() + 1;
        ArrayList arrayList = new ArrayList(20);
        ArrayList arrayList2 = new ArrayList(20);
        Resources resources2 = resources;
        while (true) {
            int next2 = xml.next();
            f = fM28683;
            if (next2 == 1) {
                f2 = fM28682;
                break;
            }
            int depth2 = xml.getDepth();
            f2 = fM28682;
            if (depth2 < depth && next2 == 3) {
                break;
            }
            if (next2 == 2) {
                if (depth2 > depth) {
                    resources2 = resources;
                } else if (xml.getName().equals("item")) {
                    TypedArray typedArrayM28942 = LayoutInflaterFactory2C1494.C1505.m2894(resources2, theme, attributeSetAsAttributeSet, C1794.GradientColorItem);
                    boolean zHasValue = typedArrayM28942.hasValue(C1794.GradientColorItem_android_color);
                    boolean zHasValue2 = typedArrayM28942.hasValue(C1794.GradientColorItem_android_offset);
                    if (!zHasValue || !zHasValue2) {
                        break;
                    }
                    int color = typedArrayM28942.getColor(C1794.GradientColorItem_android_color, 0);
                    float f3 = typedArrayM28942.getFloat(C1794.GradientColorItem_android_offset, 0.0f);
                    typedArrayM28942.recycle();
                    arrayList2.add(Integer.valueOf(color));
                    arrayList.add(Float.valueOf(f3));
                    resources2 = resources;
                } else {
                    continue;
                }
            }
            fM28683 = f;
            fM28682 = f2;
        }
        C1857 c1857 = arrayList2.size() > 0 ? new C1857(arrayList2, arrayList) : null;
        if (c1857 == null) {
            c1857 = zM2963 ? new C1857(iM2874, iM28742, iM28743) : new C1857(iM2874, iM28743);
        }
        if (iM2968 != 1) {
            if (iM2968 != 2) {
                radialGradient = new LinearGradient(fM2868, f2, f, fM28684, c1857.f6242, c1857.f6243, iM29682 != 1 ? iM29682 != 2 ? Shader.TileMode.CLAMP : Shader.TileMode.MIRROR : Shader.TileMode.REPEAT);
            } else {
                radialGradient = new SweepGradient(fM28685, fM28686, c1857.f6242, c1857.f6243);
            }
        } else {
            if (fM28687 <= 0.0f) {
                throw new XmlPullParserException("<gradient> tag requires 'gradientRadius' attribute with radial type");
            }
            radialGradient = new RadialGradient(fM28685, fM28686, fM28687, c1857.f6242, c1857.f6243, iM29682 != 1 ? iM29682 != 2 ? Shader.TileMode.CLAMP : Shader.TileMode.MIRROR : Shader.TileMode.REPEAT);
        }
        return new C1852(radialGradient, null, 0);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean m3659() {
        return this.f6229 != null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean m3660(int[] iArr) {
        if (m3661()) {
            ColorStateList colorStateList = this.f6230;
            int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
            if (colorForState != this.f6231) {
                this.f6231 = colorForState;
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public boolean m3661() {
        ColorStateList colorStateList;
        return this.f6229 == null && (colorStateList = this.f6230) != null && colorStateList.isStateful();
    }
}
