package X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2;

import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.LinearGradient;
import android.graphics.RadialGradient;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* compiled from: GradientColorInflaterCompat.java */
/* loaded from: classes.dex */
public final class Mqv2r_3 {
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static Shader m335KQgRr5e_0(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws IOException, XmlPullParserException {
        String name = xmlPullParser.getName();
        if (name.equals("gradient")) {
            TypedArray KQgRr5e_02 = IMuAHx_6.KQgRr5e_0(resources, theme, attributeSet, X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor);
            float KQgRr5e_03 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "startX", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_startX, 0.0f);
            float KQgRr5e_04 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "startY", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_startY, 0.0f);
            float KQgRr5e_05 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "endX", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_endX, 0.0f);
            float KQgRr5e_06 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "endY", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_endY, 0.0f);
            float KQgRr5e_07 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "centerX", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_centerX, 0.0f);
            float KQgRr5e_08 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "centerY", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_centerY, 0.0f);
            int QxJ9d_1 = IMuAHx_6.QxJ9d_1(KQgRr5e_02, xmlPullParser, "type", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_type, 0);
            int KQgRr5e_09 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "startColor", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_startColor, 0);
            boolean KQgRr5e_010 = IMuAHx_6.KQgRr5e_0(xmlPullParser, "centerColor");
            int KQgRr5e_011 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "centerColor", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_centerColor, 0);
            int KQgRr5e_012 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "endColor", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_endColor, 0);
            int QxJ9d_12 = IMuAHx_6.QxJ9d_1(KQgRr5e_02, xmlPullParser, "tileMode", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_tileMode, 0);
            float KQgRr5e_013 = IMuAHx_6.KQgRr5e_0(KQgRr5e_02, xmlPullParser, "gradientRadius", X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColor_android_gradientRadius, 0.0f);
            KQgRr5e_02.recycle();
            KQgRr5e_0 KQgRr5e_014 = KQgRr5e_0(KQgRr5e_0(resources, xmlPullParser, attributeSet, theme), KQgRr5e_09, KQgRr5e_012, KQgRr5e_010, KQgRr5e_011);
            if (QxJ9d_1 != 1) {
                if (QxJ9d_1 != 2) {
                    return new LinearGradient(KQgRr5e_03, KQgRr5e_04, KQgRr5e_05, KQgRr5e_06, KQgRr5e_014.f516KQgRr5e_0, KQgRr5e_014.KQgRr5e_0, KQgRr5e_0(QxJ9d_12));
                }
                return new SweepGradient(KQgRr5e_07, KQgRr5e_08, KQgRr5e_014.f516KQgRr5e_0, KQgRr5e_014.KQgRr5e_0);
            } else if (KQgRr5e_013 > 0.0f) {
                return new RadialGradient(KQgRr5e_07, KQgRr5e_08, KQgRr5e_013, KQgRr5e_014.f516KQgRr5e_0, KQgRr5e_014.KQgRr5e_0, KQgRr5e_0(QxJ9d_12));
            } else {
                throw new XmlPullParserException("<gradient> tag requires 'gradientRadius' attribute with radial type");
            }
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid gradient color tag " + name);
    }

    /* compiled from: GradientColorInflaterCompat.java */
    /* loaded from: classes.dex */
    public static final class KQgRr5e_0 {
        public final float[] KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final int[] f516KQgRr5e_0;

        public KQgRr5e_0(List<Integer> list, List<Float> list2) {
            int size = list.size();
            this.f516KQgRr5e_0 = new int[size];
            this.KQgRr5e_0 = new float[size];
            for (int i = 0; i < size; i++) {
                this.f516KQgRr5e_0[i] = list.get(i).intValue();
                this.KQgRr5e_0[i] = list2.get(i).floatValue();
            }
        }

        public KQgRr5e_0(int i, int i2) {
            this.f516KQgRr5e_0 = new int[]{i, i2};
            this.KQgRr5e_0 = new float[]{0.0f, 1.0f};
        }

        public KQgRr5e_0(int i, int i2, int i3) {
            this.f516KQgRr5e_0 = new int[]{i, i2, i3};
            this.KQgRr5e_0 = new float[]{0.0f, 0.5f, 1.0f};
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0084, code lost:
        throw new org.xmlpull.v1.XmlPullParserException(r9.getPositionDescription() + ": <item> tag requires a 'color' attribute and a 'offset' attribute!");
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static KQgRr5e_0 KQgRr5e_0(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
        int depth;
        int depth2 = xmlPullParser.getDepth() + 1;
        ArrayList arrayList = new ArrayList(20);
        ArrayList arrayList2 = new ArrayList(20);
        while (true) {
            int next = xmlPullParser.next();
            if (next == 1 || ((depth = xmlPullParser.getDepth()) < depth2 && next == 3)) {
                break;
            } else if (next == 2 && depth <= depth2 && xmlPullParser.getName().equals("item")) {
                TypedArray KQgRr5e_02 = IMuAHx_6.KQgRr5e_0(resources, theme, attributeSet, X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColorItem);
                boolean hasValue = KQgRr5e_02.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColorItem_android_color);
                boolean hasValue2 = KQgRr5e_02.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColorItem_android_offset);
                if (!hasValue || !hasValue2) {
                    break;
                }
                int color = KQgRr5e_02.getColor(X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColorItem_android_color, 0);
                float f = KQgRr5e_02.getFloat(X6FRs_4.IMuAHx_6.PGPF6hQ_2.GradientColorItem_android_offset, 0.0f);
                KQgRr5e_02.recycle();
                arrayList2.add(Integer.valueOf(color));
                arrayList.add(Float.valueOf(f));
            }
        }
        if (arrayList2.size() > 0) {
            return new KQgRr5e_0(arrayList2, arrayList);
        }
        return null;
    }

    public static KQgRr5e_0 KQgRr5e_0(KQgRr5e_0 kQgRr5e_0, int i, int i2, boolean z, int i3) {
        if (kQgRr5e_0 != null) {
            return kQgRr5e_0;
        }
        if (z) {
            return new KQgRr5e_0(i, i3, i2);
        }
        return new KQgRr5e_0(i, i2);
    }

    public static Shader.TileMode KQgRr5e_0(int i) {
        if (i != 1) {
            if (i != 2) {
                return Shader.TileMode.CLAMP;
            }
            return Shader.TileMode.MIRROR;
        }
        return Shader.TileMode.REPEAT;
    }
}
