package o; 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.SparseArray; import android.util.TypedValue; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.WeakHashMap; import o.Szw; import o.kVs; import org.xmlpull.v1.XmlPullParserException; /* loaded from: classes.dex */ public final class kVs { private static final ThreadLocal b = new ThreadLocal<>(); private static final WeakHashMap> a = new WeakHashMap<>(0); private static final Object c = new Object(); public static Drawable nZ_(Resources resources, int i, Resources.Theme theme) throws Resources.NotFoundException { return HBt.oj_(resources, i, theme); } public static Drawable oa_(Resources resources, int i, int i2, Resources.Theme theme) throws Resources.NotFoundException { return HBt.ok_(resources, i, i2, theme); } public static int nX_(Resources resources, int i, Resources.Theme theme) throws Resources.NotFoundException { return Sts.ol_(resources, i, theme); } public static ColorStateList nY_(Resources resources, int i, Resources.Theme theme) throws Resources.NotFoundException { IeS ieS = new IeS(resources, theme); ColorStateList nV_ = nV_(ieS, i); if (nV_ != null) { return nV_; } ColorStateList of_ = of_(resources, i, theme); if (of_ != null) { nU_(ieS, i, of_, theme); return of_; } return Sts.om_(resources, i, theme); } private static ColorStateList of_(Resources resources, int i, Resources.Theme theme) { if (og_(resources, i)) { return null; } try { return kFD.ny_(resources, resources.getXml(i), theme); } catch (Exception unused) { return null; } } private static ColorStateList nV_(IeS ieS, int i) { RVV rvv; synchronized (c) { SparseArray sparseArray = a.get(ieS); if (sparseArray != null && sparseArray.size() > 0 && (rvv = sparseArray.get(i)) != null) { if (rvv.d.equals(ieS.a.getConfiguration()) && ((ieS.c == null && rvv.a == 0) || (ieS.c != null && rvv.a == ieS.c.hashCode()))) { return rvv.b; } sparseArray.remove(i); } return null; } } private static void nU_(IeS ieS, int i, ColorStateList colorStateList, Resources.Theme theme) { synchronized (c) { WeakHashMap> weakHashMap = a; SparseArray sparseArray = weakHashMap.get(ieS); if (sparseArray == null) { sparseArray = new SparseArray<>(); weakHashMap.put(ieS, sparseArray); } sparseArray.append(i, new RVV(colorStateList, ieS.a.getConfiguration(), theme)); } } private static boolean og_(Resources resources, int i) { TypedValue oe_ = oe_(); resources.getValue(i, oe_, true); return oe_.type >= 28 && oe_.type <= 31; } private static TypedValue oe_() { ThreadLocal threadLocal = b; TypedValue typedValue = threadLocal.get(); if (typedValue != null) { return typedValue; } TypedValue typedValue2 = new TypedValue(); threadLocal.set(typedValue2); return typedValue2; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static final class IeS { final Resources a; final Resources.Theme c; IeS(Resources resources, Resources.Theme theme) { this.a = resources; this.c = theme; } public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } IeS ieS = (IeS) obj; return this.a.equals(ieS.a) && ZEY.b(this.c, ieS.c); } public final int hashCode() { return ZEY.d(this.a, this.c); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class RVV { final int a; final ColorStateList b; final Configuration d; RVV(ColorStateList colorStateList, Configuration configuration, Resources.Theme theme) { this.b = colorStateList; this.d = configuration; this.a = theme == null ? 0 : theme.hashCode(); } } public static Typeface ob_(Context context, int i) throws Resources.NotFoundException { if (context.isRestricted()) { return null; } return oh_(context, i, new TypedValue(), 0, null, null, false, false); } public static Typeface nW_(Context context, int i) throws Resources.NotFoundException { if (context.isRestricted()) { return null; } return oh_(context, i, new TypedValue(), 0, null, null, false, true); } /* loaded from: classes.dex */ public static abstract class LWm { /* renamed from: KC_, reason: merged with bridge method [inline-methods] */ public abstract void oq_(Typeface typeface); /* renamed from: e, reason: merged with bridge method [inline-methods] */ public abstract void b(int i); public final void op_(final Typeface typeface, Handler handler) { on_(handler).post(new Runnable(this, typeface) { // from class: o.aqs public final Typeface c; public final kVs.LWm e; @Override // java.lang.Runnable public final void run() { this.e.oq_(this.c); } { this.e = this; this.c = typeface; } }); } public final void oo_(final int i, Handler handler) { on_(handler).post(new Runnable(this, i) { // from class: o.Drr public final kVs.LWm c; public final int e; @Override // java.lang.Runnable public final void run() { this.c.b(this.e); } { this.c = this; this.e = i; } }); } public static Handler on_(Handler handler) { return handler == null ? new Handler(Looper.getMainLooper()) : handler; } } public static void od_(Context context, int i, LWm lWm, Handler handler) throws Resources.NotFoundException { if (context.isRestricted()) { lWm.oo_(-4, handler); } else { oh_(context, i, new TypedValue(), 0, lWm, handler, false, false); } } public static Typeface oc_(Context context, int i, TypedValue typedValue, int i2, LWm lWm) throws Resources.NotFoundException { if (context.isRestricted()) { return null; } return oh_(context, i, typedValue, i2, lWm, null, true, false); } private static Typeface oh_(Context context, int i, TypedValue typedValue, int i2, LWm lWm, Handler handler, boolean z, boolean z2) { Resources resources = context.getResources(); resources.getValue(i, typedValue, true); Typeface oi_ = oi_(context, resources, typedValue, i, i2, lWm, handler, z, z2); if (oi_ != null || lWm != null || z2) { return oi_; } StringBuilder sb = new StringBuilder("Font resource ID #0x"); sb.append(Integer.toHexString(i)); sb.append(" could not be retrieved."); throw new Resources.NotFoundException(sb.toString()); } private static Typeface oi_(Context context, Resources resources, TypedValue typedValue, int i, int i2, LWm lWm, Handler handler, boolean z, boolean z2) { if (typedValue.string == null) { StringBuilder sb = new StringBuilder("Resource \""); sb.append(resources.getResourceName(i)); sb.append("\" ("); sb.append(Integer.toHexString(i)); sb.append(") is not a Font: "); sb.append(typedValue); throw new Resources.NotFoundException(sb.toString()); } String obj = typedValue.string.toString(); if (!obj.startsWith("res/")) { if (lWm != null) { lWm.oo_(-3, handler); } return null; } Typeface oO_ = TaO.oO_(resources, i, obj, typedValue.assetCookie, i2); if (oO_ != null) { if (lWm != null) { lWm.op_(oO_, handler); } return oO_; } if (z2) { return null; } try { if (obj.toLowerCase().endsWith(".xml")) { Szw.HBt nL_ = Szw.nL_(resources.getXml(i), resources); if (nL_ != null) { return TaO.oL_(context, nL_, resources, i, obj, typedValue.assetCookie, i2, lWm, handler, z); } if (lWm != null) { lWm.oo_(-3, handler); } return null; } Typeface oM_ = TaO.oM_(context, resources, i, obj, typedValue.assetCookie, i2); if (lWm != null) { if (oM_ != null) { lWm.op_(oM_, handler); } else { lWm.oo_(-3, handler); } } return oM_; } catch (IOException | XmlPullParserException unused) { if (lWm != null) { lWm.oo_(-3, handler); } return null; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class Sts { static ColorStateList om_(Resources resources, int i, Resources.Theme theme) { return resources.getColorStateList(i, theme); } static int ol_(Resources resources, int i, Resources.Theme theme) { return resources.getColor(i, theme); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class HBt { static Drawable oj_(Resources resources, int i, Resources.Theme theme) { return resources.getDrawable(i, theme); } static Drawable ok_(Resources resources, int i, int i2, Resources.Theme theme) { return resources.getDrawableForDensity(i, i2, theme); } } /* loaded from: classes.dex */ public static final class ZqN { public static void os_(Resources.Theme theme) { if (Build.VERSION.SDK_INT >= 29) { Sts.ou_(theme); } else { IeS.ot_(theme); } } /* loaded from: classes.dex */ static class Sts { static void ou_(Resources.Theme theme) { theme.rebase(); } } /* loaded from: classes.dex */ static class IeS { private static Method a; private static final Object d = new Object(); private static boolean e; static void ot_(Resources.Theme theme) { synchronized (d) { if (!e) { try { Method declaredMethod = Resources.Theme.class.getDeclaredMethod("rebase", new Class[0]); a = declaredMethod; declaredMethod.setAccessible(true); } catch (NoSuchMethodException unused) { } e = true; } Method method = a; if (method != null) { try { method.invoke(theme, new Object[0]); } catch (IllegalAccessException | InvocationTargetException unused2) { a = null; } } } } } } }