package f7; import android.app.Application; import android.content.Context; import android.text.TextUtils; import com.google.android.gms.ads.RequestConfiguration; import com.mobon.sdk.e; import com.unity3d.services.core.device.reader.JsonStorageKeyNames; import java.util.ArrayList; import java.util.Iterator; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes2.dex */ public class h { /* renamed from: a, reason: collision with root package name */ private final Context f9628a; /* renamed from: b, reason: collision with root package name */ private String f9629b; /* renamed from: c, reason: collision with root package name */ private ArrayList f9630c; /* renamed from: d, reason: collision with root package name */ private boolean f9631d; /* renamed from: e, reason: collision with root package name */ private b f9632e; /* renamed from: f, reason: collision with root package name */ private int f9633f = 0; /* renamed from: g, reason: collision with root package name */ private h7.e f9634g; class a extends g { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ h7.e f9635a; a(h7.e eVar) { this.f9635a = eVar; } @Override // f7.g public void a() { super.a(); if (h.this.f9631d) { h.this.f9631d = false; h.this.f9632e.c(); } f.a(h.this.f9632e.h() + " onAdCancel"); this.f9635a.b(); } @Override // f7.g public void b() { super.b(); f.a(h.this.f9632e.h() + " ADClicked"); this.f9635a.onAdClicked(); } @Override // f7.g public void c() { super.c(); if (h.this.f9631d) { h.this.f9631d = false; h.this.f9632e.c(); } f.a(h.this.f9632e.h() + " onAdClosed"); this.f9635a.onAdClosed(); } @Override // f7.g public void f(String str) { super.f(str); f.a(h.this.f9632e.h() + " AD FailLoad: " + str); if (h.this.f9630c.size() > 0) { h.this.a(this.f9635a); } else { this.f9635a.c(str); } } @Override // f7.g public void g() { super.g(); f.a(h.this.f9632e.h() + " onAdImpression"); this.f9635a.onAdImpression(); } @Override // f7.g public void h() { super.h(); f.a(h.this.f9632e.h() + " ADLoaded"); if (!h.this.f9632e.h().equalsIgnoreCase("admixer") || "ENDING".equals(h.this.f9629b) || "INTERSTITIAL".equals(h.this.f9629b) || "INTERSTITIAL_POPUP".equals(h.this.f9629b) || "MEDIATION_ADFIT_SMALL".equals(h.this.f9629b)) { this.f9635a.d(h.this.f9632e); } } @Override // f7.g public void i() { super.i(); this.f9635a.e(); } } public h(Context context, JSONObject jSONObject, String str) { this.f9628a = context; this.f9629b = str; h(jSONObject); } private boolean i(String str) { try { return new JSONObject(str).getJSONArray("client").getJSONObject(0).getJSONArray(JsonStorageKeyNames.DATA_KEY).length() != 0; } catch (Exception unused) { return false; } } public synchronized boolean a(h7.e eVar) { this.f9634g = eVar; int size = this.f9630c.size(); int i10 = this.f9633f; if (size <= i10) { eVar.c("No fill"); return false; } ArrayList arrayList = this.f9630c; this.f9633f = i10 + 1; b bVar = (b) arrayList.get(i10); this.f9632e = bVar; if (bVar.h().toLowerCase().equals("mobon")) { eVar.a(this.f9632e.d(), this.f9632e); return i(this.f9632e.d()); } String str = null; if (this.f9632e.h().toLowerCase().equals("appbacon")) { Iterator it = this.f9630c.iterator(); while (it.hasNext()) { b bVar2 = (b) it.next(); if (bVar2.h().toLowerCase().equals("mobon")) { str = bVar2.d(); } } eVar.a(str, this.f9632e); return true; } if (!this.f9632e.h().toLowerCase().equals("mbadapter") && !this.f9632e.h().toLowerCase().equals("mbmixadapter")) { if (!this.f9632e.p()) { b bVar3 = this.f9632e; bVar3.r(this.f9628a, bVar3.f()); if (this.f9632e.h().toLowerCase().contains("criteo")) { Application e10 = com.mobon.sdk.f.c(this.f9628a).e(); if (e10 == null) { f.a(this.f9632e.h() + " Adapter Application NULL!!!!"); if (this.f9630c.size() > 0) { a(eVar); } else { eVar.c(this.f9632e.h() + " Adapter Application NULL!!!!"); } return true; } this.f9632e.u(e10); } this.f9632e.w(f.d()); } b bVar4 = this.f9632e; if (!bVar4.m(bVar4.h())) { if (this.f9630c.size() > 0) { a(eVar); } else { eVar.c(this.f9632e.h() + " init() error"); } return true; } this.f9632e.t(new a(eVar)); this.f9632e.q(); if (this.f9632e.h().equalsIgnoreCase("admixer") && !"ENDING".equals(this.f9629b) && !"INTERSTITIAL".equals(this.f9629b) && !"INTERSTITIAL_POPUP".equals(this.f9629b) && !"MEDIATION_ADFIT_SMALL".equals(this.f9629b)) { eVar.d(this.f9632e); } return true; } Iterator it2 = this.f9630c.iterator(); while (it2.hasNext()) { b bVar5 = (b) it2.next(); if (bVar5.h().toLowerCase().equals("mobon")) { str = bVar5.d(); } } eVar.a(str, this.f9632e); return true; } public String g() { b bVar = this.f9632e; String h10 = bVar != null ? bVar.h() : RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; return TextUtils.isEmpty(h10) ? RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED : h10.toLowerCase(); } public void h(JSONObject jSONObject) { boolean z10; String str; this.f9633f = 0; if (this.f9630c == null) { this.f9630c = new ArrayList(); } try { JSONArray optJSONArray = jSONObject.optJSONArray("list"); for (int i10 = 0; i10 < optJSONArray.length(); i10++) { JSONObject jSONObject2 = optJSONArray.getJSONObject(i10); String optString = jSONObject2.optString("name"); String optString2 = jSONObject2.optString("unitid"); String optString3 = jSONObject2.optString("mediaKey"); Iterator it = this.f9630c.iterator(); while (true) { if (!it.hasNext()) { z10 = false; break; } b bVar = (b) it.next(); if (bVar.k().equals(optString2) && bVar.g().equals(optString3)) { if (optString.equals("mobon")) { bVar.s(jSONObject2.optString(JsonStorageKeyNames.DATA_KEY)); } z10 = true; } } if (e.h(optString) && !TextUtils.isEmpty(optString2) && !TextUtils.isEmpty(this.f9629b) && !z10) { if (!e.b.FULL.toString().equals(this.f9629b)) { str = e.b.NORMAL.toString().equals(this.f9629b) ? "INTERSTITIAL_POPUP" : "INTERSTITIAL"; this.f9630c.add(new b(e.a(optString), optString3, optString2, this.f9629b, jSONObject2.optString(JsonStorageKeyNames.DATA_KEY), false, true)); f.a("AdapterList add : " + optString + " : " + optString2); } this.f9629b = str; this.f9630c.add(new b(e.a(optString), optString3, optString2, this.f9629b, jSONObject2.optString(JsonStorageKeyNames.DATA_KEY), false, true)); f.a("AdapterList add : " + optString + " : " + optString2); } } } catch (Exception e10) { e10.printStackTrace(); } } public boolean j() { h7.e eVar = this.f9634g; return eVar != null && a(eVar); } }