package com.fyber.inneractive.sdk.flow; import com.fyber.inneractive.sdk.external.InneractiveAdRequest; import com.fyber.inneractive.sdk.external.InneractiveAdSpot; import com.fyber.inneractive.sdk.external.InneractiveAdViewUnitController; import com.fyber.inneractive.sdk.external.InneractiveErrorCode; import com.fyber.inneractive.sdk.external.InneractiveInfrastructureError; import com.fyber.inneractive.sdk.flow.t; import com.fyber.inneractive.sdk.interfaces.a; import com.fyber.inneractive.sdk.network.k; import com.fyber.inneractive.sdk.util.IAlog; import java.util.HashMap; import java.util.Iterator; /* loaded from: classes2.dex */ public abstract class k implements k.a, a.InterfaceC0074a, a.b { public com.fyber.inneractive.sdk.interfaces.a a; public a b; public com.fyber.inneractive.sdk.config.global.s c; public com.fyber.inneractive.sdk.network.k d; public final String e; public boolean f = false; public interface a { } public k(String str) { this.e = str; } public final void a(InneractiveAdRequest inneractiveAdRequest, InneractiveInfrastructureError inneractiveInfrastructureError, com.fyber.inneractive.sdk.response.e eVar) { if (IAlog.a <= 3) { Thread.dumpStack(); } IAlog.e("%sgot onAdRequestFailed! with: %s", d(), inneractiveInfrastructureError.getErrorCode()); if (this.b != null) { if (eVar != null && eVar.i != null) { inneractiveInfrastructureError.setCause(new Exception(eVar.i + ": " + eVar.j)); } ((u) this.b).a(inneractiveAdRequest, inneractiveInfrastructureError, eVar); } } public void a(InneractiveAdRequest inneractiveAdRequest, com.fyber.inneractive.sdk.response.e eVar) { } public void b(InneractiveAdRequest inneractiveAdRequest) { } public final com.fyber.inneractive.sdk.response.e c() { Content content; com.fyber.inneractive.sdk.interfaces.a aVar = this.a; if (aVar == null || (content = ((h) aVar).c) == 0) { return null; } return content.d(); } public String d() { return IAlog.a(this); } @Override // com.fyber.inneractive.sdk.interfaces.a.InterfaceC0074a public void a(InneractiveAdRequest inneractiveAdRequest) { T t; f0 f0Var; IAlog.e("%sgot onAdLoaded!", d()); com.fyber.inneractive.sdk.interfaces.a aVar = this.a; if (aVar != null) { a aVar2 = this.b; if (aVar2 != null) { Content content = ((h) aVar).c; u uVar = (u) aVar2; t tVar = uVar.a; if (!tVar.j && (f0Var = tVar.f) != null && f0Var.supportsRefresh()) { if (uVar.a.f.canRefreshAd()) { t tVar2 = uVar.a; tVar2.e = content; content.a = inneractiveAdRequest; t.c cVar = tVar2.i; if (cVar != null) { cVar.onAdRefreshed(tVar2); } else { f0 f0Var2 = tVar2.f; if (f0Var2 instanceof InneractiveAdViewUnitController) { ((InneractiveAdViewUnitController) f0Var2).onAdRefreshed(tVar2); } } } else { t tVar3 = uVar.a; tVar3.getClass(); IAlog.a("%sad loaded successfully, but the selected unit controller has rejected the refresh!", IAlog.a(tVar3)); t tVar4 = uVar.a; tVar4.i.onAdRefreshFailed(tVar4, InneractiveErrorCode.CANCELLED); } } else { t tVar5 = uVar.a; tVar5.e = content; content.a = inneractiveAdRequest; Iterator it = tVar5.g.iterator(); while (it.hasNext()) { f0 f0Var3 = (f0) it.next(); if (f0Var3.supports(tVar5)) { tVar5.f = f0Var3; t tVar6 = uVar.a; InneractiveAdSpot.RequestListener requestListener = tVar6.b; if (requestListener != null) { requestListener.onInneractiveSuccessfulAdRequest(tVar6); } uVar.a.j = false; } } t tVar7 = uVar.a; tVar7.getClass(); IAlog.a("%sCannot find appropriate unit controller for unit: %s", IAlog.a(tVar7), uVar.a.e.d); j jVar = uVar.a.h; com.fyber.inneractive.sdk.response.e c = jVar != null ? jVar.c() : null; uVar.a(inneractiveAdRequest, new InneractiveInfrastructureError(InneractiveErrorCode.INVALID_INPUT, g.COULD_NOT_SELECT_UNIT_CONTROLLER, new Exception("Cannot find appropriate unit controller for unit: " + uVar.a.e.d)), c); t tVar8 = uVar.a; tVar8.e = null; tVar8.j = false; } String str = uVar.a.a; com.fyber.inneractive.sdk.metrics.d dVar = com.fyber.inneractive.sdk.metrics.d.d; dVar.a(str).h(); dVar.a(str).b(); t tVar9 = uVar.a; q qVar = tVar9.e; if (qVar != null && (t = qVar.b) != 0 && t.n != null) { q qVar2 = tVar9.e; T t2 = qVar2.b; InneractiveAdRequest inneractiveAdRequest2 = tVar9.c; String str2 = tVar9.a; com.fyber.inneractive.sdk.metrics.c cVar2 = new com.fyber.inneractive.sdk.metrics.c(t2, inneractiveAdRequest2, str2, t2.n, qVar2.c.c()); com.fyber.inneractive.sdk.metrics.g a2 = dVar.a(str2); HashMap j = a2.j(); if (!a2.a()) { IAlog.a("MetricCreativeReporter: Metric data not valid, data: %s", dVar.a(str2).toString()); } else { dVar.a.remove(str2); com.fyber.inneractive.sdk.util.p.a.execute(new com.fyber.inneractive.sdk.metrics.b(cVar2, a2, j)); } } } this.a = null; } b(inneractiveAdRequest); } @Override // com.fyber.inneractive.sdk.interfaces.a.InterfaceC0074a public final void a(InneractiveInfrastructureError inneractiveInfrastructureError) { Content content; IAlog.e("%sgot onFailedLoading! with: %s", d(), inneractiveInfrastructureError); com.fyber.inneractive.sdk.interfaces.a aVar = this.a; InneractiveAdRequest inneractiveAdRequest = (aVar == null || (content = ((h) aVar).c) == 0) ? null : content.a; com.fyber.inneractive.sdk.response.e c = c(); IAlog.e("%sgot handleFailedLoading! with: %s", d(), inneractiveInfrastructureError); a aVar2 = this.b; if (aVar2 != null) { ((u) aVar2).a(inneractiveAdRequest, inneractiveInfrastructureError, c); } a(inneractiveAdRequest, c); } public void a(boolean z) { this.f = true; com.fyber.inneractive.sdk.interfaces.a aVar = this.a; if (aVar == null || !z) { return; } aVar.cancel(); this.a = null; } }