导航菜单

页面标题

页面副标题

CallApp v2.226 - MaxAdViewImpl.java 源代码

正在查看: CallApp v2.226 应用的 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.amazon.aps.shared.util.APSSharedUtil;
import com.amazon.device.ads.l;
import com.amazonaws.services.s3.model.InstructionFileId;
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.w4;
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.MaxError;
import com.applovin.mediation.ads.MaxAdView;
import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkUtils;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import s4.y;

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 f9462a;

    private final MaxAdView f9463b;

    private final String f9464c;

    private final View f9465d;

    private long f9466e;

    private s2 f9467f;

    private String f9468g;

    private String f9469h;

    private final MaxAdViewConfiguration f9470i;

    private final b f9471j;

    private final d f9472k;

    private final com.applovin.impl.sdk.f f9473l;

    private final r7 f9474m;

    private final s7 f9475n;

    private final Object f9476o;

    private final Object f9477p;

    private s2 f9478q;

    private MaxAd f9479r;

    private boolean f9480s;

    private boolean f9481t;

    private boolean f9482u;

    private final AtomicBoolean f9483v;

    private boolean f9484w;

    private boolean f9485x;

    private boolean f9486y;

    private boolean f9487z;

    public class b extends c {
        private b() {
            super();
        }

        @Override
        public void onAdLoadFailed(String str, MaxError maxError) {
            n nVar = MaxAdViewImpl.this.logger;
            if (n.a()) {
                MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                n nVar2 = maxAdViewImpl.logger;
                String str2 = maxAdViewImpl.tag;
                StringBuilder sb = new StringBuilder("MaxAdListener.onAdLoadFailed(adUnitId=");
                sb.append(str);
                sb.append(", error=");
                sb.append(maxError);
                sb.append("), listener=");
                l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str2);
            }
            l2.a(MaxAdViewImpl.this.adListener, str, maxError, true);
            MaxAdViewImpl.this.a(maxError);
        }

        @Override
        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.f9468g);
            s2Var.f(MaxAdViewImpl.this.f9469h);
            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 j02 = s2Var.j0();
                MaxAdViewImpl.this.sdk.I();
                if (n.a()) {
                    n I = MaxAdViewImpl.this.sdk.I();
                    String str = MaxAdViewImpl.this.tag;
                    StringBuilder g9 = y.g(j02, "Scheduling banner ad refresh ", " milliseconds from now for '");
                    g9.append(MaxAdViewImpl.this.adUnitId);
                    g9.append("'...");
                    I.a(str, g9.toString());
                }
                MaxAdViewImpl.this.f9473l.a(j02);
                if (MaxAdViewImpl.this.f9473l.g() || MaxAdViewImpl.this.f9482u) {
                    n nVar2 = MaxAdViewImpl.this.logger;
                    if (n.a()) {
                        MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this;
                        maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Pausing ad refresh for publisher");
                    }
                    MaxAdViewImpl.this.f9473l.j();
                }
            }
            n nVar3 = MaxAdViewImpl.this.logger;
            if (n.a()) {
                MaxAdViewImpl maxAdViewImpl3 = MaxAdViewImpl.this;
                n nVar4 = maxAdViewImpl3.logger;
                String str2 = maxAdViewImpl3.tag;
                StringBuilder sb = new StringBuilder("MaxAdListener.onAdLoaded(ad=");
                sb.append(maxAd);
                sb.append("), listener=");
                l.z(sb, MaxAdViewImpl.this.adListener, nVar4, str2);
            }
            l2.f(MaxAdViewImpl.this.adListener, maxAd, true);
            MaxAdViewImpl.this.d(s2Var);
        }
    }

    public abstract class c implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0065a {
        private c() {
        }

        @Override
        public void onAdClicked(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f9478q)) {
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdListener.onAdClicked(ad=");
                    sb.append(maxAd);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                l2.a(MaxAdViewImpl.this.adListener, maxAd, true);
            }
        }

        @Override
        public void onAdCollapsed(MaxAd maxAd) {
            if (maxAd.equals(((Boolean) MaxAdViewImpl.this.sdk.a(g3.f8812j7)).booleanValue() ? MaxAdViewImpl.this.f9479r : MaxAdViewImpl.this.f9478q)) {
                MaxAdViewImpl.this.f9479r = null;
                if ((MaxAdViewImpl.this.f9478q.p0() || MaxAdViewImpl.this.B) && MaxAdViewImpl.this.f9480s) {
                    MaxAdViewImpl.this.f9480s = false;
                    MaxAdViewImpl.this.startAutoRefresh();
                }
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdViewAdListener.onAdCollapsed(ad=");
                    sb.append(maxAd);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                l2.b(MaxAdViewImpl.this.adListener, maxAd, true);
            }
        }

        @Override
        public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) {
            if (maxAd.equals(MaxAdViewImpl.this.f9478q)) {
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdListener.onAdDisplayFailed(ad=");
                    sb.append(maxAd);
                    sb.append(", error=");
                    sb.append(maxError);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                l2.a(MaxAdViewImpl.this.adListener, maxAd, maxError, true);
            }
        }

        @Override
        public void onAdDisplayed(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f9478q)) {
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdListener.onAdDisplayed(ad=");
                    sb.append(maxAd);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                l2.c(MaxAdViewImpl.this.adListener, maxAd, true);
            }
        }

        @Override
        public void onAdExpanded(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f9478q)) {
                if (((Boolean) MaxAdViewImpl.this.sdk.a(g3.f8812j7)).booleanValue()) {
                    MaxAdViewImpl.this.f9479r = maxAd;
                }
                if ((MaxAdViewImpl.this.f9478q.p0() || MaxAdViewImpl.this.B) && !MaxAdViewImpl.this.f9473l.g()) {
                    MaxAdViewImpl.this.f9480s = true;
                    MaxAdViewImpl.this.stopAutoRefresh();
                }
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdViewAdListener.onAdExpanded(ad=");
                    sb.append(maxAd);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                l2.d(MaxAdViewImpl.this.adListener, maxAd, true);
            }
        }

        @Override
        public void onAdHidden(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f9478q)) {
                n nVar = MaxAdViewImpl.this.logger;
                if (n.a()) {
                    MaxAdViewImpl maxAdViewImpl = MaxAdViewImpl.this;
                    n nVar2 = maxAdViewImpl.logger;
                    String str = maxAdViewImpl.tag;
                    StringBuilder sb = new StringBuilder("MaxAdListener.onAdHidden(ad=");
                    sb.append(maxAd);
                    sb.append("), listener=");
                    l.z(sb, MaxAdViewImpl.this.adListener, nVar2, str);
                }
                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;
                n nVar2 = maxAdViewImpl.logger;
                String str2 = maxAdViewImpl.tag;
                StringBuilder s8 = com.mobilefuse.sdk.assetsmanager.a.s("MaxAdRequestListener.onAdRequestStarted(adUnitId=", str, "), listener=");
                s8.append(MaxAdViewImpl.this.requestListener);
                nVar2.a(str2, s8.toString());
            }
            l2.a(MaxAdViewImpl.this.requestListener, str, true);
        }

        @Override
        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 class d extends c {
        private d() {
            super();
        }

        @Override
        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
        public void onAdLoaded(MaxAd maxAd) {
            if (!MaxAdViewImpl.this.f9485x) {
                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 MaxAdViewImpl(String str, MaxAdFormat maxAdFormat, MaxAdViewConfiguration maxAdViewConfiguration, MaxAdView maxAdView, View view, Context context) {
        super(str, maxAdFormat, "MaxAdView", AppLovinSdk.getInstance(context).a());
        this.f9464c = UUID.randomUUID().toString().toLowerCase(Locale.US);
        this.f9466e = Long.MAX_VALUE;
        this.f9476o = new Object();
        this.f9477p = new Object();
        this.f9478q = null;
        this.f9479r = null;
        this.f9483v = new AtomicBoolean();
        this.f9485x = false;
        this.f9462a = context.getApplicationContext();
        this.f9463b = maxAdView;
        this.f9465d = view;
        this.f9471j = new b();
        this.f9472k = new d();
        this.f9473l = new com.applovin.impl.sdk.f(this.sdk, this);
        this.f9474m = new r7(maxAdView, this.sdk);
        this.f9475n = new s7(maxAdView, this.sdk, this);
        this.f9470i = 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 com.applovin.impl.mediation.ads.c(this, 0));
        } else {
            g();
        }
    }

    public MaxAdFormat getAdFormat() {
        return this.adFormat;
    }

    public String getPlacement() {
        return this.f9468g;
    }

    public void loadAd() {
    }

    @Override
    public void onAdRefresh() {
        if (((Boolean) this.sdk.a(g3.P6)).booleanValue()) {
            f();
        } else {
            e();
        }
    }

    @Override
    public void onCreativeIdGenerated(String str, String str2) {
        s2 s2Var = this.f9478q;
        if (s2Var != null && s2Var.N().equalsIgnoreCase(str)) {
            this.f9478q.h(str2);
            l2.b(this.adReviewListener, str2, this.f9478q);
            return;
        }
        s2 s2Var2 = this.f9467f;
        if (s2Var2 == null || !s2Var2.N().equalsIgnoreCase(str)) {
            return;
        }
        this.f9467f.h(str2);
    }

    @Override
    public void onLogVisibilityImpression() {
        a(this.f9478q, this.f9474m.a(this.f9478q));
    }

    public void onWindowVisibilityChanged(int i8) {
        if (((Boolean) this.sdk.a(g3.M6)).booleanValue() && this.f9473l.h()) {
            if (q7.b(i8)) {
                if (n.a()) {
                    this.logger.a(this.tag, "Ad view visible");
                }
                this.f9473l.d();
            } else {
                if (n.a()) {
                    this.logger.a(this.tag, "Ad view hidden");
                }
                this.f9473l.c();
            }
        }
    }

    public void setCustomData(String str) {
        if (this.f9478q != null && n.a()) {
            n nVar = this.logger;
            String str2 = this.tag;
            StringBuilder s8 = com.mobilefuse.sdk.assetsmanager.a.s("Setting custom data (", str, ") for Ad Unit ID (");
            s8.append(this.adUnitId);
            s8.append(") after an ad has been loaded already.");
            nVar.k(str2, s8.toString());
        }
        z6.b(str, this.tag);
        this.f9469h = str;
    }

    @Override
    public void setExtraParameter(String str, String str2) {
        super.setExtraParameter(str, str2);
        a(str, str2);
    }

    public void setPlacement(String str) {
        if (this.f9478q != null && n.a()) {
            n nVar = this.logger;
            String str2 = this.tag;
            StringBuilder s8 = com.mobilefuse.sdk.assetsmanager.a.s("Setting placement (", str, ") for Ad Unit ID (");
            s8.append(this.adUnitId);
            s8.append(") after an ad has been loaded already.");
            nVar.k(str2, s8.toString());
        }
        this.f9468g = str;
    }

    public void setPublisherBackgroundColor(int i8) {
        this.f9466e = i8;
    }

    public void startAutoRefresh() {
        this.f9482u = false;
        if (!this.f9473l.g()) {
            if (n.a()) {
                this.logger.a(this.tag, "Ignoring call to startAutoRefresh() - ad refresh is not paused");
                return;
            }
            return;
        }
        this.f9473l.m();
        if (n.a()) {
            this.logger.a(this.tag, "Resumed auto-refresh with remaining time: " + this.f9473l.b() + "ms");
        }
    }

    public void stopAutoRefresh() {
        if (this.f9478q == null) {
            if (this.f9486y || ((Boolean) this.sdk.a(g3.O6)).booleanValue()) {
                this.f9482u = 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.f9473l.b() + "ms");
        }
        this.f9473l.j();
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("MaxAdView{adUnitId='");
        sb.append(this.adUnitId);
        sb.append("', adListener=");
        Object obj = this.adListener;
        if (obj == this.f9463b) {
            obj = "this";
        }
        sb.append(obj);
        sb.append(", isDestroyed=");
        return androidx.fragment.app.n.s(sb, a(), '}');
    }

    public void d(s2 s2Var) {
        AppLovinSdkUtils.runOnUiThread(new com.applovin.impl.mediation.ads.d(this, s2Var, 0));
    }

    private void e() {
        this.f9483v.set(false);
        if (this.f9467f != null) {
            i();
            return;
        }
        if (!b()) {
            if (n.a()) {
                this.logger.a(this.tag, "Refreshing ad from network...");
            }
            d.b bVar = d.b.REFRESH;
        } else if (this.f9481t) {
            if (n.a()) {
                this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request...");
            }
            d.b bVar2 = 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.f9483v.set(true);
        }
    }

    private void f() {
        boolean z8;
        boolean z9;
        synchronized (this.f9477p) {
            try {
                z8 = false;
                this.f9483v.set(false);
                z9 = this.f9467f != null;
                if (!z9) {
                    if (b()) {
                        if (!this.f9481t) {
                            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.f9483v.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...");
                    }
                    z8 = true;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (z9) {
            i();
        } else if (z8) {
            d.b bVar = d.b.REFRESH;
        }
    }

    public void g() {
        h();
        if (this.f9467f != null) {
            this.sdk.Q().destroyAd(this.f9467f);
        }
        synchronized (this.f9476o) {
            this.f9485x = true;
        }
        this.f9473l.a();
        this.sdk.j().b(this);
        this.sdk.K().c(this.adUnitId, this.f9464c);
        super.destroy();
    }

    private void h() {
        s2 s2Var;
        MaxAdView maxAdView = this.f9463b;
        if (maxAdView != null) {
            q.a(maxAdView, this.f9465d);
        }
        this.f9475n.b();
        synchronized (this.f9476o) {
            s2Var = this.f9478q;
        }
        MaxAd maxAd = this.f9479r;
        if (maxAd != null && maxAd.equals(s2Var)) {
            if (n.a()) {
                this.logger.a(this.tag, "Collapsing ad manually for removed ad.");
            }
            l2.b(this.f9471j, 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.f9467f + APSSharedUtil.TRUNCATE_SEPARATOR);
        }
        this.f9471j.onAdLoaded(this.f9467f);
        this.f9467f = null;
    }

    public void loadAd(d.b bVar) {
    }

    public void c() {
        if (n.a()) {
            this.logger.a(this.tag, "Loading ad for precache request...");
        }
        a(d.b.SEQUENTIAL_OR_PRECACHE, this.f9472k);
    }

    private void d() {
        if (b()) {
            if (n.a()) {
                this.logger.a(this.tag, "Scheduling refresh precache request now");
            }
            this.f9484w = true;
            this.sdk.j0().a((w4) new f6(this.sdk, "loadMaxAdForPrecacheRequest", new com.applovin.impl.mediation.ads.c(this, 1)), r5.b.MEDIATION);
        }
    }

    public void b(s2 s2Var) {
        View y8 = s2Var.y();
        String str = y8 == null ? "MaxAdView does not have a loaded ad view" : null;
        MaxAdView maxAdView = this.f9463b;
        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()) {
                n nVar = this.logger;
                String str2 = this.tag;
                StringBuilder sb = new StringBuilder("MaxAdListener.onAdDisplayFailed(ad=");
                sb.append(s2Var);
                sb.append(", error=");
                sb.append(maxErrorImpl);
                sb.append("), listener=");
                l.z(sb, this.adListener, nVar, str2);
            }
            l2.a(this.adListener, (MaxAd) s2Var, (MaxError) maxErrorImpl, true);
            this.sdk.Q().processAdDisplayErrorPostbackForUserError(maxErrorImpl, s2Var);
            return;
        }
        h();
        a((q2) s2Var);
        if (s2Var.i0()) {
            this.f9475n.a(s2Var);
        }
        maxAdView.setDescendantFocusability(393216);
        if (s2Var.k0() != Long.MAX_VALUE) {
            this.f9465d.setBackgroundColor((int) s2Var.k0());
        } else {
            long j8 = this.f9466e;
            if (j8 != Long.MAX_VALUE) {
                this.f9465d.setBackgroundColor((int) j8);
            } else {
                this.f9465d.setBackgroundColor(0);
            }
        }
        maxAdView.addView(y8);
        a(y8, s2Var);
        this.sdk.w().d(s2Var);
        c(s2Var);
        synchronized (this.f9476o) {
            this.f9478q = s2Var;
        }
        if (n.a()) {
            this.logger.a(this.tag, "Scheduling impression for ad manually...");
        }
        this.sdk.Q().processRawAdImpression(s2Var, this.f9471j);
        if (StringUtils.isValidString(this.f9478q.getAdReviewCreativeId())) {
            l2.a(this.adReviewListener, this.f9478q.getAdReviewCreativeId(), (MaxAd) this.f9478q, true);
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new com.applovin.impl.mediation.ads.d(this, s2Var, 1), s2Var.m0());
    }

    private void c(s2 s2Var) {
        int height = this.f9463b.getHeight();
        int width = this.f9463b.getWidth();
        if (height > 0 || width > 0) {
            int pxToDp = AppLovinSdkUtils.pxToDp(this.f9462a, height);
            int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f9462a, width);
            MaxAdFormat format = s2Var.getFormat();
            int height2 = (this.D ? format.getAdaptiveSize(pxToDp2, this.f9463b.getContext()) : format.getSize()).getHeight();
            int min = Math.min(format.getSize().getWidth(), k0.b(this.f9462a).x);
            if (pxToDp < height2 || pxToDp2 < min) {
                StringBuilder r8 = com.mobilefuse.sdk.assetsmanager.a.r(pxToDp2, pxToDp, "\n**************************************************\n`MaxAdView` size ", "x", " dp smaller than required ");
                r8.append(this.D ? "adaptive " : "");
                r8.append("size: ");
                r8.append(min);
                r8.append("x");
                String h8 = com.mobilefuse.sdk.assetsmanager.a.h(height2, " dp\nSome mediated networks (e.g. Google Ad Manager) may not render correctly\n**************************************************\n", r8);
                if (n.a()) {
                    this.logger.b("AppLovinSdk", h8);
                }
            }
        }
    }

    private void a(d.b bVar, a.InterfaceC0065a interfaceC0065a) {
        if (a()) {
            boolean c6 = z6.c(this.sdk);
            this.sdk.A().a(y1.f11012o0, "attemptingToLoadDestroyedAdView", CollectionUtils.hashMap("details", "debug=" + c6));
            if (!c6) {
                n.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 androidx.fragment.app.c(this, 15, interfaceC0065a, bVar));
    }

    public void a(a.InterfaceC0065a interfaceC0065a, d.b bVar) {
        int adaptiveWidth;
        s2 s2Var = this.f9478q;
        if (s2Var != null) {
            long a8 = this.f9474m.a(s2Var);
            this.extraParameters.put("visible_ad_ad_unit_id", this.f9478q.getAdUnitId());
            this.extraParameters.put("viewability_flags", Long.valueOf(a8));
        } else {
            this.extraParameters.remove("visible_ad_ad_unit_id");
            this.extraParameters.remove("viewability_flags");
        }
        int pxToDp = AppLovinSdkUtils.pxToDp(this.f9463b.getContext(), this.f9463b.getWidth());
        int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f9463b.getContext(), this.f9463b.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.f9473l.g() || this.f9482u));
        this.extraParameters.put("auto_retries_disabled", Boolean.valueOf(this.f9487z));
        MaxAdViewConfiguration maxAdViewConfiguration = this.f9470i;
        if (maxAdViewConfiguration != null && (adaptiveWidth = maxAdViewConfiguration.getAdaptiveWidth()) > 0 && pxToDp != adaptiveWidth) {
            n.j(this.tag, androidx.fragment.app.n.h(adaptiveWidth, pxToDp, "The requested adaptive ad view width (", " dp) is different from the MaxAdView width (", " dp)."));
        }
        if (n.a()) {
            this.logger.a(this.tag, "Loading " + this.adFormat.getLabel().toLowerCase(Locale.ENGLISH) + " ad for '" + this.adUnitId + "' and notifying " + interfaceC0065a + APSSharedUtil.TRUNCATE_SEPARATOR);
        }
        this.sdk.Q();
        String str = this.adUnitId;
        String str2 = this.f9464c;
        MaxAdFormat maxAdFormat = this.adFormat;
        Map<String, Object> map = this.localExtraParameters;
        Map<String, Object> map2 = this.extraParameters;
        Context context = this.f9462a;
    }

    private void a(String str, String str2) {
        if ("allow_pause_auto_refresh_immediately".equalsIgnoreCase(str)) {
            if (n.a()) {
                l.y("Updated allow immediate auto-refresh pause and ad load to: ", str2, this.logger, this.tag);
            }
            this.f9486y = Boolean.parseBoolean(str2);
            return;
        }
        if ("disable_auto_retries".equalsIgnoreCase(str)) {
            if (n.a()) {
                l.y("Updated disable auto-retries to: ", str2, this.logger, this.tag);
            }
            this.f9487z = Boolean.parseBoolean(str2);
            return;
        }
        if ("disable_precache".equalsIgnoreCase(str)) {
            if (n.a()) {
                l.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 (n.a()) {
                l.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 (n.a()) {
                l.y("Updated force precache to: ", str2, this.logger, this.tag);
            }
            this.C = Boolean.parseBoolean(str2);
        } else if ("adaptive_banner".equalsIgnoreCase(str)) {
            if (n.a()) {
                l.y("Updated is adaptive banner to: ", str2, this.logger, this.tag);
            }
            if (this.f9470i == 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.f9484w = false;
        synchronized (this.f9477p) {
            try {
                compareAndSet = this.f9483v.compareAndSet(true, false);
                if (!compareAndSet) {
                    if (n.a()) {
                        this.logger.a(this.tag, "Saving precache ad...");
                    }
                    s2 s2Var = (s2) maxAd;
                    this.f9467f = s2Var;
                    s2Var.g(this.f9468g);
                    this.f9467f.f(this.f9469h);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (compareAndSet) {
            if (n.a()) {
                this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + APSSharedUtil.TRUNCATE_SEPARATOR);
            }
            this.f9471j.onAdLoaded(maxAd);
        }
    }

    private boolean b() {
        if (this.A) {
            return false;
        }
        return ((Boolean) this.sdk.a(g3.V6)).booleanValue();
    }

    public void a(s2 s2Var) {
        long a8 = this.f9474m.a(s2Var);
        if (!s2Var.i0()) {
            a(s2Var, a8);
        }
        a(a8);
    }

    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.f9482u && !this.f9473l.g()) {
            this.f9481t = true;
            this.f9484w = false;
            long longValue = ((Long) this.sdk.a(g3.H6)).longValue();
            if (longValue >= 0) {
                this.sdk.I();
                if (n.a()) {
                    n I = this.sdk.I();
                    String str = this.tag;
                    StringBuilder g9 = y.g(longValue, "Scheduling failed banner ad refresh ", " milliseconds from now for '");
                    g9.append(this.adUnitId);
                    g9.append("'...");
                    I.a(str, g9.toString());
                }
                this.f9473l.a(longValue);
                return;
            }
            return;
        }
        if (this.f9484w) {
            if (n.a()) {
                this.logger.a(this.tag, "Refresh precache failed when auto-refresh is stopped");
            }
            this.f9484w = false;
        }
        if (this.f9483v.get()) {
            if (n.a()) {
                n nVar = this.logger;
                String str2 = this.tag;
                StringBuilder sb = new StringBuilder("Refresh precache failed - MaxAdListener.onAdLoadFailed(adUnitId=");
                sb.append(this.adUnitId);
                sb.append(", error=");
                sb.append(maxError);
                sb.append("), listener=");
                l.z(sb, this.adListener, nVar, str2);
            }
            l2.a(this.adListener, this.adUnitId, maxError, true);
        }
    }

    private void a(View view, s2 s2Var) {
        int n02 = s2Var.n0();
        int l02 = s2Var.l0();
        int dpToPx = n02 == -1 ? -1 : AppLovinSdkUtils.dpToPx(view.getContext(), n02);
        int dpToPx2 = l02 != -1 ? AppLovinSdkUtils.dpToPx(view.getContext(), l02) : -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, androidx.fragment.app.n.h(dpToPx, dpToPx2, "Pinning ad view to MAX ad view with width: ", " and height: ", InstructionFileId.DOT));
            }
            RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
            for (int i8 : q7.a(this.f9463b.getGravity(), 10, 14)) {
                layoutParams2.addRule(i8);
            }
        }
        view.setLayoutParams(layoutParams);
    }

    private void a(s2 s2Var, long j8) {
        if (n.a()) {
            this.logger.a(this.tag, "Scheduling viewability impression for ad...");
        }
        this.sdk.Q().processViewabilityAdImpressionPostback(s2Var, j8, this.f9471j);
    }

    private void a(long j8) {
        if (z6.a(j8, ((Long) this.sdk.a(g3.U6)).longValue()) && !this.C) {
            if (n.a()) {
                this.logger.a(this.tag, "Undesired flags matched - current: " + Long.toBinaryString(j8) + ", undesired: " + Long.toBinaryString(j8));
            }
            if (n.a()) {
                this.logger.a(this.tag, "Waiting for refresh timer to manually fire request");
            }
            this.f9481t = true;
            return;
        }
        if (n.a()) {
            this.logger.a(this.tag, "No undesired viewability flags matched or forcing precache - scheduling viewability");
        }
        this.f9481t = false;
        d();
    }

    public void a(MaxAd maxAd) {
        this.f9484w = false;
        if (this.f9483v.compareAndSet(true, false)) {
            if (n.a()) {
                this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + APSSharedUtil.TRUNCATE_SEPARATOR);
            }
            this.f9471j.onAdLoaded(maxAd);
            return;
        }
        if (n.a()) {
            this.logger.a(this.tag, "Saving precache ad...");
        }
        s2 s2Var = (s2) maxAd;
        this.f9467f = s2Var;
        s2Var.g(this.f9468g);
        this.f9467f.f(this.f9469h);
    }

    public boolean a() {
        boolean z8;
        synchronized (this.f9476o) {
            z8 = this.f9485x;
        }
        return z8;
    }
}