正在查看: Handling Master v2 应用的 MaxAdViewImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Handling Master v2 应用的 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.f6;
import com.applovin.impl.g3;
import com.applovin.impl.h;
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.mediation.d;
import com.applovin.impl.q;
import com.applovin.impl.q2;
import com.applovin.impl.q7;
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.n;
import com.applovin.impl.sdk.utils.CollectionUtils;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.y1;
import com.applovin.impl.z6;
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.MaxAdViewConfiguration$AdaptiveType;
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, s7.a, h.b {
private boolean A;
private boolean B;
private boolean C;
private boolean D;
private final Context a;
private final MaxAdView b;
private final String c;
private final View d;
private long e;
private s2 f;
private String g;
private String h;
private final MaxAdViewConfiguration i;
private final b j;
private final d k;
private final f l;
private final r7 m;
private final s7 n;
private final Object o;
private final Object p;
private s2 q;
private MaxAd r;
private boolean s;
private boolean t;
private boolean u;
private final AtomicBoolean v;
private boolean w;
private boolean x;
private boolean y;
private boolean z;
public static class a {
}
public class b extends c {
private b() {
super(MaxAdViewImpl.this, null);
}
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);
}
l2.a(MaxAdViewImpl.this.adListener, str, maxError, true);
MaxAdViewImpl.this.a(maxError);
}
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;
}
s2 s2Var = (s2) maxAd;
s2Var.g(MaxAdViewImpl.this.g);
s2Var.f(MaxAdViewImpl.this.h);
if (s2Var.y() == null) {
MaxAdViewImpl.this.sdk.Q().destroyAd(s2Var);
onAdLoadFailed(s2Var.getAdUnitId(), new MaxErrorImpl(-5001, "Ad view not fully loaded"));
return;
}
if (s2Var.o0()) {
long j0 = s2Var.j0();
MaxAdViewImpl.this.sdk.I();
if (n.a()) {
MaxAdViewImpl.this.sdk.I().a(MaxAdViewImpl.this.tag, "Scheduling banner ad refresh " + j0 + " milliseconds from now for '" + MaxAdViewImpl.this.adUnitId + "'...");
}
MaxAdViewImpl.this.l.a(j0);
if (MaxAdViewImpl.this.l.g() || MaxAdViewImpl.this.u) {
n nVar2 = MaxAdViewImpl.this.logger;
if (n.a()) {
MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this;
maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Pausing ad refresh for publisher");
}
MaxAdViewImpl.this.l.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);
}
l2.f(MaxAdViewImpl.this.adListener, maxAd, true);
MaxAdViewImpl.this.d(s2Var);
}
public b(MaxAdViewImpl maxAdViewImpl, a aVar) {
this();
}
}
public abstract class c implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0056a {
private c() {
}
public void onAdClicked(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.q)) {
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);
}
l2.a(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
public void onAdCollapsed(MaxAd maxAd) {
if (maxAd.equals(((Boolean) MaxAdViewImpl.this.sdk.a(g3.j7)).booleanValue() ? MaxAdViewImpl.this.r : MaxAdViewImpl.this.q)) {
MaxAdViewImpl.this.r = null;
if ((MaxAdViewImpl.this.q.p0() || MaxAdViewImpl.this.B) && MaxAdViewImpl.this.s) {
MaxAdViewImpl.this.s = 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);
}
l2.b(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) {
if (maxAd.equals(MaxAdViewImpl.this.q)) {
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);
}
l2.a(MaxAdViewImpl.this.adListener, maxAd, maxError, true);
}
}
public void onAdDisplayed(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.q)) {
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);
}
l2.c(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
public void onAdExpanded(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.q)) {
if (((Boolean) MaxAdViewImpl.this.sdk.a(g3.j7)).booleanValue()) {
MaxAdViewImpl.this.r = maxAd;
}
if ((MaxAdViewImpl.this.q.p0() || MaxAdViewImpl.this.B) && !MaxAdViewImpl.this.l.g()) {
MaxAdViewImpl.this.s = 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);
}
l2.d(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
public void onAdHidden(MaxAd maxAd) {
if (maxAd.equals(MaxAdViewImpl.this.q)) {
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);
}
l2.e(MaxAdViewImpl.this.adListener, maxAd, true);
}
}
@Override
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);
}
l2.a(MaxAdViewImpl.this.requestListener, str, true);
}
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);
}
l2.a(MaxAdViewImpl.this.revenueListener, maxAd, true);
}
public c(MaxAdViewImpl maxAdViewImpl, a aVar) {
this();
}
}
public class d extends c {
private d() {
super(MaxAdViewImpl.this, null);
}
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);
}
public void onAdLoaded(MaxAd maxAd) {
if (!MaxAdViewImpl.this.x) {
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(g3.P6)).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 d(MaxAdViewImpl maxAdViewImpl, a aVar) {
this();
}
}
public MaxAdViewImpl(String str, MaxAdFormat maxAdFormat, MaxAdViewConfiguration maxAdViewConfiguration, MaxAdView maxAdView, View view, Context context) {
super(str, maxAdFormat, "MaxAdView", AppLovinSdk.getInstance(context).a());
this.c = UUID.randomUUID().toString().toLowerCase(Locale.US);
this.e = Long.MAX_VALUE;
this.o = new Object();
this.p = new Object();
a aVar = null;
this.q = null;
this.r = null;
this.v = new AtomicBoolean();
this.x = false;
this.a = context.getApplicationContext();
this.b = maxAdView;
this.d = view;
this.j = new b(this, aVar);
this.k = new d(this, aVar);
this.l = new f(this.sdk, this);
this.m = new r7(maxAdView, this.sdk);
this.n = new s7(maxAdView, this.sdk, this);
this.i = 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 (n.a()) {
this.logger.a(this.tag, "Created new MaxAdView (" + this + ")");
}
}
@Override
public void destroy() {
if (((Boolean) this.sdk.a(g3.Q6)).booleanValue()) {
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public final void run() {
MaxAdViewImpl.this.g();
}
});
} else {
g();
}
}
public MaxAdFormat getAdFormat() {
return this.adFormat;
}
public String getPlacement() {
return this.g;
}
public void loadAd() {
loadAd(d.b.PUBLISHER_INITIATED);
}
@Override
public void onAdRefresh() {
if (((Boolean) this.sdk.a(g3.P6)).booleanValue()) {
f();
} else {
e();
}
}
public void onCreativeIdGenerated(String str, String str2) {
s2 s2Var = this.q;
if (s2Var != null && s2Var.N().equalsIgnoreCase(str)) {
this.q.h(str2);
l2.b(this.adReviewListener, str2, this.q);
return;
}
s2 s2Var2 = this.f;
if (s2Var2 == null || !s2Var2.N().equalsIgnoreCase(str)) {
return;
}
this.f.h(str2);
}
@Override
public void onLogVisibilityImpression() {
a(this.q, this.m.a(this.q));
}
public void onWindowVisibilityChanged(int i) {
if (((Boolean) this.sdk.a(g3.M6)).booleanValue() && this.l.h()) {
if (q7.b(i)) {
if (n.a()) {
this.logger.a(this.tag, "Ad view visible");
}
this.l.d();
} else {
if (n.a()) {
this.logger.a(this.tag, "Ad view hidden");
}
this.l.c();
}
}
}
public void setCustomData(String str) {
if (this.q != 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.");
}
z6.b(str, this.tag);
this.h = str;
}
@Override
public void setExtraParameter(String str, String str2) {
super.setExtraParameter(str, str2);
a(str, str2);
}
public void setPlacement(String str) {
if (this.q != 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 setPublisherBackgroundColor(int i) {
this.e = i;
}
public void startAutoRefresh() {
this.u = false;
if (!this.l.g()) {
if (n.a()) {
this.logger.a(this.tag, "Ignoring call to startAutoRefresh() - ad refresh is not paused");
return;
}
return;
}
this.l.m();
if (n.a()) {
this.logger.a(this.tag, "Resumed auto-refresh with remaining time: " + this.l.b() + "ms");
}
}
public void stopAutoRefresh() {
if (this.q == null) {
if (this.y || ((Boolean) this.sdk.a(g3.O6)).booleanValue()) {
this.u = true;
return;
} else {
n.j(this.tag, "Stopping auto-refresh has no effect until after the first ad has been loaded.");
return;
}
}
if (n.a()) {
this.logger.a(this.tag, "Pausing auto-refresh with remaining time: " + this.l.b() + "ms");
}
this.l.j();
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("MaxAdView{adUnitId='");
sb.append(this.adUnitId);
sb.append('\'');
sb.append(", adListener=");
String str = this.adListener;
if (str == this.b) {
str = "this";
}
sb.append((Object) str);
sb.append(", isDestroyed=");
sb.append(a());
sb.append('}');
return sb.toString();
}
public void d(final s2 s2Var) {
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public final void run() {
MaxAdViewImpl.this.b(s2Var);
}
});
}
private void e() {
this.v.set(false);
if (this.f != null) {
i();
return;
}
if (!b()) {
if (n.a()) {
this.logger.a(this.tag, "Refreshing ad from network...");
}
loadAd(d.b.REFRESH);
} else if (this.t) {
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.v.set(true);
}
}
private void f() {
boolean z;
boolean z2;
synchronized (this.p) {
z = false;
this.v.set(false);
z2 = this.f != null;
if (!z2) {
if (b()) {
if (!this.t) {
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.v.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;
}
}
if (z2) {
i();
} else if (z) {
loadAd(d.b.REFRESH);
}
}
public void g() {
h();
if (this.f != null) {
this.sdk.Q().destroyAd(this.f);
}
synchronized (this.o) {
this.x = true;
}
this.l.a();
this.sdk.j().b(this);
this.sdk.K().c(this.adUnitId, this.c);
super.destroy();
}
private void h() {
s2 s2Var;
MaxAdView maxAdView = this.b;
if (maxAdView != null) {
q.a(maxAdView, this.d);
}
this.n.b();
synchronized (this.o) {
s2Var = this.q;
}
MaxAd maxAd = this.r;
if (maxAd != null && maxAd.equals(s2Var)) {
if (n.a()) {
this.logger.a(this.tag, "Collapsing ad manually for removed ad.");
}
l2.b(this.j, maxAd);
}
if (s2Var != null) {
this.sdk.Q().destroyAd(s2Var);
}
}
private void i() {
if (n.a()) {
this.logger.a(this.tag, "Rendering for cached ad: " + this.f + "...");
}
this.j.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.y || ((Boolean) this.sdk.a(g3.O6)).booleanValue();
if (z && !this.l.g() && this.l.h()) {
n.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 (!z) {
if (n.a()) {
this.logger.a(this.tag, "Loading ad...");
}
a(bVar, this.j);
} else if (this.f != null) {
if (n.a()) {
this.logger.a(this.tag, "Rendering cached ad");
}
i();
} else if (this.w) {
if (n.a()) {
this.logger.a(this.tag, "Waiting for precache ad to load to render");
}
this.v.set(true);
} else {
if (n.a()) {
this.logger.a(this.tag, "Loading ad...");
}
a(bVar, this.j);
}
}
public void b(final s2 s2Var) {
View y = s2Var.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);
}
MaxError maxErrorImpl = new MaxErrorImpl(-1, str);
if (n.a()) {
this.logger.a(this.tag, "MaxAdListener.onAdDisplayFailed(ad=" + s2Var + ", error=" + maxErrorImpl + "), listener=" + this.adListener);
}
l2.a(this.adListener, s2Var, maxErrorImpl, true);
this.sdk.Q().processAdDisplayErrorPostbackForUserError(maxErrorImpl, s2Var);
return;
}
h();
a((q2) s2Var);
if (s2Var.i0()) {
this.n.a(s2Var);
}
maxAdView.setDescendantFocusability(393216);
if (s2Var.k0() != Long.MAX_VALUE) {
this.d.setBackgroundColor((int) s2Var.k0());
} 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, s2Var);
this.sdk.w().d(s2Var);
c(s2Var);
synchronized (this.o) {
this.q = s2Var;
}
if (n.a()) {
this.logger.a(this.tag, "Scheduling impression for ad manually...");
}
this.sdk.Q().processRawAdImpression(s2Var, this.j);
if (StringUtils.isValidString(this.q.getAdReviewCreativeId())) {
l2.a(this.adReviewListener, this.q.getAdReviewCreativeId(), this.q, true);
}
AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
@Override
public final void run() {
MaxAdViewImpl.this.a(s2Var);
}
}, s2Var.m0());
}
public void c() {
if (n.a()) {
this.logger.a(this.tag, "Loading ad for precache request...");
}
a(d.b.SEQUENTIAL_OR_PRECACHE, this.k);
}
private void d() {
if (b()) {
if (n.a()) {
this.logger.a(this.tag, "Scheduling refresh precache request now");
}
this.w = true;
this.sdk.j0().a(new f6(this.sdk, "loadMaxAdForPrecacheRequest", new Runnable() {
@Override
public final void run() {
MaxAdViewImpl.this.c();
}
}), r5.b.MEDIATION);
}
}
private void c(s2 s2Var) {
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 = s2Var.getFormat();
int height2 = (this.D ? format.getAdaptiveSize(pxToDp2, this.b.getContext()) : format.getSize()).getHeight();
int min = Math.min(format.getSize().getWidth(), k0.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.D ? "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(final d.b bVar, final a.InterfaceC0056a interfaceC0056a) {
if (a()) {
boolean c2 = z6.c(this.sdk);
this.sdk.A().a(y1.o0, "attemptingToLoadDestroyedAdView", 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() {
@Override
public final void run() {
MaxAdViewImpl.this.a(interfaceC0056a, bVar);
}
});
}
public void a(a.InterfaceC0056a interfaceC0056a, d.b bVar) {
int adaptiveWidth;
s2 s2Var = this.q;
if (s2Var != null) {
long a2 = this.m.a(s2Var);
this.extraParameters.put("visible_ad_ad_unit_id", this.q.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.l.g() || this.u));
this.extraParameters.put("auto_retries_disabled", Boolean.valueOf(this.z));
MaxAdViewConfiguration maxAdViewConfiguration = this.i;
if (maxAdViewConfiguration != null && (adaptiveWidth = maxAdViewConfiguration.getAdaptiveWidth()) > 0 && pxToDp != adaptiveWidth) {
n.j(this.tag, "The requested adaptive ad view width (" + adaptiveWidth + " dp) is different from the MaxAdView width (" + pxToDp + " dp).");
}
if (n.a()) {
this.logger.a(this.tag, "Loading " + this.adFormat.getLabel().toLowerCase(Locale.ENGLISH) + " ad for '" + this.adUnitId + "' and notifying " + interfaceC0056a + "...");
}
this.sdk.Q().loadAd(this.adUnitId, this.c, this.adFormat, bVar, this.localExtraParameters, this.extraParameters, this.a, interfaceC0056a);
}
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.y = 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.z = Boolean.parseBoolean(str2);
return;
}
if ("disable_precache".equalsIgnoreCase(str)) {
if (n.a()) {
this.logger.a(this.tag, "Updated precached disabled to: " + str2);
}
this.A = 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.B = Boolean.parseBoolean(str2);
return;
}
if ("force_precache".equals(str)) {
if (n.a()) {
this.logger.a(this.tag, "Updated force precache to: " + str2);
}
this.C = Boolean.parseBoolean(str2);
return;
}
if ("adaptive_banner".equalsIgnoreCase(str)) {
if (n.a()) {
this.logger.a(this.tag, "Updated is adaptive banner to: " + str2);
}
if (this.i == null) {
n.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.w = false;
synchronized (this.p) {
compareAndSet = this.v.compareAndSet(true, false);
if (!compareAndSet) {
if (n.a()) {
this.logger.a(this.tag, "Saving precache ad...");
}
s2 s2Var = (s2) maxAd;
this.f = s2Var;
s2Var.g(this.g);
this.f.f(this.h);
}
}
if (compareAndSet) {
if (n.a()) {
this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
}
this.j.onAdLoaded(maxAd);
}
}
private boolean b() {
if (this.A) {
return false;
}
return ((Boolean) this.sdk.a(g3.V6)).booleanValue();
}
public void a(s2 s2Var) {
long a2 = this.m.a(s2Var);
if (!s2Var.i0()) {
a(s2Var, a2);
}
a(a2);
}
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(g3.I6).contains(String.valueOf(maxError.getCode()))) {
this.sdk.I();
if (n.a()) {
this.sdk.I().a(this.tag, "Ignoring banner ad refresh for error code " + maxError.getCode());
return;
}
return;
}
if (!this.u && !this.l.g()) {
this.t = true;
this.w = false;
long longValue = ((Long) this.sdk.a(g3.H6)).longValue();
if (longValue >= 0) {
this.sdk.I();
if (n.a()) {
this.sdk.I().a(this.tag, "Scheduling failed banner ad refresh " + longValue + " milliseconds from now for '" + this.adUnitId + "'...");
}
this.l.a(longValue);
return;
}
return;
}
if (this.w) {
if (n.a()) {
this.logger.a(this.tag, "Refresh precache failed when auto-refresh is stopped");
}
this.w = false;
}
if (this.v.get()) {
if (n.a()) {
this.logger.a(this.tag, "Refresh precache failed - MaxAdListener.onAdLoadFailed(adUnitId=" + this.adUnitId + ", error=" + maxError + "), listener=" + this.adListener);
}
l2.a(this.adListener, this.adUnitId, maxError, true);
}
}
private void a(View view, s2 s2Var) {
int n0 = s2Var.n0();
int l0 = s2Var.l0();
int dpToPx = n0 == -1 ? -1 : AppLovinSdkUtils.dpToPx(view.getContext(), n0);
int dpToPx2 = l0 != -1 ? AppLovinSdkUtils.dpToPx(view.getContext(), l0) : -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 + ".");
}
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
for (int i : q7.a(this.b.getGravity(), 10, 14)) {
layoutParams2.addRule(i);
}
}
view.setLayoutParams(layoutParams);
}
private void a(s2 s2Var, long j) {
if (n.a()) {
this.logger.a(this.tag, "Scheduling viewability impression for ad...");
}
this.sdk.Q().processViewabilityAdImpressionPostback(s2Var, j, this.j);
}
private void a(long j) {
if (z6.a(j, ((Long) this.sdk.a(g3.U6)).longValue()) && !this.C) {
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.t = true;
return;
}
if (n.a()) {
this.logger.a(this.tag, "No undesired viewability flags matched or forcing precache - scheduling viewability");
}
this.t = false;
d();
}
public void a(MaxAd maxAd) {
this.w = false;
if (this.v.compareAndSet(true, false)) {
if (n.a()) {
this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
}
this.j.onAdLoaded(maxAd);
return;
}
if (n.a()) {
this.logger.a(this.tag, "Saving precache ad...");
}
s2 s2Var = (s2) maxAd;
this.f = s2Var;
s2Var.g(this.g);
this.f.f(this.h);
}
public boolean a() {
boolean z;
synchronized (this.o) {
z = this.x;
}
return z;
}
}