正在查看: FileWipe Pro v3.0.0 应用的 MaxAdViewImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: FileWipe Pro v3.0.0 应用的 MaxAdViewImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
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.a7;
import com.applovin.impl.e8;
import com.applovin.impl.f6;
import com.applovin.impl.g3;
import com.applovin.impl.i;
import com.applovin.impl.k0;
import com.applovin.impl.l2;
import com.applovin.impl.mediation.MaxErrorImpl;
import com.applovin.impl.mediation.ads.a;
import com.applovin.impl.q2;
import com.applovin.impl.r;
import com.applovin.impl.r5;
import com.applovin.impl.r7;
import com.applovin.impl.s2;
import com.applovin.impl.s7;
import com.applovin.impl.sdk.f;
import com.applovin.impl.sdk.o;
import com.applovin.impl.sdk.utils.CollectionUtils;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.t7;
import com.applovin.impl.w4;
import com.applovin.impl.y1;
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.MaxAdViewConfiguration;
import com.applovin.mediation.MaxError;
import com.applovin.mediation.ads.MaxAdView;
import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkUtils;
import java.util.Locale;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class MaxAdViewImpl extends com.applovin.impl.mediation.ads.a implements f.a, t7.a, i.b {
private boolean A;
private boolean B;
private boolean C;
private boolean D;
private final Context f3192a;
private final MaxAdView f3193b;
private final String f3194c;
private final View f3195d;
private long f3196e;
private s2 f3197f;
private String f3198g;
private String f3199h;
private final MaxAdViewConfiguration f3200i;
private final b f3201j;
private final d f3202k;
private final com.applovin.impl.sdk.f l;
private final s7 m;
private final t7 f3203n;
private final Object f3204o;
private final Object f3205p;
private s2 f3206q;
private MaxAd f3207r;
private boolean f3208s;
private boolean f3209t;
private boolean f3210u;
private final AtomicBoolean f3211v;
private boolean f3212w;
private boolean f3213x;
private boolean f3214y;
private boolean f3215z;
public class b extends c {
private b() {
super();
}
@Override
public void onAdLoadFailed(String str, MaxError maxError) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str2 = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdLoadFailed(adUnitId=");
sb2.append(str);
sb2.append(", error=");
sb2.append(maxError);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str2);
}
l2.a(MaxAdViewImpl.this.adListener, str, maxError, true);
MaxAdViewImpl.this.a(maxError);
}
@Override
public void onAdLoaded(MaxAd maxAd) {
if (MaxAdViewImpl.this.a()) {
o oVar = MaxAdViewImpl.this.logger;
if (o.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.X().destroyAd(maxAd);
return;
}
s2 s2Var = (s2) maxAd;
s2Var.g(MaxAdViewImpl.this.f3198g);
s2Var.f(MaxAdViewImpl.this.f3199h);
if (s2Var.y() == null) {
MaxAdViewImpl.this.sdk.X().destroyAd(s2Var);
onAdLoadFailed(s2Var.getAdUnitId(), new MaxErrorImpl(-5001, "Ad view not fully loaded"));
return;
}
if (s2Var.p0()) {
long k0 = s2Var.k0();
MaxAdViewImpl.this.sdk.O();
if (o.a()) {
o O = MaxAdViewImpl.this.sdk.O();
String str = MaxAdViewImpl.this.tag;
StringBuilder k10 = j0.a.k("Scheduling banner ad refresh ", " milliseconds from now for '", k0);
k10.append(MaxAdViewImpl.this.adUnitId);
k10.append("'...");
O.a(str, k10.toString());
}
MaxAdViewImpl.this.l.a(k0);
if (MaxAdViewImpl.this.l.g() || MaxAdViewImpl.this.f3210u) {
o oVar2 = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this;
maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Pausing ad refresh for publisher");
}
MaxAdViewImpl.this.l.j();
}
}
o oVar3 = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl3 = MaxAdViewImpl.this;
o oVar4 = maxAdViewImpl3.logger;
String str2 = maxAdViewImpl3.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdLoaded(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar4, str2);
}
l2.f(MaxAdViewImpl.this.adListener, maxAd, true);
MaxAdViewImpl.this.d(s2Var);
}
}
public abstract class c implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0008a {
private c() {
}
@Override
public void onAdClicked(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.f3206q)) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdClicked(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.a(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
public void onAdCollapsed(MaxAd maxAd) {
if (maxAd.equals(((Boolean) MaxAdViewImpl.this.sdk.a(g3.f2553y7)).booleanValue() ? MaxAdViewImpl.this.f3207r : MaxAdViewImpl.this.f3206q)) {
MaxAdViewImpl.this.f3207r = null;
if ((MaxAdViewImpl.this.f3206q.q0() || MaxAdViewImpl.this.B) && MaxAdViewImpl.this.f3208s) {
MaxAdViewImpl.this.f3208s = false;
MaxAdViewImpl.this.startAutoRefresh();
}
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdViewAdListener.onAdCollapsed(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.b(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) {
if (maxAd.equals(MaxAdViewImpl.this.f3206q)) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdDisplayFailed(ad=");
sb2.append(maxAd);
sb2.append(", error=");
sb2.append(maxError);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.a(MaxAdViewImpl.this.adListener, maxAd, maxError, true);
}
}
@Override
public void onAdDisplayed(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.f3206q)) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdDisplayed(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.c(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
public void onAdExpanded(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.f3206q)) {
if (((Boolean) MaxAdViewImpl.this.sdk.a(g3.f2553y7)).booleanValue()) {
MaxAdViewImpl.this.f3207r = maxAd;
}
if ((MaxAdViewImpl.this.f3206q.q0() || MaxAdViewImpl.this.B) && !MaxAdViewImpl.this.l.g()) {
MaxAdViewImpl.this.f3208s = true;
MaxAdViewImpl.this.stopAutoRefresh();
}
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdViewAdListener.onAdExpanded(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.d(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
public void onAdHidden(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.f3206q)) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str = maxAdViewImpl.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdHidden(ad=");
sb2.append(maxAd);
sb2.append("), listener=");
s1.a.z(sb2, MaxAdViewImpl.this.adListener, oVar2, str);
}
l2.e(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
public void onAdRequestStarted(String str) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
o oVar2 = maxAdViewImpl.logger;
String str2 = maxAdViewImpl.tag;
StringBuilder l = j0.a.l("MaxAdRequestListener.onAdRequestStarted(adUnitId=", str, "), listener=");
l.append(MaxAdViewImpl.this.requestListener);
oVar2.a(str2, l.toString());
}
l2.a(MaxAdViewImpl.this.requestListener, str, true);
}
@Override
public void onAdRevenuePaid(MaxAd maxAd) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
maxAdViewImpl.logger.a(maxAdViewImpl.tag, "MaxAdRevenueListener.onAdRevenuePaid(ad=" + maxAd + "), listener=" + MaxAdViewImpl.this.revenueListener);
}
l2.a(MaxAdViewImpl.this.revenueListener, maxAd, true);
}
}
public class d extends c {
private d() {
super();
}
@Override
public void onAdLoadFailed(String str, MaxError maxError) {
o oVar = MaxAdViewImpl.this.logger;
if (o.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
public void onAdLoaded(MaxAd maxAd) {
if (!MaxAdViewImpl.this.f3213x) {
o oVar = MaxAdViewImpl.this.logger;
if (o.a()) {
MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
maxAdViewImpl.logger.a(maxAdViewImpl.tag, "Successfully precached ad for refresh");
}
if (((Boolean) MaxAdViewImpl.this.sdk.a(g3.f2535e7)).booleanValue()) {
MaxAdViewImpl.this.b(maxAd);
return;
} else {
MaxAdViewImpl.this.a(maxAd);
return;
}
}
o oVar2 = MaxAdViewImpl.this.logger;
if (o.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.X().destroyAd(maxAd);
}
}
public MaxAdViewImpl(String str, MaxAdFormat maxAdFormat, MaxAdViewConfiguration maxAdViewConfiguration, MaxAdView maxAdView, View view, Context context) {
super(str, maxAdFormat, "MaxAdView", AppLovinSdk.getInstance(context).a());
this.f3194c = UUID.randomUUID().toString().toLowerCase(Locale.US);
this.f3196e = Long.MAX_VALUE;
this.f3204o = new Object();
this.f3205p = new Object();
this.f3206q = null;
this.f3207r = null;
this.f3211v = new AtomicBoolean();
this.f3213x = false;
this.f3192a = context.getApplicationContext();
this.f3193b = maxAdView;
this.f3195d = view;
this.f3201j = new b();
this.f3202k = new d();
this.l = new com.applovin.impl.sdk.f(this.sdk, this);
this.m = new s7(maxAdView, this.sdk);
this.f3203n = new t7(maxAdView, this.sdk, this);
this.f3200i = maxAdViewConfiguration;
this.sdk.j().a(this);
if (maxAdViewConfiguration != null && maxAdViewConfiguration.getAdaptiveType() != MaxAdViewConfiguration.AdaptiveType.NONE) {
setExtraParameter("adaptive_banner", Boolean.toString(true));
setLocalExtraParameter("adaptive_banner_type", maxAdViewConfiguration.getAdaptiveType().toString());
int adaptiveWidth = maxAdViewConfiguration.getAdaptiveWidth();
if (adaptiveWidth > 0) {
setLocalExtraParameter("adaptive_banner_width", Integer.valueOf(adaptiveWidth));
}
int inlineMaximumHeight = maxAdViewConfiguration.getInlineMaximumHeight();
if (inlineMaximumHeight > 0) {
setLocalExtraParameter("inline_adaptive_banner_max_height", Integer.valueOf(inlineMaximumHeight));
}
}
if (o.a()) {
this.logger.a(this.tag, "Created new MaxAdView (" + this + ")");
}
}
@Override
public void destroy() {
if (((Boolean) this.sdk.a(g3.f2536f7)).booleanValue()) {
AppLovinSdkUtils.runOnUiThread(new com.applovin.impl.mediation.ads.c(this, 0));
} else {
g();
}
}
public MaxAdFormat getAdFormat() {
return this.adFormat;
}
public String getPlacement() {
return this.f3198g;
}
public void loadAd() {
loadAd(com.applovin.impl.h.PUBLISHER_INITIATED);
}
@Override
public void onAdRefresh() {
if (((Boolean) this.sdk.a(g3.f2535e7)).booleanValue()) {
f();
} else {
e();
}
}
@Override
public void onCreativeIdGenerated(String str, String str2) {
s2 s2Var = this.f3206q;
if (s2Var != null && s2Var.O().equalsIgnoreCase(str)) {
this.f3206q.h(str2);
l2.b(this.adReviewListener, str2, this.f3206q);
return;
}
s2 s2Var2 = this.f3197f;
if (s2Var2 == null || !s2Var2.O().equalsIgnoreCase(str)) {
return;
}
this.f3197f.h(str2);
}
@Override
public void onLogVisibilityImpression() {
a(this.f3206q, this.m.a(this.f3206q));
}
public void onWindowVisibilityChanged(int i10) {
if (((Boolean) this.sdk.a(g3.f2532b7)).booleanValue() && this.l.h()) {
if (r7.b(i10)) {
if (o.a()) {
this.logger.a(this.tag, "Ad view visible");
}
this.l.d();
} else {
if (o.a()) {
this.logger.a(this.tag, "Ad view hidden");
}
this.l.c();
}
}
}
public void setCustomData(String str) {
if (this.f3206q != null && o.a()) {
o oVar = this.logger;
String str2 = this.tag;
StringBuilder l = j0.a.l("Setting custom data (", str, ") for Ad Unit ID (");
l.append(this.adUnitId);
l.append(") after an ad has been loaded already.");
oVar.k(str2, l.toString());
}
a7.b(str, this.tag);
this.f3199h = str;
}
@Override
public void setExtraParameter(String str, String str2) {
super.setExtraParameter(str, str2);
a(str, str2);
}
public void setPlacement(String str) {
if (this.f3206q != null && o.a()) {
o oVar = this.logger;
String str2 = this.tag;
StringBuilder l = j0.a.l("Setting placement (", str, ") for Ad Unit ID (");
l.append(this.adUnitId);
l.append(") after an ad has been loaded already.");
oVar.k(str2, l.toString());
}
this.f3198g = str;
}
public void setPublisherBackgroundColor(int i10) {
this.f3196e = i10;
}
public void startAutoRefresh() {
this.f3210u = false;
if (!this.l.g()) {
if (o.a()) {
this.logger.a(this.tag, "Ignoring call to startAutoRefresh() - ad refresh is not paused");
return;
}
return;
}
this.l.m();
if (o.a()) {
this.logger.a(this.tag, "Resumed auto-refresh with remaining time: " + this.l.b() + "ms");
}
}
public void stopAutoRefresh() {
if (this.f3206q == null) {
if (this.f3214y || ((Boolean) this.sdk.a(g3.f2534d7)).booleanValue()) {
this.f3210u = true;
return;
} else {
o.j(this.tag, "Stopping auto-refresh has no effect until after the first ad has been loaded.");
return;
}
}
if (o.a()) {
this.logger.a(this.tag, "Pausing auto-refresh with remaining time: " + this.l.b() + "ms");
}
this.l.j();
}
public String toString() {
StringBuilder sb2 = new StringBuilder("MaxAdView{adUnitId='");
sb2.append(this.adUnitId);
sb2.append("', adListener=");
Object obj = this.adListener;
if (obj == this.f3193b) {
obj = "this";
}
sb2.append(obj);
sb2.append(", isDestroyed=");
sb2.append(a());
sb2.append('}');
return sb2.toString();
}
public void d(s2 s2Var) {
AppLovinSdkUtils.runOnUiThread(new com.applovin.impl.mediation.ads.d(this, s2Var, 0));
}
private void e() {
this.f3211v.set(false);
if (this.f3197f != null) {
i();
return;
}
if (!b()) {
if (o.a()) {
this.logger.a(this.tag, "Refreshing ad from network...");
}
loadAd(com.applovin.impl.h.REFRESH);
} else if (this.f3209t) {
if (o.a()) {
this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request...");
}
loadAd(com.applovin.impl.h.REFRESH);
} else {
if (o.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.f3211v.set(true);
}
}
private void f() {
boolean z3;
boolean z8;
synchronized (this.f3205p) {
try {
z3 = false;
this.f3211v.set(false);
z8 = this.f3197f != null;
if (!z8) {
if (b()) {
if (!this.f3209t) {
if (o.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.f3211v.set(true);
} else if (o.a()) {
this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request...");
}
} else if (o.a()) {
this.logger.a(this.tag, "Refreshing ad from network...");
}
z3 = true;
}
} catch (Throwable th) {
throw th;
}
}
if (z8) {
i();
} else if (z3) {
loadAd(com.applovin.impl.h.REFRESH);
}
}
public void g() {
h();
if (this.f3197f != null) {
this.sdk.X().destroyAd(this.f3197f);
}
synchronized (this.f3204o) {
this.f3213x = true;
}
this.l.a();
this.sdk.j().b(this);
if (this.sdk.R() != null) {
this.sdk.R().c(this.adUnitId, this.f3194c);
} else {
this.sdk.Q().c(this.adUnitId, this.f3194c);
}
super.destroy();
}
private void h() {
s2 s2Var;
MaxAdView maxAdView = this.f3193b;
if (maxAdView != null) {
r.a(maxAdView, this.f3195d);
}
this.f3203n.b();
synchronized (this.f3204o) {
s2Var = this.f3206q;
}
MaxAd maxAd = this.f3207r;
if (maxAd != null && maxAd.equals(s2Var)) {
if (o.a()) {
this.logger.a(this.tag, "Collapsing ad manually for removed ad.");
}
l2.b(this.f3201j, maxAd);
}
if (s2Var != null) {
this.sdk.X().destroyAd(s2Var);
}
}
private void i() {
if (o.a()) {
this.logger.a(this.tag, "Rendering for cached ad: " + this.f3197f + "...");
}
this.f3201j.onAdLoaded(this.f3197f);
this.f3197f = null;
}
public void loadAd(com.applovin.impl.h hVar) {
if (o.a()) {
this.logger.a(this.tag, "" + this + " Loading ad for " + this.adUnitId + "...");
}
boolean z3 = this.f3214y || ((Boolean) this.sdk.a(g3.f2534d7)).booleanValue();
if (z3 && !this.l.g() && this.l.h()) {
o.h(this.tag, "Unable to load a new ad. An ad refresh has already been scheduled in " + TimeUnit.MILLISECONDS.toSeconds(this.l.b()) + " seconds.");
return;
}
if (!z3) {
if (o.a()) {
this.logger.a(this.tag, "Loading ad...");
}
a(hVar, this.f3201j);
} else if (this.f3197f != null) {
if (o.a()) {
this.logger.a(this.tag, "Rendering cached ad");
}
i();
} else if (this.f3212w) {
if (o.a()) {
this.logger.a(this.tag, "Waiting for precache ad to load to render");
}
this.f3211v.set(true);
} else {
if (o.a()) {
this.logger.a(this.tag, "Loading ad...");
}
a(hVar, this.f3201j);
}
}
public void b(s2 s2Var) {
View y10 = s2Var.y();
String str = y10 == null ? "MaxAdView does not have a loaded ad view" : null;
MaxAdView maxAdView = this.f3193b;
if (maxAdView == null) {
str = "MaxAdView does not have a parent view";
}
if (str != null) {
if (o.a()) {
this.logger.b(this.tag, str);
}
MaxErrorImpl maxErrorImpl = new MaxErrorImpl(-1, str);
if (o.a()) {
o oVar = this.logger;
String str2 = this.tag;
StringBuilder sb2 = new StringBuilder("MaxAdListener.onAdDisplayFailed(ad=");
sb2.append(s2Var);
sb2.append(", error=");
sb2.append(maxErrorImpl);
sb2.append("), listener=");
s1.a.z(sb2, this.adListener, oVar, str2);
}
l2.a(this.adListener, (MaxAd) s2Var, (MaxError) maxErrorImpl, true);
this.sdk.X().processAdDisplayErrorPostbackForUserError(maxErrorImpl, s2Var);
return;
}
h();
a((q2) s2Var);
if (s2Var.j0()) {
this.f3203n.a(s2Var);
}
maxAdView.setDescendantFocusability(393216);
if (s2Var.l0() != Long.MAX_VALUE) {
this.f3195d.setBackgroundColor((int) s2Var.l0());
} else {
long j5 = this.f3196e;
if (j5 != Long.MAX_VALUE) {
this.f3195d.setBackgroundColor((int) j5);
} else {
this.f3195d.setBackgroundColor(0);
}
}
maxAdView.addView(y10);
a(y10, s2Var);
this.sdk.z().d(s2Var);
c(s2Var);
synchronized (this.f3204o) {
this.f3206q = s2Var;
}
if (o.a()) {
this.logger.a(this.tag, "Scheduling impression for ad manually...");
}
this.sdk.X().processRawAdImpression(s2Var, this.f3201j);
if (StringUtils.isValidString(this.f3206q.getAdReviewCreativeId())) {
l2.a(this.adReviewListener, this.f3206q.getAdReviewCreativeId(), (MaxAd) this.f3206q, true);
}
AppLovinSdkUtils.runOnUiThreadDelayed(new com.applovin.impl.mediation.ads.d(this, s2Var, 1), s2Var.n0());
}
private void d() {
if (b()) {
if (o.a()) {
this.logger.a(this.tag, "Scheduling refresh precache request now");
}
this.f3212w = true;
this.sdk.q0().a((w4) new f6(this.sdk, "loadMaxAdForPrecacheRequest", new com.applovin.impl.mediation.ads.c(this, 1)), r5.b.MEDIATION);
}
}
public void c() {
if (o.a()) {
this.logger.a(this.tag, "Loading ad for precache request...");
}
a(com.applovin.impl.h.SEQUENTIAL_OR_PRECACHE, this.f3202k);
}
private void a(com.applovin.impl.h hVar, a.InterfaceC0008a interfaceC0008a) {
if (a()) {
boolean c4 = a7.c(this.sdk);
this.sdk.E().a(y1.f4720w0, "attemptingToLoadDestroyedAdView", CollectionUtils.hashMap("details", "debug=" + c4));
if (!c4) {
o.h(this.tag, "Failed to load new ad - this instance is already destroyed");
return;
} else {
throw new IllegalStateException("Failed to load new ad - this instance is already destroyed for ad unit ID: " + this.adUnitId);
}
}
AppLovinSdkUtils.runOnUiThread(true, new e8(this, interfaceC0008a, hVar, 6));
}
private void c(s2 s2Var) {
int height = this.f3193b.getHeight();
int width = this.f3193b.getWidth();
if (height > 0 || width > 0) {
int pxToDp = AppLovinSdkUtils.pxToDp(this.f3192a, height);
int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f3192a, width);
MaxAdFormat format = s2Var.getFormat();
int height2 = (this.D ? format.getAdaptiveSize(pxToDp2, this.f3193b.getContext()) : format.getSize()).getHeight();
int min = Math.min(format.getSize().getWidth(), k0.b(this.f3192a).x);
if (pxToDp < height2 || pxToDp2 < min) {
StringBuilder t3 = s1.a.t(pxToDp2, pxToDp, "\n**************************************************\n`MaxAdView` size ", "x", " dp smaller than required ");
t3.append(this.D ? "adaptive " : "");
t3.append("size: ");
t3.append(min);
t3.append("x");
String p10 = s1.a.p(t3, height2, " dp\nSome mediated networks (e.g. Google Ad Manager) may not render correctly\n**************************************************\n");
if (o.a()) {
this.logger.b("AppLovinSdk", p10);
}
}
}
}
public void a(a.InterfaceC0008a interfaceC0008a, com.applovin.impl.h hVar) {
int adaptiveWidth;
s2 s2Var = this.f3206q;
if (s2Var != null) {
long a10 = this.m.a(s2Var);
this.extraParameters.put("visible_ad_ad_unit_id", this.f3206q.getAdUnitId());
this.extraParameters.put("viewability_flags", Long.valueOf(a10));
} else {
this.extraParameters.remove("visible_ad_ad_unit_id");
this.extraParameters.remove("viewability_flags");
}
int pxToDp = AppLovinSdkUtils.pxToDp(this.f3193b.getContext(), this.f3193b.getWidth());
int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f3193b.getContext(), this.f3193b.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.l.g() || this.f3210u));
this.extraParameters.put("auto_retries_disabled", Boolean.valueOf(this.f3215z));
MaxAdViewConfiguration maxAdViewConfiguration = this.f3200i;
if (maxAdViewConfiguration != null && (adaptiveWidth = maxAdViewConfiguration.getAdaptiveWidth()) > 0 && pxToDp != adaptiveWidth) {
o.j(this.tag, "The requested adaptive ad view width (" + adaptiveWidth + " dp) is different from the MaxAdView width (" + pxToDp + " dp).");
}
if (o.a()) {
this.logger.a(this.tag, "Loading " + this.adFormat.getLabel().toLowerCase(Locale.ENGLISH) + " ad for '" + this.adUnitId + "' and notifying " + interfaceC0008a + "...");
}
this.sdk.X().loadAd(this.adUnitId, this.f3194c, this.adFormat, hVar, this.localExtraParameters, this.extraParameters, this.f3192a, interfaceC0008a);
}
private void a(String str, String str2) {
if ("allow_pause_auto_refresh_immediately".equalsIgnoreCase(str)) {
if (o.a()) {
s1.a.y("Updated allow immediate auto-refresh pause and ad load to: ", str2, this.logger, this.tag);
}
this.f3214y = Boolean.parseBoolean(str2);
return;
}
if ("disable_auto_retries".equalsIgnoreCase(str)) {
if (o.a()) {
s1.a.y("Updated disable auto-retries to: ", str2, this.logger, this.tag);
}
this.f3215z = Boolean.parseBoolean(str2);
return;
}
if ("disable_precache".equalsIgnoreCase(str)) {
if (o.a()) {
s1.a.y("Updated precached disabled to: ", str2, this.logger, this.tag);
}
this.A = Boolean.parseBoolean(str2);
return;
}
if ("should_stop_auto_refresh_on_ad_expand".equals(str)) {
if (o.a()) {
s1.a.y("Updated should stop auto-refresh on ad expand to: ", str2, this.logger, this.tag);
}
this.B = Boolean.parseBoolean(str2);
} else if ("force_precache".equals(str)) {
if (o.a()) {
s1.a.y("Updated force precache to: ", str2, this.logger, this.tag);
}
this.C = Boolean.parseBoolean(str2);
} else if ("adaptive_banner".equalsIgnoreCase(str)) {
if (o.a()) {
s1.a.y("Updated is adaptive banner to: ", str2, this.logger, this.tag);
}
if (this.f3200i == null) {
o.h(this.tag, "You configured adaptive banners incorrectly by setting extra parameters to the MaxAdView! Please configure adaptive banners via MaxAdViewConfiguration instead. Learn more: https://developers.applovin.com/en/max/android/ad-formats/banner-and-mrec-ads#adaptive-banners");
}
this.D = Boolean.parseBoolean(str2);
setLocalExtraParameter(str, str2);
}
}
public void b(MaxAd maxAd) {
boolean compareAndSet;
this.f3212w = false;
synchronized (this.f3205p) {
try {
compareAndSet = this.f3211v.compareAndSet(true, false);
if (!compareAndSet) {
if (o.a()) {
this.logger.a(this.tag, "Saving precache ad...");
}
s2 s2Var = (s2) maxAd;
this.f3197f = s2Var;
s2Var.g(this.f3198g);
this.f3197f.f(this.f3199h);
}
} catch (Throwable th) {
throw th;
}
}
if (compareAndSet) {
if (o.a()) {
this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
}
this.f3201j.onAdLoaded(maxAd);
}
}
private boolean b() {
if (this.A) {
return false;
}
return ((Boolean) this.sdk.a(g3.f2540k7)).booleanValue();
}
public void a(s2 s2Var) {
long a10 = this.m.a(s2Var);
if (!s2Var.j0()) {
a(s2Var, a10);
}
a(a10);
}
public void a(MaxError maxError) {
if (a()) {
if (o.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(g3.X6).contains(String.valueOf(maxError.getCode()))) {
this.sdk.O();
if (o.a()) {
this.sdk.O().a(this.tag, "Ignoring banner ad refresh for error code " + maxError.getCode());
return;
}
return;
}
if (!this.f3210u && !this.l.g()) {
this.f3209t = true;
this.f3212w = false;
long longValue = ((Long) this.sdk.a(g3.W6)).longValue();
if (longValue >= 0) {
this.sdk.O();
if (o.a()) {
o O = this.sdk.O();
String str = this.tag;
StringBuilder k10 = j0.a.k("Scheduling failed banner ad refresh ", " milliseconds from now for '", longValue);
k10.append(this.adUnitId);
k10.append("'...");
O.a(str, k10.toString());
}
this.l.a(longValue);
return;
}
return;
}
if (this.f3212w) {
if (o.a()) {
this.logger.a(this.tag, "Refresh precache failed when auto-refresh is stopped");
}
this.f3212w = false;
}
if (this.f3211v.get()) {
if (o.a()) {
o oVar = this.logger;
String str2 = this.tag;
StringBuilder sb2 = new StringBuilder("Refresh precache failed - MaxAdListener.onAdLoadFailed(adUnitId=");
sb2.append(this.adUnitId);
sb2.append(", error=");
sb2.append(maxError);
sb2.append("), listener=");
s1.a.z(sb2, this.adListener, oVar, str2);
}
l2.a(this.adListener, this.adUnitId, maxError, true);
}
}
private void a(View view, s2 s2Var) {
int o02 = s2Var.o0();
int m02 = s2Var.m0();
int dpToPx = o02 == -1 ? -1 : AppLovinSdkUtils.dpToPx(view.getContext(), o02);
int dpToPx2 = m02 != -1 ? AppLovinSdkUtils.dpToPx(view.getContext(), m02) : -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 (o.a()) {
this.logger.a(this.tag, "Pinning ad view to MAX ad view with width: " + dpToPx + " and height: " + dpToPx2 + ".");
}
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
for (int i10 : r7.a(this.f3193b.getGravity(), 10, 14)) {
layoutParams2.addRule(i10);
}
}
view.setLayoutParams(layoutParams);
}
private void a(s2 s2Var, long j5) {
if (o.a()) {
this.logger.a(this.tag, "Scheduling viewability impression for ad...");
}
this.sdk.X().processViewabilityAdImpressionPostback(s2Var, j5, this.f3201j);
}
private void a(long j5) {
if (a7.a(j5, ((Long) this.sdk.a(g3.f2539j7)).longValue()) && !this.C) {
if (o.a()) {
this.logger.a(this.tag, "Undesired flags matched - current: " + Long.toBinaryString(j5) + ", undesired: " + Long.toBinaryString(j5));
}
if (o.a()) {
this.logger.a(this.tag, "Waiting for refresh timer to manually fire request");
}
this.f3209t = true;
return;
}
if (o.a()) {
this.logger.a(this.tag, "No undesired viewability flags matched or forcing precache - scheduling viewability");
}
this.f3209t = false;
d();
}
public void a(MaxAd maxAd) {
this.f3212w = false;
if (this.f3211v.compareAndSet(true, false)) {
if (o.a()) {
this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
}
this.f3201j.onAdLoaded(maxAd);
return;
}
if (o.a()) {
this.logger.a(this.tag, "Saving precache ad...");
}
s2 s2Var = (s2) maxAd;
this.f3197f = s2Var;
s2Var.g(this.f3198g);
this.f3197f.f(this.f3199h);
}
public boolean a() {
boolean z3;
synchronized (this.f3204o) {
z3 = this.f3213x;
}
return z3;
}
}