package com.mbridge.msdk.foundation.db.a; import com.mbridge.msdk.foundation.controller.c; import com.mbridge.msdk.foundation.db.g; import com.mbridge.msdk.foundation.db.k; import java.util.Collection; import java.util.Iterator; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes4.dex */ public final class b { private com.mbridge.msdk.foundation.same.a.a a; private k b; public static class a { private static b a = new b(); } private b() { this.a = new com.mbridge.msdk.foundation.same.a.a(1000); try { k a2 = k.a(g.a(c.m().c())); this.b = a2; a(a2.a(), false); } catch (Throwable th) { th.printStackTrace(); } } public final void a(JSONObject jSONObject, final boolean z) { if (jSONObject != null) { Iterator keys = jSONObject.keys(); final com.mbridge.msdk.foundation.same.a.a aVar = new com.mbridge.msdk.foundation.same.a.a(100); while (keys.hasNext()) { String next = keys.next(); JSONObject optJSONObject = jSONObject.optJSONObject(next); this.a.a(next, optJSONObject); aVar.a(next, optJSONObject); } com.mbridge.msdk.foundation.same.f.a.b().execute(new Runnable() { // from class: com.mbridge.msdk.foundation.db.a.b.1 @Override // java.lang.Runnable public final void run() { if (!z || b.this.b == null) { return; } for (String str : aVar.a()) { b.this.b.a(str, b.this.a.a(str)); } } }); } } public static b a() { return a.a; } public final JSONArray b() { return new JSONArray((Collection) this.a.a()); } public final JSONObject a(String str) { k kVar; JSONObject a2 = this.a.a(str); if (a2 != null || (kVar = this.b) == null) { return a2; } JSONObject a3 = kVar.a(str); if (a3 != null) { this.a.a(str, a3); } return a3; } }