package com.applovin.impl.mediation.ads; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.applovin.impl.ar; import com.applovin.impl.br; import com.applovin.impl.e0; import com.applovin.impl.gc; import com.applovin.impl.ge; import com.applovin.impl.he; import com.applovin.impl.jn; import com.applovin.impl.la; import com.applovin.impl.mediation.MaxErrorImpl; import com.applovin.impl.mediation.ads.a; import com.applovin.impl.mediation.d; import com.applovin.impl.sdk.d; import com.applovin.impl.sdk.j; import com.applovin.impl.sdk.n; import com.applovin.impl.sdk.utils.CollectionUtils; import com.applovin.impl.sdk.utils.StringUtils; import com.applovin.impl.tm; import com.applovin.impl.v; import com.applovin.impl.ve; import com.applovin.impl.yl; import com.applovin.impl.yp; import com.applovin.impl.z3; import com.applovin.impl.zq; import com.applovin.mediation.MaxAd; import com.applovin.mediation.MaxAdFormat; import com.applovin.mediation.MaxAdListener; import com.applovin.mediation.MaxAdRevenueListener; import com.applovin.mediation.MaxAdViewAdListener; import com.applovin.mediation.MaxError; import com.applovin.mediation.ads.MaxAdView; import com.applovin.sdk.AppLovinSdkUtils; import com.google.ar.core.ImageMetadata; import csdk.gluads.Consts; import java.util.Locale; import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes2.dex */ public class MaxAdViewImpl extends com.applovin.impl.mediation.ads.a implements d.a, br.a, v.b { private boolean A; private final Context a; private final MaxAdView b; private final String c; private final View d; private long e; private he f; private String g; private String h; private final b i; private final d j; private final com.applovin.impl.sdk.d k; private final ar l; private final br m; private final Object n; private final Object o; private he p; private boolean q; private boolean r; private final AtomicBoolean s; private boolean t; private boolean u; private boolean v; private boolean w; private boolean x; private boolean y; private boolean z; public class b extends c { private b() { super(); } @Override // com.applovin.mediation.MaxAdListener public void onAdLoadFailed(String str, MaxError maxError) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdListener.onAdLoadFailed(adUnitId=" + str + ", error=" + maxError + "), listener=" + MaxAdViewImpl.this.adListener); } gc.a(MaxAdViewImpl.this.adListener, str, maxError, true); MaxAdViewImpl.this.a(maxError); } @Override // com.applovin.mediation.MaxAdListener public void onAdLoaded(MaxAd maxAd) { if (MaxAdViewImpl.this.a()) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "Precache ad with ad unit ID '" + MaxAdViewImpl.this.adUnitId + "' loaded after MaxAdView was destroyed. Destroying the ad."); } MaxAdViewImpl.this.sdk.Q().destroyAd(maxAd); return; } he heVar = (he) maxAd; heVar.g(MaxAdViewImpl.this.g); heVar.f(MaxAdViewImpl.this.h); if (heVar.y() == null) { MaxAdViewImpl.this.sdk.Q().destroyAd(heVar); onAdLoadFailed(heVar.getAdUnitId(), new MaxErrorImpl(-5001, "Ad view not fully loaded")); return; } if (heVar.u0()) { long p0 = heVar.p0(); MaxAdViewImpl.this.sdk.J(); if (n.a()) { MaxAdViewImpl.this.sdk.J().a(MaxAdViewImpl.this.tag, "Scheduling banner ad refresh " + p0 + " milliseconds from now for '" + MaxAdViewImpl.this.adUnitId + "'..."); } MaxAdViewImpl.this.k.a(p0); if (MaxAdViewImpl.this.k.g() || MaxAdViewImpl.this.r) { n nVar2 = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this; maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Pausing ad refresh for publisher"); } MaxAdViewImpl.this.k.j(); } } n nVar3 = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl3 = MaxAdViewImpl.this; maxAdViewImpl3.logger.a(maxAdViewImpl3.tag, "MaxAdListener.onAdLoaded(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.f(MaxAdViewImpl.this.adListener, maxAd, true); MaxAdViewImpl.this.d(heVar); } } public abstract class c implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0026a { private boolean a; private c() { } @Override // com.applovin.mediation.MaxAdListener public void onAdClicked(MaxAd maxAd) { if (maxAd.equals(MaxAdViewImpl.this.p)) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdListener.onAdClicked(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.a(MaxAdViewImpl.this.adListener, maxAd, true); } } @Override // com.applovin.mediation.MaxAdViewAdListener public void onAdCollapsed(MaxAd maxAd) { if (maxAd.equals(MaxAdViewImpl.this.p)) { if ((MaxAdViewImpl.this.p.v0() || MaxAdViewImpl.this.y) && this.a) { this.a = false; MaxAdViewImpl.this.startAutoRefresh(); } n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdViewAdListener.onAdCollapsed(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.b(MaxAdViewImpl.this.adListener, maxAd, true); } } @Override // com.applovin.mediation.MaxAdListener public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) { if (maxAd.equals(MaxAdViewImpl.this.p)) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdListener.onAdDisplayFailed(ad=" + maxAd + ", error=" + maxError + "), listener=" + MaxAdViewImpl.this.adListener); } gc.a(MaxAdViewImpl.this.adListener, maxAd, maxError, true); } } @Override // com.applovin.mediation.MaxAdListener public void onAdDisplayed(MaxAd maxAd) { if (maxAd.equals(MaxAdViewImpl.this.p)) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdListener.onAdDisplayed(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.c(MaxAdViewImpl.this.adListener, maxAd, true); } } @Override // com.applovin.mediation.MaxAdViewAdListener public void onAdExpanded(MaxAd maxAd) { if (maxAd.equals(MaxAdViewImpl.this.p)) { if ((MaxAdViewImpl.this.p.v0() || MaxAdViewImpl.this.y) && !MaxAdViewImpl.this.k.g()) { this.a = true; MaxAdViewImpl.this.stopAutoRefresh(); } n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdViewAdListener.onAdExpanded(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.d(MaxAdViewImpl.this.adListener, maxAd, true); } } @Override // com.applovin.mediation.MaxAdListener public void onAdHidden(MaxAd maxAd) { if (maxAd.equals(MaxAdViewImpl.this.p)) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdListener.onAdHidden(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.adListener); } gc.e(MaxAdViewImpl.this.adListener, maxAd, true); } } @Override // com.applovin.mediation.MaxAdRequestListener public void onAdRequestStarted(String str) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdRequestListener.onAdRequestStarted(adUnitId=" + str + "), listener=" + MaxAdViewImpl.this.requestListener); } gc.a(MaxAdViewImpl.this.requestListener, str, true); } @Override // com.applovin.mediation.MaxAdRevenueListener public void onAdRevenuePaid(MaxAd maxAd) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdRevenueListener.onAdRevenuePaid(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.revenueListener); } gc.a(MaxAdViewImpl.this.revenueListener, maxAd, true); } } public class d extends c { private d() { super(); } @Override // com.applovin.mediation.MaxAdListener public void onAdLoadFailed(String str, MaxError maxError) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "Failed to precache ad for refresh with error code: " + maxError.getCode()); } MaxAdViewImpl.this.a(maxError); } @Override // com.applovin.mediation.MaxAdListener public void onAdLoaded(MaxAd maxAd) { if (!MaxAdViewImpl.this.u) { n nVar = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this; maxAdViewImpl.logger.a(maxAdViewImpl.tag, "Successfully precached ad for refresh"); } if (((Boolean) MaxAdViewImpl.this.sdk.a(ve.j7)).booleanValue()) { MaxAdViewImpl.this.b(maxAd); return; } else { MaxAdViewImpl.this.a(maxAd); return; } } n nVar2 = MaxAdViewImpl.this.logger; if (n.a()) { MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this; maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Ad with ad unit ID '" + MaxAdViewImpl.this.adUnitId + "' loaded after MaxAdView was destroyed. Destroying the ad."); } MaxAdViewImpl.this.sdk.Q().destroyAd(maxAd); } } public MaxAdViewImpl(String str, MaxAdFormat maxAdFormat, MaxAdView maxAdView, View view, j jVar, Context context) { super(str, maxAdFormat, "MaxAdView", jVar); this.c = UUID.randomUUID().toString().toLowerCase(Locale.US); this.e = Long.MAX_VALUE; this.n = new Object(); this.o = new Object(); this.p = null; this.s = new AtomicBoolean(); this.u = false; if (context == null) { throw new IllegalArgumentException("No context specified"); } this.a = context.getApplicationContext(); this.b = maxAdView; this.d = view; this.i = new b(); this.j = new d(); this.k = new com.applovin.impl.sdk.d(jVar, this); this.l = new ar(maxAdView, jVar); this.m = new br(maxAdView, jVar, this); jVar.h().a(this); if (n.a()) { this.logger.a(this.tag, "Created new MaxAdView (" + this + ")"); } } @Override // com.applovin.impl.mediation.ads.a public void destroy() { g(); if (this.f != null) { this.sdk.Q().destroyAd(this.f); } synchronized (this.n) { this.u = true; } this.k.a(); this.sdk.h().b(this); this.sdk.K().c(this.adUnitId, this.c); super.destroy(); } public MaxAdFormat getAdFormat() { return this.adFormat; } public String getPlacement() { return this.g; } public void loadAd() { loadAd(d.b.PUBLISHER_INITIATED); } @Override // com.applovin.impl.sdk.d.a public void onAdRefresh() { if (((Boolean) this.sdk.a(ve.j7)).booleanValue()) { f(); } else { e(); } } @Override // com.applovin.impl.v.b public void onCreativeIdGenerated(String str, String str2) { he heVar = this.p; if (heVar != null && heVar.S().equalsIgnoreCase(str)) { this.p.h(str2); gc.b(this.adReviewListener, str2, this.p); return; } he heVar2 = this.f; if (heVar2 == null || !heVar2.S().equalsIgnoreCase(str)) { return; } this.f.h(str2); } @Override // com.applovin.impl.br.a public void onLogVisibilityImpression() { a(this.p, this.l.a(this.p)); } public void onWindowVisibilityChanged(int i) { if (((Boolean) this.sdk.a(ve.g7)).booleanValue() && this.k.h()) { if (zq.b(i)) { if (n.a()) { this.logger.a(this.tag, "Ad view visible"); } this.k.d(); } else { if (n.a()) { this.logger.a(this.tag, "Ad view hidden"); } this.k.c(); } } } @Override // com.applovin.impl.mediation.ads.a public void setExtraParameter(String str, String str2) { super.setExtraParameter(str, str2); a(str, str2); } public void setPublisherBackgroundColor(int i) { this.e = i; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("MaxAdView{adUnitId='"); sb.append(this.adUnitId); sb.append('\''); sb.append(", adListener="); Object obj = this.adListener; if (obj == this.b) { obj = "this"; } sb.append(obj); sb.append(", isDestroyed="); sb.append(a()); sb.append('}'); return sb.toString(); } private void e() { this.s.set(false); if (this.f != null) { h(); return; } if (!b()) { if (n.a()) { this.logger.a(this.tag, "Refreshing ad from network..."); } loadAd(d.b.REFRESH); } else if (this.q) { if (n.a()) { this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request..."); } loadAd(d.b.REFRESH); } else { if (n.a()) { this.logger.b(this.tag, "Ignoring attempt to refresh ad - either still waiting for precache or did not attempt request due to visibility requirement not met"); } this.s.set(true); } } private void f() { boolean z; boolean z2; synchronized (this.o) { try { z = false; this.s.set(false); z2 = this.f != null; if (!z2) { if (b()) { if (!this.q) { if (n.a()) { this.logger.b(this.tag, "Ignoring attempt to refresh ad - either still waiting for precache or did not attempt request due to visibility requirement not met"); } this.s.set(true); } else if (n.a()) { this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request..."); } } else if (n.a()) { this.logger.a(this.tag, "Refreshing ad from network..."); } z = true; } } catch (Throwable th) { throw th; } } if (z2) { h(); } else if (z) { loadAd(d.b.REFRESH); } } private void h() { if (n.a()) { this.logger.a(this.tag, "Rendering for cached ad: " + this.f + "..."); } this.i.onAdLoaded(this.f); this.f = null; } public void loadAd(d.b bVar) { if (n.a()) { this.logger.a(this.tag, "" + this + " Loading ad for " + this.adUnitId + "..."); } boolean z = this.v || ((Boolean) this.sdk.a(ve.i7)).booleanValue(); if (z && !this.k.g() && this.k.h()) { n.h(this.tag, "Unable to load a new ad. An ad refresh has already been scheduled in " + TimeUnit.MILLISECONDS.toSeconds(this.k.b()) + " seconds."); return; } if (!z) { if (n.a()) { this.logger.a(this.tag, "Loading ad..."); } a(bVar, this.i); } else if (this.f != null) { if (n.a()) { this.logger.a(this.tag, "Rendering cached ad"); } h(); } else if (this.t) { if (n.a()) { this.logger.a(this.tag, "Waiting for precache ad to load to render"); } this.s.set(true); } else { if (n.a()) { this.logger.a(this.tag, "Loading ad..."); } a(bVar, this.i); } } public void setCustomData(String str) { if (this.p != null && n.a()) { this.logger.k(this.tag, "Setting custom data (" + str + ") for Ad Unit ID (" + this.adUnitId + ") after an ad has been loaded already."); } yp.b(str, this.tag); this.h = str; } public void setPlacement(String str) { if (this.p != null && n.a()) { this.logger.k(this.tag, "Setting placement (" + str + ") for Ad Unit ID (" + this.adUnitId + ") after an ad has been loaded already."); } this.g = str; } public void startAutoRefresh() { this.r = false; if (this.k.g()) { this.k.m(); if (n.a()) { this.logger.a(this.tag, "Resumed auto-refresh with remaining time: " + this.k.b() + "ms"); return; } return; } if (n.a()) { this.logger.a(this.tag, "Ignoring call to startAutoRefresh() - ad refresh is not paused"); } } public void stopAutoRefresh() { if (this.p != null) { if (n.a()) { this.logger.a(this.tag, "Pausing auto-refresh with remaining time: " + this.k.b() + "ms"); } this.k.j(); return; } if (this.v || ((Boolean) this.sdk.a(ve.i7)).booleanValue()) { this.r = true; } else { n.j(this.tag, "Stopping auto-refresh has no effect until after the first ad has been loaded."); } } private void g() { he heVar; MaxAdView maxAdView = this.b; if (maxAdView != null) { e0.a(maxAdView, this.d); } this.m.b(); synchronized (this.n) { heVar = this.p; } if (heVar != null) { this.sdk.Q().destroyAd(heVar); } } /* JADX INFO: Access modifiers changed from: private */ public void d(final he heVar) { AppLovinSdkUtils.runOnUiThread(new Runnable() { // from class: com.applovin.impl.mediation.ads.MaxAdViewImpl$$ExternalSyntheticLambda2 @Override // java.lang.Runnable public final void run() { MaxAdViewImpl.this.b(heVar); } }); } private void d() { if (b()) { if (n.a()) { this.logger.a(this.tag, "Scheduling refresh precache request now"); } this.t = true; this.sdk.j0().a((yl) new jn(this.sdk, "loadMaxAdForPrecacheRequest", new Runnable() { // from class: com.applovin.impl.mediation.ads.MaxAdViewImpl$$ExternalSyntheticLambda3 @Override // java.lang.Runnable public final void run() { MaxAdViewImpl.this.c(); } }), tm.b.MEDIATION); } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void b(final he heVar) { View y = heVar.y(); String str = y == null ? "MaxAdView does not have a loaded ad view" : null; MaxAdView maxAdView = this.b; if (maxAdView == null) { str = "MaxAdView does not have a parent view"; } if (str != null) { if (n.a()) { this.logger.b(this.tag, str); } MaxErrorImpl maxErrorImpl = new MaxErrorImpl(-1, str); if (n.a()) { this.logger.a(this.tag, "MaxAdListener.onAdDisplayFailed(ad=" + heVar + ", error=" + maxErrorImpl + "), listener=" + this.adListener); } gc.a(this.adListener, (MaxAd) heVar, (MaxError) maxErrorImpl, true); this.sdk.Q().processAdDisplayErrorPostbackForUserError(maxErrorImpl, heVar); return; } g(); a((ge) heVar); if (heVar.o0()) { this.m.a(heVar); } maxAdView.setDescendantFocusability(ImageMetadata.HOT_PIXEL_MODE); if (heVar.q0() != Long.MAX_VALUE) { this.d.setBackgroundColor((int) heVar.q0()); } else { long j = this.e; if (j != Long.MAX_VALUE) { this.d.setBackgroundColor((int) j); } else { this.d.setBackgroundColor(0); } } maxAdView.addView(y); a(y, heVar); this.sdk.w().d(heVar); c(heVar); synchronized (this.n) { this.p = heVar; } if (n.a()) { this.logger.a(this.tag, "Scheduling impression for ad manually..."); } this.sdk.Q().processRawAdImpression(heVar, this.i); if (StringUtils.isValidString(this.p.getAdReviewCreativeId())) { gc.a(this.adReviewListener, this.p.getAdReviewCreativeId(), (MaxAd) this.p, true); } AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() { // from class: com.applovin.impl.mediation.ads.MaxAdViewImpl$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { MaxAdViewImpl.this.a(heVar); } }, heVar.s0()); } /* JADX INFO: Access modifiers changed from: private */ public void b(MaxAd maxAd) { boolean compareAndSet; this.t = false; synchronized (this.o) { try { compareAndSet = this.s.compareAndSet(true, false); if (!compareAndSet) { if (n.a()) { this.logger.a(this.tag, "Saving precache ad..."); } he heVar = (he) maxAd; this.f = heVar; heVar.g(this.g); this.f.f(this.h); } } catch (Throwable th) { throw th; } } if (compareAndSet) { if (n.a()) { this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "..."); } this.i.onAdLoaded(maxAd); } } private boolean b() { if (this.x) { return false; } return ((Boolean) this.sdk.a(ve.o7)).booleanValue(); } private void c(he heVar) { int height = this.b.getHeight(); int width = this.b.getWidth(); if (height > 0 || width > 0) { int pxToDp = AppLovinSdkUtils.pxToDp(this.a, height); int pxToDp2 = AppLovinSdkUtils.pxToDp(this.a, width); MaxAdFormat format = heVar.getFormat(); int height2 = (this.A ? format.getAdaptiveSize(pxToDp2, this.b.getContext()) : format.getSize()).getHeight(); int min = Math.min(format.getSize().getWidth(), z3.b(this.a).x); if (pxToDp < height2 || pxToDp2 < min) { StringBuilder sb = new StringBuilder(); sb.append("\n**************************************************\n`MaxAdView` size "); sb.append(pxToDp2); sb.append("x"); sb.append(pxToDp); sb.append(" dp smaller than required "); sb.append(this.A ? "adaptive " : ""); sb.append("size: "); sb.append(min); sb.append("x"); sb.append(height2); sb.append(" dp\nSome mediated networks (e.g. Google Ad Manager) may not render correctly\n**************************************************\n"); String sb2 = sb.toString(); if (n.a()) { this.logger.b("AppLovinSdk", sb2); } } } } private void a(View view, he heVar) { int t0 = heVar.t0(); int r0 = heVar.r0(); int dpToPx = t0 == -1 ? -1 : AppLovinSdkUtils.dpToPx(view.getContext(), t0); int dpToPx2 = r0 != -1 ? AppLovinSdkUtils.dpToPx(view.getContext(), r0) : -1; ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams == null) { layoutParams = new RelativeLayout.LayoutParams(dpToPx, dpToPx2); } else { layoutParams.width = dpToPx; layoutParams.height = dpToPx2; } if (layoutParams instanceof RelativeLayout.LayoutParams) { if (n.a()) { this.logger.a(this.tag, "Pinning ad view to MAX ad view with width: " + dpToPx + " and height: " + dpToPx2 + Consts.STRING_PERIOD); } RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams; for (int i : zq.a(this.b.getGravity(), 10, 14)) { layoutParams2.addRule(i); } } view.setLayoutParams(layoutParams); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void c() { if (n.a()) { this.logger.a(this.tag, "Loading ad for precache request..."); } a(d.b.SEQUENTIAL_OR_PRECACHE, this.j); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(he heVar) { long a2 = this.l.a(heVar); if (!heVar.o0()) { a(heVar, a2); } a(a2); } private void a(final d.b bVar, final a.InterfaceC0026a interfaceC0026a) { if (a()) { boolean c2 = yp.c(this.sdk); this.sdk.E().a(la.L, "attemptingToLoadDestroyedAdView", (Map) CollectionUtils.hashMap("details", "debug=" + c2)); if (!c2) { n.h(this.tag, "Failed to load new ad - this instance is already destroyed"); return; } throw new IllegalStateException("Failed to load new ad - this instance is already destroyed for ad unit ID: " + this.adUnitId); } AppLovinSdkUtils.runOnUiThread(true, new Runnable() { // from class: com.applovin.impl.mediation.ads.MaxAdViewImpl$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { MaxAdViewImpl.this.a(interfaceC0026a, bVar); } }); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(a.InterfaceC0026a interfaceC0026a, d.b bVar) { he heVar = this.p; if (heVar != null) { long a2 = this.l.a(heVar); this.extraParameters.put("visible_ad_ad_unit_id", this.p.getAdUnitId()); this.extraParameters.put("viewability_flags", Long.valueOf(a2)); } else { this.extraParameters.remove("visible_ad_ad_unit_id"); this.extraParameters.remove("viewability_flags"); } int pxToDp = AppLovinSdkUtils.pxToDp(this.b.getContext(), this.b.getWidth()); int pxToDp2 = AppLovinSdkUtils.pxToDp(this.b.getContext(), this.b.getHeight()); this.extraParameters.put("viewport_width", Integer.valueOf(pxToDp)); this.extraParameters.put("viewport_height", Integer.valueOf(pxToDp2)); this.extraParameters.put("auto_refresh_stopped", Boolean.valueOf(this.k.g() || this.r)); this.extraParameters.put("auto_retries_disabled", Boolean.valueOf(this.w)); if (n.a()) { this.logger.a(this.tag, "Loading " + this.adFormat.getLabel().toLowerCase(Locale.ENGLISH) + " ad for '" + this.adUnitId + "' and notifying " + interfaceC0026a + "..."); } this.sdk.Q().loadAd(this.adUnitId, this.c, this.adFormat, bVar, this.localExtraParameters, this.extraParameters, this.a, interfaceC0026a); } private void a(String str, String str2) { if ("allow_pause_auto_refresh_immediately".equalsIgnoreCase(str)) { if (n.a()) { this.logger.a(this.tag, "Updated allow immediate auto-refresh pause and ad load to: " + str2); } this.v = Boolean.parseBoolean(str2); return; } if ("disable_auto_retries".equalsIgnoreCase(str)) { if (n.a()) { this.logger.a(this.tag, "Updated disable auto-retries to: " + str2); } this.w = Boolean.parseBoolean(str2); return; } if ("disable_precache".equalsIgnoreCase(str)) { if (n.a()) { this.logger.a(this.tag, "Updated precached disabled to: " + str2); } this.x = Boolean.parseBoolean(str2); return; } if ("should_stop_auto_refresh_on_ad_expand".equals(str)) { if (n.a()) { this.logger.a(this.tag, "Updated should stop auto-refresh on ad expand to: " + str2); } this.y = Boolean.parseBoolean(str2); return; } if ("force_precache".equals(str)) { if (n.a()) { this.logger.a(this.tag, "Updated force precache to: " + str2); } this.z = Boolean.parseBoolean(str2); return; } if ("adaptive_banner".equalsIgnoreCase(str)) { if (n.a()) { this.logger.a(this.tag, "Updated is adaptive banner to: " + str2); } this.A = Boolean.parseBoolean(str2); setLocalExtraParameter(str, str2); } } /* JADX INFO: Access modifiers changed from: private */ public void a(MaxError maxError) { if (a()) { if (n.a()) { this.logger.a(this.tag, "Ad load failure with ad unit ID '" + this.adUnitId + "' occured after MaxAdView was destroyed."); return; } return; } if (this.sdk.c(ve.c7).contains(String.valueOf(maxError.getCode()))) { this.sdk.J(); if (n.a()) { this.sdk.J().a(this.tag, "Ignoring banner ad refresh for error code " + maxError.getCode()); return; } return; } if (!this.r && !this.k.g()) { this.q = true; this.t = false; long longValue = ((Long) this.sdk.a(ve.b7)).longValue(); if (longValue >= 0) { this.sdk.J(); if (n.a()) { this.sdk.J().a(this.tag, "Scheduling failed banner ad refresh " + longValue + " milliseconds from now for '" + this.adUnitId + "'..."); } this.k.a(longValue); return; } return; } if (this.t) { if (n.a()) { this.logger.a(this.tag, "Refresh precache failed when auto-refresh is stopped"); } this.t = false; } if (this.s.get()) { if (n.a()) { this.logger.a(this.tag, "Refresh precache failed - MaxAdListener.onAdLoadFailed(adUnitId=" + this.adUnitId + ", error=" + maxError + "), listener=" + this.adListener); } gc.a(this.adListener, this.adUnitId, maxError, true); } } private void a(he heVar, long j) { if (n.a()) { this.logger.a(this.tag, "Scheduling viewability impression for ad..."); } this.sdk.Q().processViewabilityAdImpressionPostback(heVar, j, this.i); } private void a(long j) { if (yp.a(j, ((Long) this.sdk.a(ve.n7)).longValue()) && !this.z) { if (n.a()) { this.logger.a(this.tag, "Undesired flags matched - current: " + Long.toBinaryString(j) + ", undesired: " + Long.toBinaryString(j)); } if (n.a()) { this.logger.a(this.tag, "Waiting for refresh timer to manually fire request"); } this.q = true; return; } if (n.a()) { this.logger.a(this.tag, "No undesired viewability flags matched or forcing precache - scheduling viewability"); } this.q = false; d(); } /* JADX INFO: Access modifiers changed from: private */ public void a(MaxAd maxAd) { this.t = false; if (this.s.compareAndSet(true, false)) { if (n.a()) { this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "..."); } this.i.onAdLoaded(maxAd); return; } if (n.a()) { this.logger.a(this.tag, "Saving precache ad..."); } he heVar = (he) maxAd; this.f = heVar; heVar.g(this.g); this.f.f(this.h); } /* JADX INFO: Access modifiers changed from: private */ public boolean a() { boolean z; synchronized (this.n) { z = this.u; } return z; } }