导航菜单

页面标题

页面副标题

Antivirus Cleaner v1.2.0.0 - MaxAdViewImpl.java 源代码

正在查看: Antivirus Cleaner v1.2.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.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.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.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.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 f6379a;

    private final MaxAdView f6380b;

    private final String f6381c;

    private final View f6382d;

    private long f6383e;

    private s2 f6384f;

    private String f6385g;

    private String f6386h;

    private final MaxAdViewConfiguration f6387i;

    private final b f6388j;

    private final d f6389k;

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

    private final r7 f6391m;

    private final s7 f6392n;

    private final Object f6393o;

    private final Object f6394p;

    private s2 f6395q;

    private MaxAd f6396r;

    private boolean f6397s;

    private boolean f6398t;

    private boolean f6399u;

    private final AtomicBoolean f6400v;

    private boolean f6401w;

    private boolean f6402x;

    private boolean f6403y;

    private boolean f6404z;

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

        @Override
        public void onAdLoadFailed(String str, MaxError maxError) {
            com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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);
        }

        @Override
        public void onAdLoaded(MaxAd maxAd) {
            if (MaxAdViewImpl.this.a()) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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.f6385g);
            s2Var.f(MaxAdViewImpl.this.f6386h);
            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 (com.applovin.impl.sdk.n.a()) {
                    MaxAdViewImpl.this.sdk.I().a(MaxAdViewImpl.this.tag, "Scheduling banner ad refresh " + j02 + " milliseconds from now for '" + MaxAdViewImpl.this.adUnitId + "'...");
                }
                MaxAdViewImpl.this.f6390l.a(j02);
                if (MaxAdViewImpl.this.f6390l.g() || MaxAdViewImpl.this.f6399u) {
                    com.applovin.impl.sdk.n nVar2 = MaxAdViewImpl.this.logger;
                    if (com.applovin.impl.sdk.n.a()) {
                        MaxAdViewImpl maxAdViewImpl2 = MaxAdViewImpl.this;
                        maxAdViewImpl2.logger.a(maxAdViewImpl2.tag, "Pausing ad refresh for publisher");
                    }
                    MaxAdViewImpl.this.f6390l.j();
                }
            }
            com.applovin.impl.sdk.n nVar3 = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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 abstract class c implements MaxAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0085a {
        private c() {
        }

        @Override
        public void onAdClicked(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f6395q)) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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);
            }
        }

        @Override
        public void onAdCollapsed(MaxAd maxAd) {
            if (maxAd.equals(((Boolean) MaxAdViewImpl.this.sdk.a(g3.j7)).booleanValue() ? MaxAdViewImpl.this.f6396r : MaxAdViewImpl.this.f6395q)) {
                MaxAdViewImpl.this.f6396r = null;
                if ((MaxAdViewImpl.this.f6395q.p0() || MaxAdViewImpl.this.B) && MaxAdViewImpl.this.f6397s) {
                    MaxAdViewImpl.this.f6397s = false;
                    MaxAdViewImpl.this.startAutoRefresh();
                }
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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);
            }
        }

        @Override
        public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) {
            if (maxAd.equals(MaxAdViewImpl.this.f6395q)) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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);
            }
        }

        @Override
        public void onAdDisplayed(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f6395q)) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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);
            }
        }

        @Override
        public void onAdExpanded(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f6395q)) {
                if (((Boolean) MaxAdViewImpl.this.sdk.a(g3.j7)).booleanValue()) {
                    MaxAdViewImpl.this.f6396r = maxAd;
                }
                if ((MaxAdViewImpl.this.f6395q.p0() || MaxAdViewImpl.this.B) && !MaxAdViewImpl.this.f6390l.g()) {
                    MaxAdViewImpl.this.f6397s = true;
                    MaxAdViewImpl.this.stopAutoRefresh();
                }
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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);
            }
        }

        @Override
        public void onAdHidden(MaxAd maxAd) {
            if (maxAd.equals(MaxAdViewImpl.this.f6395q)) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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) {
            com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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);
        }

        @Override
        public void onAdRevenuePaid(MaxAd maxAd) {
            com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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) {
            com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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.f6402x) {
                com.applovin.impl.sdk.n nVar = MaxAdViewImpl.this.logger;
                if (com.applovin.impl.sdk.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;
                }
            }
            com.applovin.impl.sdk.n nVar2 = MaxAdViewImpl.this.logger;
            if (com.applovin.impl.sdk.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.f6381c = UUID.randomUUID().toString().toLowerCase(Locale.US);
        this.f6383e = Long.MAX_VALUE;
        this.f6393o = new Object();
        this.f6394p = new Object();
        this.f6395q = null;
        this.f6396r = null;
        this.f6400v = new AtomicBoolean();
        this.f6402x = false;
        this.f6379a = context.getApplicationContext();
        this.f6380b = maxAdView;
        this.f6382d = view;
        this.f6388j = new b();
        this.f6389k = new d();
        this.f6390l = new com.applovin.impl.sdk.f(this.sdk, this);
        this.f6391m = new r7(maxAdView, this.sdk);
        this.f6392n = new s7(maxAdView, this.sdk, this);
        this.f6387i = 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 (com.applovin.impl.sdk.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.f6385g;
    }

    public void loadAd() {
        loadAd(d.b.PUBLISHER_INITIATED);
    }

    @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.f6395q;
        if (s2Var != null && s2Var.N().equalsIgnoreCase(str)) {
            this.f6395q.h(str2);
            l2.b(this.adReviewListener, str2, this.f6395q);
            return;
        }
        s2 s2Var2 = this.f6384f;
        if (s2Var2 == null || !s2Var2.N().equalsIgnoreCase(str)) {
            return;
        }
        this.f6384f.h(str2);
    }

    @Override
    public void onLogVisibilityImpression() {
        a(this.f6395q, this.f6391m.a(this.f6395q));
    }

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

    public void setCustomData(String str) {
        if (this.f6395q != null && com.applovin.impl.sdk.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.f6386h = str;
    }

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

    public void setPlacement(String str) {
        if (this.f6395q != null && com.applovin.impl.sdk.n.a()) {
            this.logger.k(this.tag, "Setting placement (" + str + ") for Ad Unit ID (" + this.adUnitId + ") after an ad has been loaded already.");
        }
        this.f6385g = str;
    }

    public void setPublisherBackgroundColor(int i4) {
        this.f6383e = i4;
    }

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

    public void stopAutoRefresh() {
        if (this.f6395q == null) {
            if (this.f6403y || ((Boolean) this.sdk.a(g3.O6)).booleanValue()) {
                this.f6399u = true;
                return;
            } else {
                com.applovin.impl.sdk.n.j(this.tag, "Stopping auto-refresh has no effect until after the first ad has been loaded.");
                return;
            }
        }
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Pausing auto-refresh with remaining time: " + this.f6390l.b() + "ms");
        }
        this.f6390l.j();
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("MaxAdView{adUnitId='");
        sb.append(this.adUnitId);
        sb.append('\'');
        sb.append(", adListener=");
        Object obj = this.adListener;
        if (obj == this.f6380b) {
            obj = "this";
        }
        sb.append(obj);
        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.f6400v.set(false);
        if (this.f6384f != null) {
            i();
            return;
        }
        if (!b()) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Refreshing ad from network...");
            }
            loadAd(d.b.REFRESH);
        } else if (this.f6398t) {
            if (com.applovin.impl.sdk.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 (com.applovin.impl.sdk.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.f6400v.set(true);
        }
    }

    private void f() {
        boolean z3;
        boolean z4;
        synchronized (this.f6394p) {
            try {
                z3 = false;
                this.f6400v.set(false);
                z4 = this.f6384f != null;
                if (!z4) {
                    if (b()) {
                        if (!this.f6398t) {
                            if (com.applovin.impl.sdk.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.f6400v.set(true);
                        } else if (com.applovin.impl.sdk.n.a()) {
                            this.logger.a(this.tag, "Refreshing ad from network due to viewability requirements not met for refresh request...");
                        }
                    } else if (com.applovin.impl.sdk.n.a()) {
                        this.logger.a(this.tag, "Refreshing ad from network...");
                    }
                    z3 = true;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (z4) {
            i();
        } else if (z3) {
            loadAd(d.b.REFRESH);
        }
    }

    public void g() {
        h();
        if (this.f6384f != null) {
            this.sdk.Q().destroyAd(this.f6384f);
        }
        synchronized (this.f6393o) {
            this.f6402x = true;
        }
        this.f6390l.a();
        this.sdk.j().b(this);
        this.sdk.K().c(this.adUnitId, this.f6381c);
        super.destroy();
    }

    private void h() {
        s2 s2Var;
        MaxAdView maxAdView = this.f6380b;
        if (maxAdView != null) {
            com.applovin.impl.q.a(maxAdView, this.f6382d);
        }
        this.f6392n.b();
        synchronized (this.f6393o) {
            s2Var = this.f6395q;
        }
        MaxAd maxAd = this.f6396r;
        if (maxAd != null && maxAd.equals(s2Var)) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Collapsing ad manually for removed ad.");
            }
            l2.b(this.f6388j, maxAd);
        }
        if (s2Var != null) {
            this.sdk.Q().destroyAd(s2Var);
        }
    }

    private void i() {
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Rendering for cached ad: " + this.f6384f + "...");
        }
        this.f6388j.onAdLoaded(this.f6384f);
        this.f6384f = null;
    }

    public void loadAd(d.b bVar) {
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "" + this + " Loading ad for " + this.adUnitId + "...");
        }
        boolean z3 = this.f6403y || ((Boolean) this.sdk.a(g3.O6)).booleanValue();
        if (z3 && !this.f6390l.g() && this.f6390l.h()) {
            com.applovin.impl.sdk.n.h(this.tag, "Unable to load a new ad. An ad refresh has already been scheduled in " + TimeUnit.MILLISECONDS.toSeconds(this.f6390l.b()) + " seconds.");
            return;
        }
        if (!z3) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Loading ad...");
            }
            a(bVar, this.f6388j);
        } else if (this.f6384f != null) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Rendering cached ad");
            }
            i();
        } else if (this.f6401w) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Waiting for precache ad to load to render");
            }
            this.f6400v.set(true);
        } else {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Loading ad...");
            }
            a(bVar, this.f6388j);
        }
    }

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

    private void d() {
        if (b()) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Scheduling refresh precache request now");
            }
            this.f6401w = true;
            this.sdk.j0().a((w4) new f6(this.sdk, "loadMaxAdForPrecacheRequest", new Runnable() {
                @Override
                public final void run() {
                    MaxAdViewImpl.this.c();
                }
            }), r5.b.MEDIATION);
        }
    }

    public void b(final s2 s2Var) {
        View y3 = s2Var.y();
        String str = y3 == null ? "MaxAdView does not have a loaded ad view" : null;
        MaxAdView maxAdView = this.f6380b;
        if (maxAdView == null) {
            str = "MaxAdView does not have a parent view";
        }
        if (str != null) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.b(this.tag, str);
            }
            MaxErrorImpl maxErrorImpl = new MaxErrorImpl(-1, str);
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "MaxAdListener.onAdDisplayFailed(ad=" + s2Var + ", error=" + maxErrorImpl + "), listener=" + this.adListener);
            }
            l2.a(this.adListener, (MaxAd) s2Var, (MaxError) maxErrorImpl, true);
            this.sdk.Q().processAdDisplayErrorPostbackForUserError(maxErrorImpl, s2Var);
            return;
        }
        h();
        a((q2) s2Var);
        if (s2Var.i0()) {
            this.f6392n.a(s2Var);
        }
        maxAdView.setDescendantFocusability(393216);
        if (s2Var.k0() != Long.MAX_VALUE) {
            this.f6382d.setBackgroundColor((int) s2Var.k0());
        } else {
            long j4 = this.f6383e;
            if (j4 != Long.MAX_VALUE) {
                this.f6382d.setBackgroundColor((int) j4);
            } else {
                this.f6382d.setBackgroundColor(0);
            }
        }
        maxAdView.addView(y3);
        a(y3, s2Var);
        this.sdk.w().d(s2Var);
        c(s2Var);
        synchronized (this.f6393o) {
            this.f6395q = s2Var;
        }
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Scheduling impression for ad manually...");
        }
        this.sdk.Q().processRawAdImpression(s2Var, this.f6388j);
        if (StringUtils.isValidString(this.f6395q.getAdReviewCreativeId())) {
            l2.a(this.adReviewListener, this.f6395q.getAdReviewCreativeId(), (MaxAd) this.f6395q, true);
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
            @Override
            public final void run() {
                MaxAdViewImpl.this.a(s2Var);
            }
        }, s2Var.m0());
    }

    private void c(s2 s2Var) {
        int height = this.f6380b.getHeight();
        int width = this.f6380b.getWidth();
        if (height > 0 || width > 0) {
            int pxToDp = AppLovinSdkUtils.pxToDp(this.f6379a, height);
            int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f6379a, width);
            MaxAdFormat format = s2Var.getFormat();
            int height2 = (this.D ? format.getAdaptiveSize(pxToDp2, this.f6380b.getContext()) : format.getSize()).getHeight();
            int min = Math.min(format.getSize().getWidth(), k0.b(this.f6379a).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 (com.applovin.impl.sdk.n.a()) {
                    this.logger.b("AppLovinSdk", sb2);
                }
            }
        }
    }

    private void a(final d.b bVar, final a.InterfaceC0085a interfaceC0085a) {
        if (a()) {
            boolean c4 = z6.c(this.sdk);
            this.sdk.A().a(y1.f8228o0, "attemptingToLoadDestroyedAdView", CollectionUtils.hashMap("details", "debug=" + c4));
            if (!c4) {
                com.applovin.impl.sdk.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(interfaceC0085a, bVar);
            }
        });
    }

    public void a(a.InterfaceC0085a interfaceC0085a, d.b bVar) {
        int adaptiveWidth;
        s2 s2Var = this.f6395q;
        if (s2Var != null) {
            long a4 = this.f6391m.a(s2Var);
            this.extraParameters.put("visible_ad_ad_unit_id", this.f6395q.getAdUnitId());
            this.extraParameters.put("viewability_flags", Long.valueOf(a4));
        } else {
            this.extraParameters.remove("visible_ad_ad_unit_id");
            this.extraParameters.remove("viewability_flags");
        }
        int pxToDp = AppLovinSdkUtils.pxToDp(this.f6380b.getContext(), this.f6380b.getWidth());
        int pxToDp2 = AppLovinSdkUtils.pxToDp(this.f6380b.getContext(), this.f6380b.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.f6390l.g() || this.f6399u));
        this.extraParameters.put("auto_retries_disabled", Boolean.valueOf(this.f6404z));
        MaxAdViewConfiguration maxAdViewConfiguration = this.f6387i;
        if (maxAdViewConfiguration != null && (adaptiveWidth = maxAdViewConfiguration.getAdaptiveWidth()) > 0 && pxToDp != adaptiveWidth) {
            com.applovin.impl.sdk.n.j(this.tag, "The requested adaptive ad view width (" + adaptiveWidth + " dp) is different from the MaxAdView width (" + pxToDp + " dp).");
        }
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Loading " + this.adFormat.getLabel().toLowerCase(Locale.ENGLISH) + " ad for '" + this.adUnitId + "' and notifying " + interfaceC0085a + "...");
        }
        this.sdk.Q().loadAd(this.adUnitId, this.f6381c, this.adFormat, bVar, this.localExtraParameters, this.extraParameters, this.f6379a, interfaceC0085a);
    }

    private void a(String str, String str2) {
        if ("allow_pause_auto_refresh_immediately".equalsIgnoreCase(str)) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Updated allow immediate auto-refresh pause and ad load to: " + str2);
            }
            this.f6403y = Boolean.parseBoolean(str2);
            return;
        }
        if ("disable_auto_retries".equalsIgnoreCase(str)) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Updated disable auto-retries to: " + str2);
            }
            this.f6404z = Boolean.parseBoolean(str2);
            return;
        }
        if ("disable_precache".equalsIgnoreCase(str)) {
            if (com.applovin.impl.sdk.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 (com.applovin.impl.sdk.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 (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Updated force precache to: " + str2);
            }
            this.C = Boolean.parseBoolean(str2);
            return;
        }
        if ("adaptive_banner".equalsIgnoreCase(str)) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Updated is adaptive banner to: " + str2);
            }
            if (this.f6387i == null) {
                com.applovin.impl.sdk.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.f6401w = false;
        synchronized (this.f6394p) {
            try {
                compareAndSet = this.f6400v.compareAndSet(true, false);
                if (!compareAndSet) {
                    if (com.applovin.impl.sdk.n.a()) {
                        this.logger.a(this.tag, "Saving precache ad...");
                    }
                    s2 s2Var = (s2) maxAd;
                    this.f6384f = s2Var;
                    s2Var.g(this.f6385g);
                    this.f6384f.f(this.f6386h);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (compareAndSet) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
            }
            this.f6388j.onAdLoaded(maxAd);
        }
    }

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

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

    public void a(MaxError maxError) {
        if (a()) {
            if (com.applovin.impl.sdk.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 (com.applovin.impl.sdk.n.a()) {
                this.sdk.I().a(this.tag, "Ignoring banner ad refresh for error code " + maxError.getCode());
                return;
            }
            return;
        }
        if (!this.f6399u && !this.f6390l.g()) {
            this.f6398t = true;
            this.f6401w = false;
            long longValue = ((Long) this.sdk.a(g3.H6)).longValue();
            if (longValue >= 0) {
                this.sdk.I();
                if (com.applovin.impl.sdk.n.a()) {
                    this.sdk.I().a(this.tag, "Scheduling failed banner ad refresh " + longValue + " milliseconds from now for '" + this.adUnitId + "'...");
                }
                this.f6390l.a(longValue);
                return;
            }
            return;
        }
        if (this.f6401w) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Refresh precache failed when auto-refresh is stopped");
            }
            this.f6401w = false;
        }
        if (this.f6400v.get()) {
            if (com.applovin.impl.sdk.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 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 (com.applovin.impl.sdk.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 i4 : q7.a(this.f6380b.getGravity(), 10, 14)) {
                layoutParams2.addRule(i4);
            }
        }
        view.setLayoutParams(layoutParams);
    }

    private void a(s2 s2Var, long j4) {
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Scheduling viewability impression for ad...");
        }
        this.sdk.Q().processViewabilityAdImpressionPostback(s2Var, j4, this.f6388j);
    }

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

    public void a(MaxAd maxAd) {
        this.f6401w = false;
        if (this.f6400v.compareAndSet(true, false)) {
            if (com.applovin.impl.sdk.n.a()) {
                this.logger.a(this.tag, "Rendering precache request ad: " + maxAd.getAdUnitId() + "...");
            }
            this.f6388j.onAdLoaded(maxAd);
            return;
        }
        if (com.applovin.impl.sdk.n.a()) {
            this.logger.a(this.tag, "Saving precache ad...");
        }
        s2 s2Var = (s2) maxAd;
        this.f6384f = s2Var;
        s2Var.g(this.f6385g);
        this.f6384f.f(this.f6386h);
    }

    public boolean a() {
        boolean z3;
        synchronized (this.f6393o) {
            z3 = this.f6402x;
        }
        return z3;
    }
}