package com.igaworks.ssp.part.custom; import android.content.Context; import android.os.Handler; import android.os.Looper; import com.igaworks.ssp.CustomAdType; import com.igaworks.ssp.SSPErrorCode; 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.n.c; import com.igaworks.ssp.common.o.h; import com.igaworks.ssp.common.o.k; import com.igaworks.ssp.part.custom.listener.ICustomAdListener; import java.util.List; import org.json.JSONObject; /* loaded from: classes2.dex */ public class AdPopcornSSPCustomAd { /* renamed from: a, reason: collision with root package name */ private String f6948a; /* renamed from: b, reason: collision with root package name */ private String f6949b; /* renamed from: c, reason: collision with root package name */ private CustomAdType f6950c; /* renamed from: d, reason: collision with root package name */ private Context f6951d; /* renamed from: e, reason: collision with root package name */ private f f6952e; /* renamed from: f, reason: collision with root package name */ private ICustomAdListener f6953f; /* renamed from: g, reason: collision with root package name */ c f6954g = new b(); class a extends com.igaworks.ssp.common.o.c { /* renamed from: com.igaworks.ssp.part.custom.AdPopcornSSPCustomAd$a$a, reason: collision with other inner class name */ class RunnableC0089a implements Runnable { RunnableC0089a() { } @Override // java.lang.Runnable public void run() { AdPopcornSSPCustomAd.this.loadAd(); } } a() { } @Override // com.igaworks.ssp.common.o.c public void a() { new Handler(Looper.getMainLooper()).post(new RunnableC0089a()); } } class b implements c { b() { } @Override // com.igaworks.ssp.common.n.c public void a(a.d dVar, String str, String str2, boolean z10) { String y10; try { if (z10) { AdPopcornSSPCustomAd.this.a(SSPErrorCode.SERVER_TIMEOUT); return; } if (k.b(str)) { AdPopcornSSPCustomAd.this.a(SSPErrorCode.UNKNOWN_SERVER_ERROR); return; } f f10 = com.igaworks.ssp.common.l.a.f(str); if (f10 != null && f10.f() != 1) { AdPopcornSSPCustomAd.this.a(f10.f()); return; } AdPopcornSSPCustomAd.this.f6952e = f10; if (AdPopcornSSPCustomAd.this.f6952e != null && AdPopcornSSPCustomAd.this.f6952e.c() != null) { i.a(AdPopcornSSPCustomAd.this.f6951d, AdPopcornSSPCustomAd.this.f6952e.c()); } if (!com.igaworks.ssp.common.o.b.a(AdPopcornSSPCustomAd.this.f6952e)) { AdPopcornSSPCustomAd.this.a(SSPErrorCode.NO_AD); return; } if (AdPopcornSSPCustomAd.this.f6950c == CustomAdType.NATIVE_AD) { JSONObject jSONObject = new JSONObject(); jSONObject.put("IconImageURL", AdPopcornSSPCustomAd.this.f6952e.a().get(0).g()); jSONObject.put("MainImageURL", AdPopcornSSPCustomAd.this.f6952e.a().get(0).n()); jSONObject.put("Title", AdPopcornSSPCustomAd.this.f6952e.a().get(0).v()); jSONObject.put("Desc", AdPopcornSSPCustomAd.this.f6952e.a().get(0).c()); jSONObject.put("CtaText", AdPopcornSSPCustomAd.this.f6952e.a().get(0).a()); jSONObject.put("PrivacyPolicyImageURL", AdPopcornSSPCustomAd.this.f6952e.a().get(0).r()); jSONObject.put("PrivacyPolicyURL", AdPopcornSSPCustomAd.this.f6952e.a().get(0).s()); jSONObject.put("LandingURL", AdPopcornSSPCustomAd.this.f6952e.a().get(0).l()); if (AdPopcornSSPCustomAd.this.f6952e.a().get(0).u() == 0) { jSONObject.put("TemplateNo", 20); } else { jSONObject.put("TemplateNo", AdPopcornSSPCustomAd.this.f6952e.a().get(0).u()); } y10 = jSONObject.toString(); } else { y10 = AdPopcornSSPCustomAd.this.f6952e.a().get(0).y(); } AdPopcornSSPCustomAd.this.a(y10); try { if (k.a(AdPopcornSSPCustomAd.this.f6952e.a().get(0).A())) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "Call Custom Win notice : " + AdPopcornSSPCustomAd.this.f6952e.a().get(0).A()); g.e().b().a(AdPopcornSSPCustomAd.this.f6951d, a.d.WIN_NOTICE, AdPopcornSSPCustomAd.this.f6952e.a().get(0).A()); } } catch (Exception unused) { } } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); AdPopcornSSPCustomAd.this.a(SSPErrorCode.EXCEPTION); } } } public AdPopcornSSPCustomAd(Context context) { this.f6951d = context; } public List getClickTrackersList() { try { com.igaworks.ssp.common.m.a aVar = this.f6952e.a().get(0); if (aVar != null) { return aVar.b(); } return null; } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "getClickTrackersList exception : " + e10.getMessage()); return null; } } public List getImpTrackersList() { try { com.igaworks.ssp.common.m.a aVar = this.f6952e.a().get(0); if (aVar != null) { return aVar.j(); } return null; } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "getImpTrackersList exception : " + e10.getMessage()); return null; } } public String getPlacementId() { return this.f6948a; } public void loadAd() { try { if (!g.e().d()) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), this.f6948a + " : GDPR_CONSENT_UNAVAILABLE"); a(SSPErrorCode.GDPR_CONSENT_UNAVAILABLE); return; } String str = this.f6948a; if (str != null && str.length() != 0) { if (this.f6950c == null) { this.f6950c = CustomAdType.BANNER_320x50; } 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.f6951d.getApplicationContext()).start(); return; } g.e().a(this); com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "loadAd : " + this.f6948a); if (!h.b(this.f6951d.getApplicationContext())) { a(SSPErrorCode.NETWORK_IS_NOT_ONLINE); return; } a.d dVar = a.d.POST_BANNER_320x50; CustomAdType customAdType = this.f6950c; if (customAdType != CustomAdType.BANNER_320x50) { if (customAdType == CustomAdType.BANNER_320x100) { dVar = a.d.POST_BANNER_320x100; } else if (customAdType == CustomAdType.BANNER_300x250) { dVar = a.d.POST_BANNER_300x250; } else if (customAdType == CustomAdType.INTERSTITIAL) { dVar = a.d.POST_INTERSTITIAL; } else if (customAdType == CustomAdType.NATIVE_AD) { dVar = a.d.NATIVE_AD; } } g.e().b().a(this.f6951d.getApplicationContext(), dVar, this.f6948a, this.f6949b, false, this.f6954g); return; } a(SSPErrorCode.INVALID_PLACEMENT_ID); } catch (Exception unused) { a(SSPErrorCode.EXCEPTION); } } public void reportClick() { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "called reportClick"); try { com.igaworks.ssp.common.m.a aVar = this.f6952e.a().get(0); for (int i10 = 0; i10 < aVar.b().size(); i10++) { String str = aVar.b().get(i10); if (k.a(str)) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), String.format("reportClick url : %s ", str)); g.e().b().a(this.f6951d, a.d.CLICK_REPORT_URL, str); } } } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "reportClick exception : " + e10.getMessage()); } } public void reportImpression() { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "called reportImpression"); try { if (com.igaworks.ssp.common.o.b.a(this.f6952e)) { try { com.igaworks.ssp.common.m.a aVar = this.f6952e.a().get(0); for (int i10 = 0; i10 < aVar.j().size(); i10++) { String str = aVar.j().get(i10); if (k.a(str)) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), String.format("", str)); g.e().b().a(this.f6951d, a.d.IMPRESSION, str); } } } catch (Exception unused) { } } } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "reportImpression exception : " + e10.getMessage()); } } public void setAdType(CustomAdType customAdType) { this.f6950c = customAdType; } public void setCustomAdEventCallbackListener(ICustomAdListener iCustomAdListener) { this.f6953f = iCustomAdListener; } public void setPlacementAppKey(String str) { this.f6949b = str; } public void setPlacementId(String str) { this.f6948a = str; g.e().a(this); } public void stopAd() { try { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "stopAd : " + this.f6948a); if (this.f6952e != null) { this.f6952e = null; } g.e().b(this); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); } } public AdPopcornSSPCustomAd(Context context, String str) { this.f6951d = context; this.f6949b = str; } private void a() { com.igaworks.ssp.common.o.m.a.c(Thread.currentThread(), "internalStopAd : " + this.f6948a); if (this.f6952e != null) { this.f6952e = null; } } /* JADX INFO: Access modifiers changed from: private */ public void a(int i10) { ICustomAdListener iCustomAdListener = this.f6953f; if (iCustomAdListener != null) { iCustomAdListener.OnCustomAdReceiveFailed(this.f6948a, new SSPErrorCode(i10)); } a(); } /* JADX INFO: Access modifiers changed from: private */ public void a(String str) { ICustomAdListener iCustomAdListener = this.f6953f; if (iCustomAdListener != null) { iCustomAdListener.OnCustomAdReceiveSuccess(this.f6948a, str); } } }