package com.mbridge.msdk.widget.custom.a; import android.content.Context; import android.text.TextUtils; import android.util.Xml; import android.view.View; import android.view.ViewGroup; import androidx.constraintlayout.core.motion.utils.TypedValues; import com.mbridge.msdk.foundation.controller.a; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; import com.mbridge.msdk.widget.custom.b.d; import java.io.IOException; import java.io.InputStream; import java.lang.ref.SoftReference; import java.lang.reflect.Field; import java.util.HashMap; import org.xmlpull.v1.XmlPullParser; /* compiled from: MBResource */ public final class b { private static b g; private SoftReference<HashMap<String, c>> a; private SoftReference<HashMap<String, String>> b; private SoftReference<HashMap<String, c>> c; private String d; private String e; private Context f; private b() { } public static b a() { if (g == null) { g = new b(); } return g; } public final void a(String str) { this.f = a.f().j(); if (d.a) { this.d = this.f.getFilesDir().toString(); } else { this.d = str; } com.mbridge.msdk.widget.custom.b.a.a(this.f); this.e = "/drawable/"; d.a("屏幕:" + this.e); this.f = this.f; } public final HashMap b() { SoftReference<HashMap<String, c>> softReference = this.a; if (softReference == null || softReference.get() == null) { HashMap hashMap = new HashMap(); hashMap.put("layout_width", c.layout_width); hashMap.put("layout_height", c.layout_height); hashMap.put("orientation", c.orientation); hashMap.put("layout_centerHorizontal", c.layout_centerHorizontal); hashMap.put("layout_centerVertical", c.layout_centerVertical); hashMap.put("layout_marginLeft", c.layout_marginLeft); hashMap.put("layout_marginRight", c.layout_marginRight); hashMap.put("layout_margin", c.layout_margin); hashMap.put("layout_gravity", c.layout_gravity); hashMap.put("layout_alignParentRight", c.layout_alignParentRight); hashMap.put("layout_weight", c.layout_weight); hashMap.put("contentDescription", c.contentDescription); hashMap.put("gravity", c.gravity); hashMap.put("id", c.id); hashMap.put("layout_below", c.layout_below); hashMap.put("layout_above", c.layout_above); hashMap.put("layout_toLeftOf", c.layout_toLeftOf); hashMap.put("layout_toRightOf", c.layout_toRightOf); hashMap.put("background", c.background); hashMap.put("layout_marginTop", c.layout_marginTop); hashMap.put("layout_marginBottom", c.layout_marginBottom); hashMap.put("layout_marginLeft", c.layout_marginLeft); hashMap.put("layout_marginRight", c.layout_marginRight); hashMap.put("layout_alignParentBottom", c.layout_alignParentBottom); hashMap.put("layout_alignParentTop", c.layout_alignParentTop); hashMap.put("layout_alignParentLeft", c.layout_alignParentLeft); this.a = new SoftReference<>(hashMap); } return this.a.get(); } public final HashMap<String, c> c() { SoftReference<HashMap<String, c>> softReference = this.c; if (softReference == null || softReference.get() == null) { HashMap hashMap = new HashMap(); hashMap.put("id", c.id); hashMap.put("text", c.text); hashMap.put("ellipsize", c.ellipsize); hashMap.put("fadingEdge", c.fadingEdge); hashMap.put("scrollHorizontally", c.scrollHorizontally); hashMap.put("textColor", c.textColor); hashMap.put("textSize", c.textSize); hashMap.put("visibility", c.visibility); hashMap.put("background", c.background); hashMap.put("textStyle", c.textStyle); hashMap.put(TtmlNode.TAG_STYLE, c.L); hashMap.put("layout_width", c.layout_width); hashMap.put("layout_height", c.layout_height); hashMap.put("layout_below", c.layout_below); hashMap.put("contentDescription", c.contentDescription); hashMap.put("src", c.src); hashMap.put("gravity", c.gravity); hashMap.put("orientation", c.orientation); hashMap.put("numColumns", c.numColumns); hashMap.put("verticalSpacing", c.verticalSpacing); hashMap.put("horizontalSpacing", c.horizontalSpacing); hashMap.put("background", c.background); hashMap.put("layout_marginBottom", c.layout_marginBottom); hashMap.put("scaleType", c.scaleType); hashMap.put("singleLine", c.singleLine); hashMap.put("paddingBottom", c.paddingBottom); hashMap.put("paddingTop", c.paddingTop); hashMap.put("letterSpacing", c.letterSpacing); hashMap.put("paddingRight", c.paddingRight); hashMap.put("layout_right", c.layout_right); this.c = new SoftReference<>(hashMap); } return this.c.get(); } public final int b(String str) { if (TextUtils.isEmpty(str) || !str.startsWith("#")) { return -16777216; } int length = str.length(); if (length == 7) { return (int) Long.decode(str.replace("#", "#FF")).longValue(); } if (length == 9) { return (int) Long.decode(str).longValue(); } d.a("返回白色背景"); return -1; } public final int c(String str) { try { return Integer.parseInt(str); } catch (Exception unused) { int indexOf = str.indexOf("d"); int indexOf2 = str.indexOf("s"); if (indexOf == -1) { indexOf = indexOf2; } int parseInt = Integer.parseInt(str.substring(0, indexOf)); return str.contains("d") ? com.mbridge.msdk.widget.custom.b.a.a(this.f, parseInt) : parseInt; } } public final int d(String str) { String[] split = str.toUpperCase().split("\\|"); int i = 48; try { Class<?> cls = Class.forName("android.view.Gravity"); for (String str2 : split) { i |= cls.getField(str2).getInt(null); } } catch (Exception e2) { e2.printStackTrace(); } return i; } public final int a(Context context, String str) { String packageName = context.getPackageName(); StringBuilder sb = new StringBuilder(); sb.append(packageName); sb.append(".R$"); String[] split = str.split("\\."); System.out.println(split.toString()); sb.append(split[1]); try { Class<?> cls = Class.forName(sb.toString()); Object newInstance = cls.newInstance(); Field declaredField = cls.getDeclaredField(split[2]); declaredField.setAccessible(true); return ((Integer) declaredField.get(newInstance)).intValue(); } catch (Exception e2) { e2.printStackTrace(); return 0; } } public final String e(String str) { if (!str.startsWith("@")) { return str; } SoftReference<HashMap<String, String>> softReference = this.b; if (softReference == null || softReference.get() == null) { d.a("字符串变空了"); this.b = new SoftReference<>(d()); } return this.b.get().get(str.substring(8)); } private HashMap<String, String> d() { InputStream inputStream; try { inputStream = this.f.getAssets().open("strings.xml"); } catch (IOException e2) { e2.printStackTrace(); inputStream = null; } XmlPullParser newPullParser = Xml.newPullParser(); try { newPullParser.setInput(inputStream, "utf-8"); HashMap<String, String> hashMap = new HashMap<>(); for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) { if (eventType == 2 && TypedValues.Custom.S_STRING.equals(newPullParser.getName())) { hashMap.put(newPullParser.getAttributeValue(0), newPullParser.nextText()); } } return hashMap; } catch (Exception e3) { e3.printStackTrace(); return null; } } public final View f(String str) { a aVar = new a(this.f); return aVar.a(aVar.a(str), (ViewGroup) null, false); } }