package p071y;

import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.Base64;
import android.util.TypedValue;
import android.util.Xml;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import p014e0.C0648e;
import p064v.C1752c;

/* renamed from: y.f */
/* loaded from: classes.dex */
public class C1812f {

    /* renamed from: y.f$a */
    /* loaded from: classes.dex */
    public static class C1813a {
        /* renamed from: a */
        public static int m310a(TypedArray typedArray, int i) {
            int type;
            type = typedArray.getType(i);
            return type;
        }
    }

    /* renamed from: y.f$b */
    /* loaded from: classes.dex */
    public interface InterfaceC1814b {
    }

    /* renamed from: y.f$c */
    /* loaded from: classes.dex */
    public static final class C1815c implements InterfaceC1814b {

        /* renamed from: a */
        public final C1816d[] f4540a;

        public C1815c(C1816d[] c1816dArr) {
            this.f4540a = c1816dArr;
        }

        /* renamed from: a */
        public C1816d[] m309a() {
            return this.f4540a;
        }
    }

    /* renamed from: y.f$d */
    /* loaded from: classes.dex */
    public static final class C1816d {

        /* renamed from: a */
        public final String f4541a;

        /* renamed from: b */
        public final int f4542b;

        /* renamed from: c */
        public final boolean f4543c;

        /* renamed from: d */
        public final String f4544d;

        /* renamed from: e */
        public final int f4545e;

        /* renamed from: f */
        public final int f4546f;

        public C1816d(String str, int i, boolean z, String str2, int i2, int i3) {
            this.f4541a = str;
            this.f4542b = i;
            this.f4543c = z;
            this.f4544d = str2;
            this.f4545e = i2;
            this.f4546f = i3;
        }

        /* renamed from: a */
        public String m308a() {
            return this.f4541a;
        }

        /* renamed from: b */
        public int m307b() {
            return this.f4546f;
        }

        /* renamed from: c */
        public int m306c() {
            return this.f4545e;
        }

        /* renamed from: d */
        public String m305d() {
            return this.f4544d;
        }

        /* renamed from: e */
        public int m304e() {
            return this.f4542b;
        }

        /* renamed from: f */
        public boolean m303f() {
            return this.f4543c;
        }
    }

    /* renamed from: y.f$e */
    /* loaded from: classes.dex */
    public static final class C1817e implements InterfaceC1814b {

        /* renamed from: a */
        public final C0648e f4547a;

        /* renamed from: b */
        public final int f4548b;

        /* renamed from: c */
        public final int f4549c;

        /* renamed from: d */
        public final String f4550d;

        public C1817e(C0648e c0648e, int i, int i2, String str) {
            this.f4547a = c0648e;
            this.f4549c = i;
            this.f4548b = i2;
            this.f4550d = str;
        }

        /* renamed from: a */
        public int m302a() {
            return this.f4549c;
        }

        /* renamed from: b */
        public C0648e m301b() {
            return this.f4547a;
        }

        /* renamed from: c */
        public String m300c() {
            return this.f4550d;
        }

        /* renamed from: d */
        public int m299d() {
            return this.f4548b;
        }
    }

    /* renamed from: a */
    public static int m318a(TypedArray typedArray, int i) {
        if (Build.VERSION.SDK_INT >= 21) {
            return C1813a.m310a(typedArray, i);
        }
        TypedValue typedValue = new TypedValue();
        typedArray.getValue(i, typedValue);
        return typedValue.type;
    }

    /* renamed from: b */
    public static InterfaceC1814b m317b(XmlPullParser xmlPullParser, Resources resources) {
        int next;
        do {
            next = xmlPullParser.next();
            if (next == 2) {
                break;
            }
        } while (next != 1);
        if (next == 2) {
            return m315d(xmlPullParser, resources);
        }
        throw new XmlPullParserException("No start tag found");
    }

    /* renamed from: c */
    public static List<List<byte[]>> m316c(Resources resources, int i) {
        if (i == 0) {
            return Collections.emptyList();
        }
        TypedArray obtainTypedArray = resources.obtainTypedArray(i);
        try {
            if (obtainTypedArray.length() == 0) {
                return Collections.emptyList();
            }
            ArrayList arrayList = new ArrayList();
            if (m318a(obtainTypedArray, 0) == 1) {
                for (int i2 = 0; i2 < obtainTypedArray.length(); i2++) {
                    int resourceId = obtainTypedArray.getResourceId(i2, 0);
                    if (resourceId != 0) {
                        arrayList.add(m311h(resources.getStringArray(resourceId)));
                    }
                }
            } else {
                arrayList.add(m311h(resources.getStringArray(i)));
            }
            return arrayList;
        } finally {
            obtainTypedArray.recycle();
        }
    }

    /* renamed from: d */
    public static InterfaceC1814b m315d(XmlPullParser xmlPullParser, Resources resources) {
        xmlPullParser.require(2, null, "font-family");
        if (xmlPullParser.getName().equals("font-family")) {
            return m314e(xmlPullParser, resources);
        }
        m312g(xmlPullParser);
        return null;
    }

    /* renamed from: e */
    public static InterfaceC1814b m314e(XmlPullParser xmlPullParser, Resources resources) {
        TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(xmlPullParser), C1752c.f4450h);
        String string = obtainAttributes.getString(C1752c.f4451i);
        String string2 = obtainAttributes.getString(C1752c.f4455m);
        String string3 = obtainAttributes.getString(C1752c.f4456n);
        int resourceId = obtainAttributes.getResourceId(C1752c.f4452j, 0);
        int integer = obtainAttributes.getInteger(C1752c.f4453k, 1);
        int integer2 = obtainAttributes.getInteger(C1752c.f4454l, 500);
        String string4 = obtainAttributes.getString(C1752c.f4457o);
        obtainAttributes.recycle();
        if (string != null && string2 != null && string3 != null) {
            while (xmlPullParser.next() != 3) {
                m312g(xmlPullParser);
            }
            return new C1817e(new C0648e(string, string2, string3, m316c(resources, resourceId)), integer, integer2, string4);
        }
        ArrayList arrayList = new ArrayList();
        while (xmlPullParser.next() != 3) {
            if (xmlPullParser.getEventType() == 2) {
                if (xmlPullParser.getName().equals("font")) {
                    arrayList.add(m313f(xmlPullParser, resources));
                } else {
                    m312g(xmlPullParser);
                }
            }
        }
        if (arrayList.isEmpty()) {
            return null;
        }
        return new C1815c((C1816d[]) arrayList.toArray(new C1816d[0]));
    }

    /* renamed from: f */
    public static C1816d m313f(XmlPullParser xmlPullParser, Resources resources) {
        TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(xmlPullParser), C1752c.f4458p);
        int i = C1752c.f4467y;
        if (!obtainAttributes.hasValue(i)) {
            i = C1752c.f4460r;
        }
        int i2 = obtainAttributes.getInt(i, 400);
        int i3 = C1752c.f4465w;
        if (!obtainAttributes.hasValue(i3)) {
            i3 = C1752c.f4461s;
        }
        boolean z = 1 == obtainAttributes.getInt(i3, 0);
        int i4 = C1752c.f4468z;
        if (!obtainAttributes.hasValue(i4)) {
            i4 = C1752c.f4462t;
        }
        int i5 = C1752c.f4466x;
        if (!obtainAttributes.hasValue(i5)) {
            i5 = C1752c.f4463u;
        }
        String string = obtainAttributes.getString(i5);
        int i6 = obtainAttributes.getInt(i4, 0);
        int i7 = C1752c.f4464v;
        if (!obtainAttributes.hasValue(i7)) {
            i7 = C1752c.f4459q;
        }
        int resourceId = obtainAttributes.getResourceId(i7, 0);
        String string2 = obtainAttributes.getString(i7);
        obtainAttributes.recycle();
        while (xmlPullParser.next() != 3) {
            m312g(xmlPullParser);
        }
        return new C1816d(string2, i2, z, string, i6, resourceId);
    }

    /* renamed from: g */
    public static void m312g(XmlPullParser xmlPullParser) {
        int i = 1;
        while (i > 0) {
            int next = xmlPullParser.next();
            if (next == 2) {
                i++;
            } else if (next == 3) {
                i--;
            }
        }
    }

    /* renamed from: h */
    public static List<byte[]> m311h(String[] strArr) {
        ArrayList arrayList = new ArrayList();
        for (String str : strArr) {
            arrayList.add(Base64.decode(str, 0));
        }
        return arrayList;
    }
}