ZStore v1.7版本的 MD5 值为:ca9bb200afd8d690876bd39318f8215c

以下内容为反编译后的 e.java 源代码,内容仅作参考


package com.applovin.impl.adview.activity.b;

import android.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.StrictMode;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import androidx.annotation.Nullable;
import com.applovin.communicator.AppLovinCommunicator;
import com.applovin.communicator.AppLovinCommunicatorMessage;
import com.applovin.communicator.AppLovinCommunicatorSubscriber;
import com.applovin.exoplayer2.ab;
import com.applovin.exoplayer2.ak;
import com.applovin.exoplayer2.an;
import com.applovin.exoplayer2.aw;
import com.applovin.exoplayer2.h.u;
import com.applovin.exoplayer2.k.p;
import com.applovin.exoplayer2.l.ai;
import com.applovin.exoplayer2.ui.f;
import com.applovin.impl.adview.AppLovinTouchToClickListener;
import com.applovin.impl.adview.h;
import com.applovin.impl.adview.k;
import com.applovin.impl.adview.n;
import com.applovin.impl.adview.w;
import com.applovin.impl.adview.x;
import com.applovin.impl.sdk.e.ac;
import com.applovin.impl.sdk.e.r;
import com.applovin.impl.sdk.o;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.sdk.utils.Utils;
import com.applovin.impl.sdk.utils.t;
import com.applovin.impl.sdk.utils.v;
import com.applovin.sdk.AppLovinAdClickListener;
import com.applovin.sdk.AppLovinAdDisplayListener;
import com.applovin.sdk.AppLovinAdVideoPlaybackListener;
import com.applovin.sdk.AppLovinSdkUtils;
import com.iab.omid.library.applovin.adsession.FriendlyObstructionPurpose;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

public class e extends com.applovin.impl.adview.activity.b.a implements AppLovinCommunicatorSubscriber {

    @Nullable
    protected final n A;

    @Nullable
    protected h B;

    @Nullable
    protected final ImageView C;

    @Nullable
    protected w D;

    @Nullable
    protected final ProgressBar E;
    protected final k F;
    protected boolean G;
    protected long H;
    protected int I;
    protected boolean J;
    protected boolean K;
    private final com.applovin.impl.adview.activity.a.c L;
    private final a M;
    private final Handler N;
    private final boolean O;
    private long P;
    private final AtomicBoolean Q;
    private final AtomicBoolean R;
    private long S;
    private long T;
    protected final com.applovin.exoplayer2.ui.g x;
    protected final aw y;
    protected final com.applovin.impl.adview.a z;

    public e(com.applovin.impl.sdk.ad.e eVar, Activity activity, @Nullable Map<String, Object> map, o oVar, AppLovinAdClickListener appLovinAdClickListener, AppLovinAdDisplayListener appLovinAdDisplayListener, AppLovinAdVideoPlaybackListener appLovinAdVideoPlaybackListener) {
        super(eVar, activity, map, oVar, appLovinAdClickListener, appLovinAdDisplayListener, appLovinAdVideoPlaybackListener);
        this.L = new com.applovin.impl.adview.activity.a.c(this.a, this.e, this.b);
        this.M = new a();
        this.N = new Handler(Looper.getMainLooper());
        this.F = new k(this.N, this.b);
        this.O = this.a.f();
        this.G = Utils.isVideoMutedInitially(this.b);
        this.P = -1L;
        this.Q = new AtomicBoolean();
        this.R = new AtomicBoolean();
        this.S = -2L;
        this.T = 0L;
        if (!eVar.hasVideoUrl()) {
            throw new IllegalStateException("Attempting to use fullscreen video ad presenter for non-video ad");
        }
        c cVar = new c();
        if (eVar.r() >= 0) {
            this.A = new n(eVar.x(), activity);
            this.A.setVisibility(8);
            this.A.setOnClickListener(cVar);
        } else {
            this.A = null;
        }
        if (a(this.G, oVar)) {
            this.C = new ImageView(activity);
            this.C.setScaleType(ImageView.ScaleType.FIT_CENTER);
            this.C.setClickable(true);
            this.C.setOnClickListener(cVar);
            d(this.G);
        } else {
            this.C = null;
        }
        String C = eVar.C();
        if (StringUtils.isValidString(C)) {
            x xVar = new x(oVar);
            xVar.a(new WeakReference<>(this.M));
            this.D = new w(xVar, activity);
            this.D.a(C);
        } else {
            this.D = null;
        }
        if (this.O) {
            this.z = new com.applovin.impl.adview.a(activity, ((Integer) oVar.a(com.applovin.impl.sdk.c.b.cU)).intValue(), R.attr.progressBarStyleLarge);
            this.z.setColor(Color.parseColor("#75FFFFFF"));
            this.z.setBackgroundColor(Color.parseColor("#00000000"));
            this.z.setVisibility(8);
            AppLovinCommunicator.getInstance(activity).subscribe(this, "video_caching_failed");
        } else {
            this.z = null;
        }
        final int m = m();
        boolean z = ((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cE)).booleanValue() && m > 0;
        if (this.B == null && z) {
            this.B = new h(activity);
            int I = eVar.I();
            this.B.setTextColor(I);
            this.B.setTextSize(((Integer) oVar.a(com.applovin.impl.sdk.c.b.cD)).intValue());
            this.B.setFinishedStrokeColor(I);
            this.B.setFinishedStrokeWidth(((Integer) oVar.a(com.applovin.impl.sdk.c.b.cC)).intValue());
            this.B.setMax(m);
            this.B.setProgress(m);
            this.F.a("COUNTDOWN_CLOCK", TimeUnit.SECONDS.toMillis(1L), new k.a() {
                @Override
                public void a() {
                    if (e.this.B != null) {
                        long seconds = m - TimeUnit.MILLISECONDS.toSeconds(e.this.x.getPlayer().I());
                        if (seconds <= 0) {
                            e.this.n = true;
                        } else if (e.this.E()) {
                            e.this.B.setProgress((int) seconds);
                        }
                    }
                }

                @Override
                public boolean b() {
                    return e.this.E();
                }
            });
        }
        if (eVar.R()) {
            this.E = new ProgressBar(activity, null, R.attr.progressBarStyleHorizontal);
            this.E.setMax(10000);
            this.E.setPadding(0, 0, 0, 0);
            if (com.applovin.impl.sdk.utils.h.d()) {
                this.E.setProgressTintList(ColorStateList.valueOf(eVar.S()));
            }
            this.F.a("PROGRESS_BAR", ((Long) oVar.a(com.applovin.impl.sdk.c.b.cR)).longValue(), new k.a() {
                @Override
                public void a() {
                    if (e.this.J) {
                        e.this.E.setVisibility(8);
                    } else {
                        e.this.E.setProgress((int) ((((float) e.this.y.I()) / ((float) e.this.H)) * 10000.0f));
                    }
                }

                @Override
                public boolean b() {
                    return !e.this.J;
                }
            });
        } else {
            this.E = null;
        }
        this.y = new aw.a(activity).a();
        b bVar = new b();
        this.y.a((an.b) bVar);
        this.y.c(0);
        this.x = new com.applovin.exoplayer2.ui.g(activity);
        this.x.b();
        this.x.setControllerVisibilityListener(bVar);
        this.x.setPlayer(this.y);
        this.x.setOnTouchListener(new AppLovinTouchToClickListener(oVar, com.applovin.impl.sdk.c.b.aX, activity, bVar));
        C();
    }

    @Override
    public void d() {
        a((ViewGroup) null);
    }

    @Override
    public void a(@Nullable ViewGroup viewGroup) {
        this.L.a(this.C, this.A, this.D, this.z, this.E, this.B, this.x, this.f, this.g, null, viewGroup);
        if (this.g != null) {
            this.g.a();
        }
        this.y.a(true);
        if (this.a.ap()) {
            this.v.a(this.a, new Runnable() {
                @Override
                public void run() {
                    e.this.a(250L);
                }
            });
        }
        if (this.O) {
            y();
        }
        this.f.renderAd(this.a);
        this.d.b(this.O ? 1L : 0L);
        if (this.A != null) {
            this.b.N().a(new ac(this.b, new Runnable() {
                @Override
                public void run() {
                    e.this.D();
                }
            }), r.b.MAIN, this.a.s(), true);
        }
        super.b(this.G);
    }

    public void c(long j) {
        this.H = j;
    }

    protected void C() {
        a(!this.O);
        u a2 = new u.a(new p(this.e, ai.a((Context) this.e, "com.applovin.sdk"))).a(ab.a(this.a.h()));
        this.y.a(this.G ? 0 : 1);
        this.y.a((com.applovin.exoplayer2.h.p) a2);
        this.y.w();
        this.y.a(false);
    }

    protected void D() {
        if (this.R.compareAndSet(false, true)) {
            a(this.A, this.a.r(), new Runnable() {
                @Override
                public void run() {
                    e.this.S = -1L;
                    e.this.T = SystemClock.elapsedRealtime();
                }
            });
        }
    }

    @Override
    public void c(boolean z) {
        super.c(z);
        if (z) {
            a(0L);
        } else if (!this.J) {
            e();
        }
    }

    @Override
    public void h() {
        this.F.b();
        this.N.removeCallbacksAndMessages(null);
        n();
        super.h();
    }

    @Override
    public void k() {
        if (((Boolean) this.b.a(com.applovin.impl.sdk.c.b.gu)).booleanValue()) {
            com.applovin.impl.sdk.utils.w.a(this.D);
            this.D = null;
        }
        this.y.E();
        if (this.O) {
            AppLovinCommunicator.getInstance(this.e).unsubscribe(this, "video_caching_failed");
        }
        super.k();
    }

    public void a(PointF pointF, boolean z) {
        Context z2;
        if (this.a.E()) {
            com.applovin.impl.sdk.x xVar = this.c;
            if (com.applovin.impl.sdk.x.a()) {
                this.c.b("AppLovinFullscreenActivity", "Clicking through video");
            }
            Uri k = this.a.k();
            if (k != null) {
                if (this.f != null) {
                    z2 = this.f.getContext();
                } else {
                    o oVar = this.b;
                    z2 = o.z();
                }
                this.b.F().trackAndLaunchVideoClick(this.a, k, pointF, z, this, z2);
                com.applovin.impl.sdk.utils.n.a(this.s, this.a);
                this.d.b();
                this.p++;
                return;
            }
            return;
        }
        I();
    }

    private void I() {
        com.applovin.impl.adview.u D = this.a.D();
        if (D != null && D.e() && !this.J && this.D != null) {
            final boolean z = this.D.getVisibility() == 4;
            final long f = D.f();
            AppLovinSdkUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (z) {
                        v.a(e.this.D, f, (Runnable) null);
                    } else {
                        v.b(e.this.D, f, null);
                    }
                }
            });
        }
    }

    protected boolean E() {
        return (this.n || this.J || !this.x.getPlayer().a()) ? false : true;
    }

    public void c() {
        this.S = SystemClock.elapsedRealtime() - this.T;
        com.applovin.impl.sdk.x xVar = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Skipping video with skip time: " + this.S + "ms");
        }
        this.d.f();
        this.o++;
        if (this.a.y()) {
            h();
        } else {
            B();
        }
    }

    @Override
    public void e() {
        com.applovin.impl.sdk.x xVar = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Pausing video");
        }
        if (this.y.a()) {
            this.P = this.y.I();
            this.y.a(false);
            this.F.c();
            com.applovin.impl.sdk.x xVar2 = this.c;
            if (com.applovin.impl.sdk.x.a()) {
                this.c.b("AppLovinFullscreenActivity", "Paused video at position " + this.P + "ms");
                return;
            }
            return;
        }
        com.applovin.impl.sdk.x xVar3 = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Nothing to pause");
        }
    }

    protected void F() {
        this.I = H();
        this.y.a(false);
    }

    @Override
    public void a(long j) {
        a(new Runnable() {
            @Override
            public void run() {
                e.this.G();
            }
        }, j);
    }

    protected void G() {
        if (this.J) {
            com.applovin.impl.sdk.x xVar = this.c;
            if (com.applovin.impl.sdk.x.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - postitial shown");
                return;
            }
            return;
        }
        if (this.b.Z().isApplicationPaused()) {
            com.applovin.impl.sdk.x xVar2 = this.c;
            if (com.applovin.impl.sdk.x.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - app paused");
                return;
            }
            return;
        }
        if (this.P >= 0) {
            long j = this.P;
            com.applovin.impl.sdk.x xVar3 = this.c;
            if (com.applovin.impl.sdk.x.a()) {
                this.c.b("AppLovinFullscreenActivity", "Resuming video at position " + j + "ms for MediaPlayer: " + this.y);
            }
            this.y.a(true);
            this.F.a();
            this.P = -1L;
            if (!this.y.a()) {
                y();
                return;
            }
            return;
        }
        com.applovin.impl.sdk.x xVar4 = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Invalid last video position, isVideoPlaying=" + this.y.a());
        }
    }

    public void y() {
        AppLovinSdkUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (e.this.z != null) {
                    e.this.z.a();
                }
            }
        });
    }

    public void z() {
        AppLovinSdkUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (e.this.z != null) {
                    e.this.z.b();
                }
            }
        });
    }

    public void c(String str) {
        com.applovin.impl.sdk.x xVar = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.e("AppLovinFullscreenActivity", "Encountered media error: " + str + " for ad: " + this.a);
        }
        if (this.Q.compareAndSet(false, true)) {
            if (this.t instanceof com.applovin.impl.sdk.ad.h) {
                ((com.applovin.impl.sdk.ad.h) this.t).onAdDisplayFailed(str);
            }
            h();
        }
    }

    @Override
    public boolean s() {
        return this.a != null && H() >= this.a.T();
    }

    public int H() {
        if (this.y == null) {
            return 0;
        }
        long I = this.y.I();
        if (this.K) {
            return 100;
        }
        if (I > 0) {
            return (int) ((((float) I) / ((float) this.H)) * 100.0f);
        }
        return this.I;
    }

    @Override
    protected boolean t() {
        return u() && !s();
    }

    public void B() {
        F();
        this.L.a(this.h, this.g, this.f);
        a("javascript:al_onPoststitialShow(" + this.o + "," + this.p + ");", this.a.V());
        if (this.h != null) {
            if (this.a.t() >= 0) {
                a(this.h, this.a.t(), new Runnable() {
                    @Override
                    public void run() {
                        e.this.k = SystemClock.elapsedRealtime();
                    }
                });
            } else {
                this.h.setVisibility(0);
            }
        }
        ArrayList arrayList = new ArrayList();
        if (this.h != null) {
            arrayList.add(new com.applovin.impl.sdk.a.d(this.h, FriendlyObstructionPurpose.CLOSE_AD, "close button"));
        }
        if (this.g != null && this.g.b()) {
            arrayList.add(new com.applovin.impl.sdk.a.d(this.g, FriendlyObstructionPurpose.NOT_VISIBLE, this.g.getIdentifier()));
        }
        this.a.o().a(this.f, arrayList);
        w();
        this.J = true;
    }

    private static boolean a(boolean z, o oVar) {
        if (!((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cJ)).booleanValue()) {
            return false;
        }
        if (((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cK)).booleanValue() && !z) {
            return ((Boolean) oVar.a(com.applovin.impl.sdk.c.b.cM)).booleanValue();
        }
        return true;
    }

    protected void d(boolean z) {
        if (com.applovin.impl.sdk.utils.h.d()) {
            AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) this.e.getDrawable(z ? com.applovin.sdk.R.drawable.applovin_ic_unmute_to_mute : com.applovin.sdk.R.drawable.applovin_ic_mute_to_unmute);
            if (animatedVectorDrawable != null) {
                this.C.setScaleType(ImageView.ScaleType.FIT_XY);
                this.C.setImageDrawable(animatedVectorDrawable);
                animatedVectorDrawable.start();
                return;
            }
        }
        Uri aH = z ? this.a.aH() : this.a.aI();
        StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
        this.C.setImageURI(aH);
        StrictMode.setThreadPolicy(allowThreadDiskReads);
    }

    public void A() {
        this.G = !this.G;
        this.y.a(this.G ? 0 : 1);
        d(this.G);
        a(this.G, 0L);
    }

    @Override
    public void a() {
        com.applovin.impl.sdk.x xVar = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Continue video from prompt - will resume in onWindowFocusChanged(true) when alert dismisses");
        }
    }

    @Override
    public void b() {
        com.applovin.impl.sdk.x xVar = this.c;
        if (com.applovin.impl.sdk.x.a()) {
            this.c.b("AppLovinFullscreenActivity", "Skipping video from prompt");
        }
        c();
    }

    @Override
    protected void n() {
        super.a(H(), this.O, s(), this.S);
    }

    @Override
    protected void v() {
        long ah;
        if (this.a.ag() >= 0 || this.a.ah() >= 0) {
            if (this.a.ag() >= 0) {
                ah = this.a.ag();
            } else {
                com.applovin.impl.sdk.ad.a aVar = (com.applovin.impl.sdk.ad.a) this.a;
                long j = this.H > 0 ? 0 + this.H : 0L;
                if (aVar.ai()) {
                    int l = (int) ((com.applovin.impl.sdk.ad.a) this.a).l();
                    if (l > 0) {
                        j += TimeUnit.SECONDS.toMillis(l);
                    } else {
                        int t = (int) aVar.t();
                        if (t > 0) {
                            j += TimeUnit.SECONDS.toMillis(t);
                        }
                    }
                }
                ah = (long) (j * (this.a.ah() / 100.0d));
            }
            b(ah);
        }
    }

    @Override
    public void x() {
        super.x();
        this.L.a(this.D);
        this.L.a((View) this.A);
        if (!u() || this.J) {
            J();
        }
    }

    public void J() {
        this.L.a(this.i);
        this.k = SystemClock.elapsedRealtime();
    }

    @Override
    public void onMessageReceived(AppLovinCommunicatorMessage appLovinCommunicatorMessage) {
        if ("video_caching_failed".equals(appLovinCommunicatorMessage.getTopic())) {
            Bundle messageData = appLovinCommunicatorMessage.getMessageData();
            long j = messageData.getLong("ad_id");
            if (((Boolean) this.b.a(com.applovin.impl.sdk.c.b.gb)).booleanValue() && j == this.a.getAdIdNumber() && this.O) {
                int i = messageData.getInt("load_response_code");
                String string = messageData.getString("load_exception_message");
                if ((string != null || i < 200 || i >= 300) && !this.K && !this.y.a()) {
                    c("Video cache error during stream. ResponseCode=" + i + ", exception=" + string);
                }
            }
        }
    }

    @Override
    public String getCommunicatorId() {
        return "FullscreenVideoAdExoPlayerPresenter";
    }

    private class b implements an.b, f.d, AppLovinTouchToClickListener.OnClickListener {
        private b() {
        }

        @Override
        public void b(int i) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Player state changed to state " + i + " and will play when ready: " + e.this.y.x());
            }
            if (i == 2) {
                e.this.y();
                e.this.d.g();
                return;
            }
            if (i == 3) {
                e.this.y.a(e.this.G ? 0 : 1);
                e.this.m = (int) TimeUnit.MILLISECONDS.toSeconds(e.this.y.H());
                e.this.c(e.this.y.H());
                e.this.v();
                com.applovin.impl.sdk.x xVar2 = e.this.c;
                if (com.applovin.impl.sdk.x.a()) {
                    e.this.c.b("AppLovinFullscreenActivity", "MediaPlayer prepared: " + e.this.y);
                }
                e.this.F.a();
                if (e.this.A != null) {
                    e.this.D();
                }
                e.this.z();
                if (e.this.v.c()) {
                    e.this.e();
                    return;
                }
                return;
            }
            if (i == 4) {
                com.applovin.impl.sdk.x xVar3 = e.this.c;
                if (com.applovin.impl.sdk.x.a()) {
                    e.this.c.b("AppLovinFullscreenActivity", "Video completed");
                }
                e.this.K = true;
                if (!e.this.l) {
                    e.this.B();
                } else if (e.this.u()) {
                    e.this.J();
                }
            }
        }

        @Override
        public void a(ak akVar) {
            e.this.c("Video view error (" + akVar + ")");
            e.this.h();
        }

        @Override
        public void onClick(View view, PointF pointF) {
            e.this.a(pointF, false);
        }

        @Override
        public void a(int i) {
            if (i == 0) {
                e.this.x.b();
            }
        }
    }

    private class c implements View.OnClickListener {
        private c() {
        }

        @Override
        public void onClick(View view) {
            if (view == e.this.A) {
                if (e.this.t()) {
                    e.this.e();
                    e.this.q();
                    e.this.v.b();
                    return;
                }
                e.this.c();
                return;
            }
            if (view == e.this.C) {
                e.this.A();
                return;
            }
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.e("AppLovinFullscreenActivity", "Unhandled click on widget: " + view);
            }
        }
    }

    private class a implements x.a {
        private a() {
        }

        @Override
        public void a(w wVar) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Clicking through from video button...");
            }
            e.this.a(wVar.getAndClearLastClickLocation(), false);
        }

        @Override
        public void b(w wVar) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Closing ad from video button...");
            }
            e.this.h();
        }

        @Override
        public void c(w wVar) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Skipping video from video button...");
            }
            e.this.c();
        }

        @Override
        public void d(w wVar) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Attempting to install app from video button...");
            }
            e.this.a(wVar.getAndClearLastClickLocation(), true);
        }

        @Override
        public void a(Uri uri, w wVar) {
            com.applovin.impl.sdk.x xVar = e.this.c;
            if (com.applovin.impl.sdk.x.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Attempting to load a url from video button...");
            }
            t.a(uri, e.this.f.getController(), e.this.b);
        }
    }
}