package com.igaworks.ssp.part.splash; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; import com.igaworks.ssp.SSPErrorCode; import com.igaworks.ssp.common.adapter.BaseMediationAdapter; import com.igaworks.ssp.common.g; import com.igaworks.ssp.common.g.b; import com.igaworks.ssp.common.i; import com.igaworks.ssp.common.m.f; import com.igaworks.ssp.common.n.a; import com.igaworks.ssp.common.o.h; import com.igaworks.ssp.common.o.k; import com.igaworks.ssp.part.splash.listener.ISplashAdEventCallbackListener; import java.lang.ref.WeakReference; import java.util.concurrent.ConcurrentHashMap; /* loaded from: classes2.dex */ public class AdPopcornSSPSplashAd extends FrameLayout { /* renamed from: a, reason: collision with root package name */ private String f7270a; /* renamed from: b, reason: collision with root package name */ private String f7271b; /* renamed from: c, reason: collision with root package name */ private WeakReference f7272c; /* renamed from: d, reason: collision with root package name */ private f f7273d; /* renamed from: e, reason: collision with root package name */ private ISplashAdEventCallbackListener f7274e; /* renamed from: f, reason: collision with root package name */ private boolean f7275f; /* renamed from: g, reason: collision with root package name */ private boolean f7276g; /* renamed from: h, reason: collision with root package name */ private int f7277h; /* renamed from: i, reason: collision with root package name */ private boolean f7278i; /* renamed from: j, reason: collision with root package name */ private ConcurrentHashMap f7279j; /* renamed from: k, reason: collision with root package name */ private BaseMediationAdapter f7280k; /* renamed from: l, reason: collision with root package name */ private com.igaworks.ssp.part.splash.listener.a f7281l; /* renamed from: m, reason: collision with root package name */ com.igaworks.ssp.common.n.c f7282m; class a extends com.igaworks.ssp.common.o.c { /* renamed from: com.igaworks.ssp.part.splash.AdPopcornSSPSplashAd$a$a, reason: collision with other inner class name */ class RunnableC0095a implements Runnable { RunnableC0095a() { } @Override // java.lang.Runnable public void run() { AdPopcornSSPSplashAd.this.f7275f = false; AdPopcornSSPSplashAd.this.loadAd(); } } a() { } @Override // com.igaworks.ssp.common.o.c public void a() { new Handler(Looper.getMainLooper()).post(new RunnableC0095a()); } } class b implements com.igaworks.ssp.part.splash.listener.a { b() { } @Override // com.igaworks.ssp.part.splash.listener.a public void a(int i10) { AdPopcornSSPSplashAd.this.f7277h = i10; AdPopcornSSPSplashAd.this.e(); } @Override // com.igaworks.ssp.part.splash.listener.a public void onImpression() { AdPopcornSSPSplashAd.this.d(); } @Override // com.igaworks.ssp.part.splash.listener.a public void a(int i10, int i11) { try { if (AdPopcornSSPSplashAd.this.f7280k != null) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), "Fail in adapter : " + AdPopcornSSPSplashAd.this.f7280k.getNetworkName() + ", internalReason : " + i11); AdPopcornSSPSplashAd adPopcornSSPSplashAd = AdPopcornSSPSplashAd.this; adPopcornSSPSplashAd.a(adPopcornSSPSplashAd.f7280k); } if (AdPopcornSSPSplashAd.this.f7273d.d() == null) { AdPopcornSSPSplashAd.this.a(SSPErrorCode.NO_AD); return; } if (i10 >= AdPopcornSSPSplashAd.this.f7273d.d().a().size() - 1) { AdPopcornSSPSplashAd.this.a(SSPErrorCode.NO_AD); return; } AdPopcornSSPSplashAd.this.f7277h = i10 + 1; com.igaworks.ssp.common.b a10 = com.igaworks.ssp.common.b.a(AdPopcornSSPSplashAd.this.f7273d.d().a().get(AdPopcornSSPSplashAd.this.f7277h).a()); AdPopcornSSPSplashAd adPopcornSSPSplashAd2 = AdPopcornSSPSplashAd.this; adPopcornSSPSplashAd2.f7280k = adPopcornSSPSplashAd2.a(a10); AdPopcornSSPSplashAd.this.f7280k.setSplashMediationAdapterEventListener(this); AdPopcornSSPSplashAd.this.f7280k.loadSplashAd((Context) AdPopcornSSPSplashAd.this.f7272c.get(), AdPopcornSSPSplashAd.this.f7273d, AdPopcornSSPSplashAd.this.f7277h, AdPopcornSSPSplashAd.this); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); AdPopcornSSPSplashAd.this.a(SSPErrorCode.EXCEPTION); } } } class c implements com.igaworks.ssp.common.n.c { c() { } @Override // com.igaworks.ssp.common.n.c public void a(a.d dVar, String str, String str2, boolean z10) { if (dVar == a.d.SPLASH_AD) { try { if (z10) { AdPopcornSSPSplashAd.this.a(SSPErrorCode.SERVER_TIMEOUT); return; } if (k.b(str)) { AdPopcornSSPSplashAd.this.a(SSPErrorCode.UNKNOWN_SERVER_ERROR); return; } if (!h.b(((Context) AdPopcornSSPSplashAd.this.f7272c.get()).getApplicationContext())) { AdPopcornSSPSplashAd.this.a(SSPErrorCode.NETWORK_IS_NOT_ONLINE); return; } f f10 = com.igaworks.ssp.common.l.a.f(str); if (f10 != null && f10.f() != 1) { AdPopcornSSPSplashAd.this.a(f10.f()); return; } AdPopcornSSPSplashAd.this.f7273d = f10; if (AdPopcornSSPSplashAd.this.f7273d != null && AdPopcornSSPSplashAd.this.f7273d.c() != null) { i.a((Context) AdPopcornSSPSplashAd.this.f7272c.get(), AdPopcornSSPSplashAd.this.f7273d.c()); } AdPopcornSSPSplashAd.this.c(); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); AdPopcornSSPSplashAd.this.a(SSPErrorCode.EXCEPTION); } } } } public AdPopcornSSPSplashAd(Context context) { super(context); this.f7275f = false; this.f7276g = false; this.f7277h = 0; this.f7278i = false; this.f7281l = new b(); this.f7282m = new c(); this.f7272c = new WeakReference<>(context); } private void b() { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "internalStopAd : " + this.f7270a); setVisibility(8); } /* JADX INFO: Access modifiers changed from: private */ public void c() { BaseMediationAdapter baseMediationAdapter; Context context; f fVar; try { if (com.igaworks.ssp.common.o.b.c(this.f7273d)) { com.igaworks.ssp.common.o.b.a(this.f7273d, this.f7279j); BaseMediationAdapter a10 = a(com.igaworks.ssp.common.b.a(this.f7273d.d().a().get(this.f7277h).a())); this.f7280k = a10; a10.setSplashMediationAdapterEventListener(this.f7281l); baseMediationAdapter = this.f7280k; context = this.f7272c.get(); fVar = this.f7273d; } else { if (!com.igaworks.ssp.common.o.b.a(this.f7273d)) { a(this.f7273d.f()); return; } BaseMediationAdapter a11 = a(com.igaworks.ssp.common.b.ADPOPCORN); this.f7280k = a11; a11.setSplashMediationAdapterEventListener(this.f7281l); baseMediationAdapter = this.f7280k; context = this.f7272c.get(); fVar = this.f7273d; } baseMediationAdapter.loadSplashAd(context, fVar, this.f7277h, this); } catch (Exception e10) { e10.printStackTrace(); a(SSPErrorCode.EXCEPTION); } } public void destroy() { try { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "splashAd destroy : " + this.f7270a); this.f7276g = false; this.f7275f = false; BaseMediationAdapter baseMediationAdapter = this.f7280k; if (baseMediationAdapter != null) { baseMediationAdapter.destroySplashAd(); this.f7280k.setSplashMediationAdapterEventListener(null); this.f7280k = null; } if (this.f7273d != null) { this.f7273d = null; } g.e().b(this); a(); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); } } public boolean isFullscreenSplash() { return this.f7278i; } public boolean isLoaded() { return this.f7276g; } public void loadAd() { com.igaworks.ssp.common.n.c cVar; int i10; String str; String str2; a.d dVar; Context context; try { if (!g.e().d()) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), this.f7270a + " : GDPR_CONSENT_UNAVAILABLE"); a(SSPErrorCode.GDPR_CONSENT_UNAVAILABLE); return; } if (this.f7275f) { com.igaworks.ssp.common.o.m.a.b(Thread.currentThread(), this.f7270a + " : SplashAd In Progress!!"); return; } this.f7277h = 0; this.f7275f = true; String str3 = this.f7270a; if (str3 != null && str3.length() != 0) { if (!g.e().i()) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "Checking ADID..."); g.e().a(new a()); g e10 = g.e(); e10.getClass(); e10.new b(this.f7272c.get().getApplicationContext()).start(); return; } com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "load SplashAd : " + this.f7270a); if (!h.b(this.f7272c.get().getApplicationContext())) { a(SSPErrorCode.NETWORK_IS_NOT_ONLINE); return; } com.igaworks.ssp.common.n.a b10 = g.e().b(); if (this.f7278i) { Context applicationContext = this.f7272c.get().getApplicationContext(); a.d dVar2 = a.d.SPLASH_AD; String str4 = this.f7270a; str = this.f7271b; cVar = this.f7282m; i10 = 2; dVar = dVar2; str2 = str4; context = applicationContext; } else { Context applicationContext2 = this.f7272c.get().getApplicationContext(); a.d dVar3 = a.d.SPLASH_AD; String str5 = this.f7270a; String str6 = this.f7271b; cVar = this.f7282m; i10 = 1; str = str6; str2 = str5; dVar = dVar3; context = applicationContext2; } b10.a(context, dVar, str2, str, i10, cVar); return; } a(SSPErrorCode.INVALID_PLACEMENT_ID); } catch (Exception unused) { this.f7275f = false; } } @Override // android.view.View protected void onVisibilityChanged(View view, int i10) { super.onVisibilityChanged(view, i10); BaseMediationAdapter baseMediationAdapter = this.f7280k; if (baseMediationAdapter != null) { baseMediationAdapter.checkAdPopcornSSPNativeImpression(); } } @Override // android.view.View public void onWindowFocusChanged(boolean z10) { super.onWindowFocusChanged(z10); BaseMediationAdapter baseMediationAdapter = this.f7280k; if (baseMediationAdapter != null) { baseMediationAdapter.checkAdPopcornSSPNativeImpression(); } } public void setFullScreenSplash(boolean z10) { this.f7278i = z10; } public void setPlacementAppKey(String str) { this.f7271b = str; } public void setPlacementId(String str) { this.f7270a = str; g.e().a(this); } public void setSplashAdEventCallbackListener(ISplashAdEventCallbackListener iSplashAdEventCallbackListener) { this.f7274e = iSplashAdEventCallbackListener; } public AdPopcornSSPSplashAd(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.f7275f = false; this.f7276g = false; this.f7277h = 0; this.f7278i = false; this.f7281l = new b(); this.f7282m = new c(); this.f7272c = new WeakReference<>(context); } /* JADX INFO: Access modifiers changed from: private */ public void d() { ISplashAdEventCallbackListener iSplashAdEventCallbackListener = this.f7274e; if (iSplashAdEventCallbackListener != null) { iSplashAdEventCallbackListener.onImpression(); } } /* JADX INFO: Access modifiers changed from: private */ public void e() { this.f7275f = false; this.f7276g = true; ISplashAdEventCallbackListener iSplashAdEventCallbackListener = this.f7274e; if (iSplashAdEventCallbackListener != null) { iSplashAdEventCallbackListener.onSplashAdLoadSuccess(); } } public AdPopcornSSPSplashAd(Context context, String str) { super(context); this.f7275f = false; this.f7276g = false; this.f7277h = 0; this.f7278i = false; this.f7281l = new b(); this.f7282m = new c(); this.f7272c = new WeakReference<>(context); this.f7271b = str; } /* JADX INFO: Access modifiers changed from: private */ public BaseMediationAdapter a(com.igaworks.ssp.common.b bVar) { if (this.f7279j == null) { this.f7279j = new ConcurrentHashMap<>(); } BaseMediationAdapter baseMediationAdapter = this.f7279j.get(bVar); if (baseMediationAdapter == null && (baseMediationAdapter = bVar.d()) != null) { this.f7279j.put(bVar, baseMediationAdapter); } return baseMediationAdapter; } private void a() { ConcurrentHashMap concurrentHashMap = this.f7279j; if (concurrentHashMap != null) { concurrentHashMap.clear(); this.f7279j = null; } } /* JADX INFO: Access modifiers changed from: private */ public void a(int i10) { this.f7275f = false; this.f7276g = false; ISplashAdEventCallbackListener iSplashAdEventCallbackListener = this.f7274e; if (iSplashAdEventCallbackListener != null) { iSplashAdEventCallbackListener.onSplashAdLoadFailed(new SSPErrorCode(i10)); } b(); } /* JADX INFO: Access modifiers changed from: private */ public void a(BaseMediationAdapter baseMediationAdapter) { if (baseMediationAdapter == null) { return; } baseMediationAdapter.setSplashMediationAdapterEventListener(null); baseMediationAdapter.destroySplashAd(); } }