package com.ironsource; import android.app.Activity; import com.ironsource.c2; import com.ironsource.k7; import com.ironsource.mediationsdk.IronSource; import com.ironsource.mediationsdk.adunit.adapter.internal.AdapterAdFullScreenInterface; import com.ironsource.mediationsdk.adunit.adapter.internal.BaseAdAdapter; import com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener; import com.ironsource.mediationsdk.logger.IronLog; import com.ironsource.mediationsdk.logger.IronSourceError; import com.ironsource.mediationsdk.model.Placement; import java.util.Locale; /* loaded from: classes2.dex */ public abstract class g7 extends k7 implements AdapterAdInteractionListener { public class a extends yp { public a() { } @Override // com.ironsource.yp public void a() { g7.this.P(); } } public class b extends yp { public b() { } @Override // com.ironsource.yp public void a() { g7.this.S(); } } public class c extends yp { public c() { } @Override // com.ironsource.yp public void a() { g7.this.Q(); } } public class d extends yp { public d() { } @Override // com.ironsource.yp public void a() { g7.this.T(); } } public class e extends yp { public e() { } @Override // com.ironsource.yp public void a() { g7.this.R(); } } public class f extends yp { final /* synthetic */ int a; final /* synthetic */ String b; public f(int i, String str) { this.a = i; this.b = str; } @Override // com.ironsource.yp public void a() { g7.this.b(this.a, this.b); } } public g7(ko koVar, i1 i1Var, BaseAdAdapter baseAdAdapter, v2 v2Var, f5 f5Var, Listener listener) { super(koVar, i1Var, baseAdAdapter, v2Var, f5Var, listener); } /* JADX INFO: Access modifiers changed from: private */ public void P() { String str; IronLog ironLog = IronLog.INTERNAL; ironLog.verbose(d()); synchronized (this.q) { try { if (this.e != k7.h.SHOWING) { ironLog.error("unexpected ad closed for " + k() + " - state = " + this.e); x1 x1Var = this.d; if (x1Var != null) { x1Var.k.j("unexpected ad closed - state = " + this.e); } return; } a(k7.h.NONE); if (this.d != null) { String str2 = ""; if (this.a.a() == IronSource.AD_UNIT.REWARDED_VIDEO) { String d2 = ((c2) this.b).d(); StringBuilder sb = new StringBuilder(); sb.append("otherInstanceAvailable = "); if (d2.length() > 0) { str = "true|" + d2; } else { str = "false"; } sb.append(str); str2 = sb.toString(); } this.d.j.a(j(), str2); } ((c2) this.b).a(this); } catch (Throwable th) { throw th; } } } /* JADX INFO: Access modifiers changed from: private */ public void Q() { IronLog.INTERNAL.verbose(d()); x1 x1Var = this.d; if (x1Var != null) { x1Var.j.d(j()); } ((c2) this.b).c(this); } /* JADX INFO: Access modifiers changed from: private */ public void R() { IronLog.INTERNAL.verbose(d()); x1 x1Var = this.d; if (x1Var != null) { x1Var.j.l(j()); } ((c2) this.b).b((g7) this); } /* JADX INFO: Access modifiers changed from: private */ public void S() { IronLog.INTERNAL.verbose(d()); x1 x1Var = this.d; if (x1Var != null) { x1Var.j.i(j()); } ((c2) this.b).d(this); } /* JADX INFO: Access modifiers changed from: private */ public void T() { IronLog.INTERNAL.verbose(d()); x1 x1Var = this.d; if (x1Var != null) { x1Var.j.k(j()); } } public static String a(k7.h hVar, int i, String str) { return String.format(Locale.ENGLISH, "unexpected show failed, state - %s, error - %d %s", hVar, Integer.valueOf(i), str); } /* JADX INFO: Access modifiers changed from: private */ public void b(int i, String str) { IronLog ironLog = IronLog.INTERNAL; ironLog.verbose(a("error = " + i + ", " + str)); k7.h hVar = this.e; if (hVar == k7.h.SHOWING) { a(k7.h.FAILED); x1 x1Var = this.d; if (x1Var != null) { x1Var.j.a(j(), i, str, ""); } ((c2) this.b).a(new IronSourceError(i, str), (g7) this); return; } String a2 = a(hVar, i, str); ironLog.error(a(a2)); x1 x1Var2 = this.d; if (x1Var2 != null) { x1Var2.k.r(a2); } } @Override // com.ironsource.k7 public boolean B() { Object obj; if (this.k == null || !y()) { return false; } try { obj = this.c; } catch (Throwable th) { i9.d().a(th); String str = "isReadyToShow - exception = " + th.getMessage() + " - state = " + this.e; IronLog.INTERNAL.error(a(str)); x1 x1Var = this.d; if (x1Var != null) { x1Var.k.f(str); } } if (obj instanceof AdapterAdFullScreenInterface) { return ((AdapterAdFullScreenInterface) obj).isAdAvailable(this.k); } IronLog.INTERNAL.error(a("isReadyToShow - adapter not instance of AdapterAdFullScreenInterface")); x1 x1Var2 = this.d; if (x1Var2 != null) { x1Var2.k.f("isReadyToShow - adapter not instance of AdapterAdFullScreenInterface"); } return false; } public void a(Activity activity, Placement placement) { IronLog ironLog = IronLog.INTERNAL; ironLog.verbose(a("placementName = " + placement.getPlacementName())); try { this.g = placement; a(k7.h.SHOWING); this.d.j.a(activity, j()); Object obj = this.c; if (obj instanceof AdapterAdFullScreenInterface) { ((AdapterAdFullScreenInterface) obj).showAd(this.k, this); } else { ironLog.error(a("showAd - adapter not instance of AdapterAdFullScreenInterface")); x1 x1Var = this.d; if (x1Var != null) { x1Var.k.f("showAd - adapter not instance of AdapterAdFullScreenInterface"); } } } catch (Throwable th) { i9.d().a(th); a(k7.h.FAILED); String str = "showAd - exception = " + th.getMessage() + " - state = " + this.e; IronLog.INTERNAL.error(a(str)); x1 x1Var2 = this.d; if (x1Var2 != null) { x1Var2.k.f(str); } onAdShowFailed(t1.h(this.a.a()), str); } } public void b(boolean z) { x1 x1Var = this.d; if (x1Var != null) { x1Var.j.a(z); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdClosed() { if (u().c()) { u().a(new a()); } else { P(); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdEnded() { if (u().c()) { u().a(new c()); } else { Q(); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdShowFailed(int i, String str) { if (u().c()) { u().a(new f(i, str)); } else { b(i, str); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdShowSuccess() { if (u().c()) { u().a(new e()); } else { R(); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdStarted() { if (u().c()) { u().a(new b()); } else { S(); } } @Override // com.ironsource.mediationsdk.adunit.adapter.internal.listener.AdapterAdInteractionListener public void onAdVisible() { if (u().c()) { u().a(new d()); } else { T(); } } }