package p; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import java.util.WeakHashMap; /* loaded from: classes.dex */ public abstract class h { /* renamed from: a, reason: collision with root package name */ private static final ThreadLocal f12876a = new ThreadLocal(); /* renamed from: b, reason: collision with root package name */ private static final WeakHashMap f12877b = new WeakHashMap(0); /* renamed from: c, reason: collision with root package name */ private static final Object f12878c = new Object(); static class a { static ColorStateList a(Resources resources, int i10, Resources.Theme theme) { return resources.getColorStateList(i10, theme); } } private static class b { /* renamed from: a, reason: collision with root package name */ final ColorStateList f12879a; /* renamed from: b, reason: collision with root package name */ final Configuration f12880b; b(ColorStateList colorStateList, Configuration configuration) { this.f12879a = colorStateList; this.f12880b = configuration; } } private static final class c { /* renamed from: a, reason: collision with root package name */ final Resources f12881a; /* renamed from: b, reason: collision with root package name */ final Resources.Theme f12882b; c(Resources resources, Resources.Theme theme) { this.f12881a = resources; this.f12882b = theme; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || c.class != obj.getClass()) { return false; } c cVar = (c) obj; return this.f12881a.equals(cVar.f12881a) && y.c.a(this.f12882b, cVar.f12882b); } public int hashCode() { return y.c.b(this.f12881a, this.f12882b); } } public static abstract class d { class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Typeface f12883a; a(Typeface typeface) { this.f12883a = typeface; } @Override // java.lang.Runnable public void run() { d.this.e(this.f12883a); } } class b implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ int f12885a; b(int i10) { this.f12885a = i10; } @Override // java.lang.Runnable public void run() { d.this.d(this.f12885a); } } public static Handler c(Handler handler) { return handler == null ? new Handler(Looper.getMainLooper()) : handler; } public final void a(int i10, Handler handler) { c(handler).post(new b(i10)); } public final void b(Typeface typeface, Handler handler) { c(handler).post(new a(typeface)); } public abstract void d(int i10); public abstract void e(Typeface typeface); } private static void a(c cVar, int i10, ColorStateList colorStateList) { synchronized (f12878c) { WeakHashMap weakHashMap = f12877b; SparseArray sparseArray = (SparseArray) weakHashMap.get(cVar); if (sparseArray == null) { sparseArray = new SparseArray(); weakHashMap.put(cVar, sparseArray); } sparseArray.append(i10, new b(colorStateList, cVar.f12881a.getConfiguration())); } } private static ColorStateList b(c cVar, int i10) { b bVar; synchronized (f12878c) { SparseArray sparseArray = (SparseArray) f12877b.get(cVar); if (sparseArray != null && sparseArray.size() > 0 && (bVar = (b) sparseArray.get(i10)) != null) { if (bVar.f12880b.equals(cVar.f12881a.getConfiguration())) { return bVar.f12879a; } sparseArray.remove(i10); } return null; } } public static ColorStateList c(Resources resources, int i10, Resources.Theme theme) { c cVar = new c(resources, theme); ColorStateList b10 = b(cVar, i10); if (b10 != null) { return b10; } ColorStateList i11 = i(resources, i10, theme); if (i11 == null) { return Build.VERSION.SDK_INT >= 23 ? a.a(resources, i10, theme) : resources.getColorStateList(i10); } a(cVar, i10, i11); return i11; } public static Drawable d(Resources resources, int i10, Resources.Theme theme) { return resources.getDrawable(i10, theme); } public static Typeface e(Context context, int i10) { if (context.isRestricted()) { return null; } return k(context, i10, new TypedValue(), 0, null, null, false, false); } public static Typeface f(Context context, int i10, TypedValue typedValue, int i11, d dVar) { if (context.isRestricted()) { return null; } return k(context, i10, typedValue, i11, dVar, null, true, false); } public static void g(Context context, int i10, d dVar, Handler handler) { y.h.e(dVar); if (context.isRestricted()) { dVar.a(-4, handler); } else { k(context, i10, new TypedValue(), 0, dVar, handler, false, false); } } private static TypedValue h() { ThreadLocal threadLocal = f12876a; TypedValue typedValue = (TypedValue) threadLocal.get(); if (typedValue != null) { return typedValue; } TypedValue typedValue2 = new TypedValue(); threadLocal.set(typedValue2); return typedValue2; } private static ColorStateList i(Resources resources, int i10, Resources.Theme theme) { if (j(resources, i10)) { return null; } try { return p.c.a(resources, resources.getXml(i10), theme); } catch (Exception e10) { Log.w("ResourcesCompat", "Failed to inflate ColorStateList, leaving it to the framework", e10); return null; } } private static boolean j(Resources resources, int i10) { TypedValue h10 = h(); resources.getValue(i10, h10, true); int i11 = h10.type; return i11 >= 28 && i11 <= 31; } private static Typeface k(Context context, int i10, TypedValue typedValue, int i11, d dVar, Handler handler, boolean z10, boolean z11) { Resources resources = context.getResources(); resources.getValue(i10, typedValue, true); Typeface l10 = l(context, resources, typedValue, i10, i11, dVar, handler, z10, z11); if (l10 != null || dVar != null || z11) { return l10; } throw new Resources.NotFoundException("Font resource ID #0x" + Integer.toHexString(i10) + " could not be retrieved."); } /* JADX WARN: Removed duplicated region for block: B:36:0x00a6 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private static android.graphics.Typeface l(android.content.Context r15, android.content.res.Resources r16, android.util.TypedValue r17, int r18, int r19, p.h.d r20, android.os.Handler r21, boolean r22, boolean r23) { /* r0 = r16 r1 = r17 r4 = r18 r5 = r19 r9 = r20 r10 = r21 java.lang.String r11 = "ResourcesCompat" java.lang.CharSequence r2 = r1.string if (r2 == 0) goto Laa java.lang.String r12 = r2.toString() java.lang.String r1 = "res/" boolean r1 = r12.startsWith(r1) r13 = -3 r14 = 0 if (r1 != 0) goto L26 if (r9 == 0) goto L25 r9.a(r13, r10) L25: return r14 L26: android.graphics.Typeface r1 = q.i.f(r0, r4, r5) if (r1 == 0) goto L32 if (r9 == 0) goto L31 r9.b(r1, r10) L31: return r1 L32: if (r23 == 0) goto L35 return r14 L35: java.lang.String r1 = r12.toLowerCase() // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f java.lang.String r2 = ".xml" boolean r1 = r1.endsWith(r2) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f if (r1 == 0) goto L68 android.content.res.XmlResourceParser r1 = r0.getXml(r4) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f p.e$a r2 = p.e.b(r1, r0) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f if (r2 != 0) goto L56 java.lang.String r0 = "Failed to find font-family tag" android.util.Log.e(r11, r0) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f if (r9 == 0) goto L55 r9.a(r13, r10) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f L55: return r14 L56: r1 = r15 r3 = r16 r4 = r18 r5 = r19 r6 = r20 r7 = r21 r8 = r22 android.graphics.Typeface r0 = q.i.c(r1, r2, r3, r4, r5, r6, r7, r8) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f return r0 L68: r1 = r15 android.graphics.Typeface r0 = q.i.d(r15, r0, r4, r12, r5) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f if (r9 == 0) goto L78 if (r0 == 0) goto L75 r9.b(r0, r10) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f goto L78 L75: r9.a(r13, r10) // Catch: java.io.IOException -> L79 org.xmlpull.v1.XmlPullParserException -> L8f L78: return r0 L79: r0 = move-exception java.lang.StringBuilder r1 = new java.lang.StringBuilder r1.() java.lang.String r2 = "Failed to read xml resource " r1.append(r2) r1.append(r12) java.lang.String r1 = r1.toString() android.util.Log.e(r11, r1, r0) goto La4 L8f: r0 = move-exception java.lang.StringBuilder r1 = new java.lang.StringBuilder r1.() java.lang.String r2 = "Failed to parse xml resource " r1.append(r2) r1.append(r12) java.lang.String r1 = r1.toString() android.util.Log.e(r11, r1, r0) La4: if (r9 == 0) goto La9 r9.a(r13, r10) La9: return r14 Laa: android.content.res.Resources$NotFoundException r2 = new android.content.res.Resources$NotFoundException java.lang.StringBuilder r3 = new java.lang.StringBuilder r3.() java.lang.String r5 = "Resource \"" r3.append(r5) java.lang.String r0 = r0.getResourceName(r4) r3.append(r0) java.lang.String r0 = "\" (" r3.append(r0) java.lang.String r0 = java.lang.Integer.toHexString(r18) r3.append(r0) java.lang.String r0 = ") is not a Font: " r3.append(r0) r3.append(r1) java.lang.String r0 = r3.toString() r2.(r0) throw r2 */ throw new UnsupportedOperationException("Method not decompiled: p.h.l(android.content.Context, android.content.res.Resources, android.util.TypedValue, int, int, p.h$d, android.os.Handler, boolean, boolean):android.graphics.Typeface"); } }