Apk Done v1.0版本的 MD5 值为:44cfb8e1ce639995aa7f0de6a3a6388b

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


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

import android.app.Activity;
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 com.applovin.communicator.AppLovinCommunicator;
import com.applovin.communicator.AppLovinCommunicatorMessage;
import com.applovin.communicator.AppLovinCommunicatorSubscriber;
import com.applovin.impl.adview.AppLovinTouchToClickListener;
import com.applovin.impl.adview.j;
import com.applovin.impl.adview.m;
import com.applovin.impl.adview.s;
import com.applovin.impl.adview.t;
import com.applovin.impl.adview.u;
import com.applovin.impl.sdk.e.o;
import com.applovin.impl.sdk.e.z;
import com.applovin.impl.sdk.n;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.sdk.utils.Utils;
import com.applovin.impl.sdk.utils.p;
import com.applovin.impl.sdk.w;
import com.applovin.sdk.AppLovinAdClickListener;
import com.applovin.sdk.AppLovinAdDisplayListener;
import com.applovin.sdk.AppLovinAdVideoPlaybackListener;
import com.applovin.sdk.AppLovinSdkUtils;
import com.applovin.sdk.R;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import com.yandex.metrica.YandexMetricaDefaultValues;
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class e extends com.applovin.impl.adview.activity.b.a implements AppLovinCommunicatorSubscriber {
    protected final j A;
    protected boolean B;
    protected long C;
    protected int D;
    protected boolean E;
    protected boolean F;
    private final com.applovin.impl.adview.activity.a.c G;
    private final a H;
    private final Handler I;
    private final boolean J;
    private long K;
    private final AtomicBoolean L;
    private final AtomicBoolean M;
    private long N;
    private long O;
    protected final PlayerView t;
    protected final SimpleExoPlayer u;
    protected final com.applovin.impl.adview.a v;
    protected final m w;
    protected final ImageView x;
    protected final t y;
    protected final ProgressBar z;

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

        @Override
        public void a(t tVar) {
            if (w.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Clicking through from video button...");
            }
            e.this.a(tVar.getAndClearLastClickLocation());
        }

        @Override
        public void b(t tVar) {
            if (w.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Closing ad from video button...");
            }
            e.this.h();
        }

        @Override
        public void c(t tVar) {
            if (w.a()) {
                e.this.c.b("AppLovinFullscreenActivity", "Skipping video from video button...");
            }
            e.this.c();
        }
    }

    private class b implements AppLovinTouchToClickListener.OnClickListener, Player.EventListener, PlayerControlView.VisibilityListener {
        private b() {
        }

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

        public void onPlaybackStateChanged(int i) {
            if (w.a()) {
                w wVar = e.this.c;
                wVar.b("AppLovinFullscreenActivity", "Player state changed to state " + i + " and will play when ready: " + e.this.u.getPlayWhenReady());
            }
            if (i == 2) {
                e.this.u();
                e.this.d.g();
            } else if (i != 3) {
                if (i == 4) {
                    if (w.a()) {
                        e.this.c.b("AppLovinFullscreenActivity", "Video completed");
                    }
                    e.this.F = true;
                    e.this.x();
                }
            } else {
                e.this.u.setVolume(!e.this.B ? 1 : 0);
                e eVar = e.this;
                eVar.c(eVar.u.getDuration());
                e.this.t();
                if (w.a()) {
                    w wVar2 = e.this.c;
                    wVar2.b("AppLovinFullscreenActivity", "MediaPlayer prepared: " + e.this.u);
                }
                e.this.A.a();
                if (e.this.w != null) {
                    e.this.z();
                }
                e.this.v();
                if (e.this.q.c()) {
                    e.this.e();
                }
            }
        }

        public void onPlayerError(ExoPlaybackException exoPlaybackException) {
            e eVar = e.this;
            eVar.c("Video view error (" + exoPlaybackException + ")");
            e.this.h();
        }

        public void onVisibilityChange(int i) {
            if (i == 0) {
                e.this.t.hideController();
            }
        }
    }

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

        @Override
        public void onClick(View view) {
            if (view == e.this.w) {
                if (!e.this.r()) {
                    e.this.c();
                    return;
                }
                e.this.e();
                e.this.o();
                e.this.q.b();
            } else if (view == e.this.x) {
                e.this.w();
            } else if (w.a()) {
                w wVar = e.this.c;
                wVar.e("AppLovinFullscreenActivity", "Unhandled click on widget: " + view);
            }
        }
    }

    public e(com.applovin.impl.sdk.ad.e eVar, Activity activity, n nVar, AppLovinAdClickListener appLovinAdClickListener, AppLovinAdDisplayListener appLovinAdDisplayListener, AppLovinAdVideoPlaybackListener appLovinAdVideoPlaybackListener) {
        super(eVar, activity, nVar, appLovinAdClickListener, appLovinAdDisplayListener, appLovinAdVideoPlaybackListener);
        this.G = new com.applovin.impl.adview.activity.a.c(this.a, this.e, this.b);
        this.H = new a();
        Handler handler = new Handler(Looper.getMainLooper());
        this.I = handler;
        this.A = new j(handler, this.b);
        this.J = this.a.f();
        this.B = Utils.isVideoMutedInitially(this.b);
        this.K = -1L;
        this.L = new AtomicBoolean();
        this.M = new AtomicBoolean();
        this.N = -2L;
        this.O = 0L;
        if (!eVar.hasVideoUrl()) {
            throw new IllegalStateException("Attempting to use fullscreen video ad presenter for non-video ad");
        }
        c cVar = new c();
        if (eVar.q() >= 0) {
            m mVar = new m(eVar.w(), activity);
            this.w = mVar;
            mVar.setVisibility(8);
            this.w.setOnClickListener(cVar);
        } else {
            this.w = null;
        }
        if (a(this.B, nVar)) {
            ImageView imageView = new ImageView(activity);
            this.x = imageView;
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            this.x.setClickable(true);
            this.x.setOnClickListener(cVar);
            d(this.B);
        } else {
            this.x = null;
        }
        String B = eVar.B();
        if (StringUtils.isValidString(B)) {
            u uVar = new u(nVar);
            uVar.a(new WeakReference<>(this.H));
            t tVar = new t(uVar, activity);
            this.y = tVar;
            tVar.a(B);
        } else {
            this.y = null;
        }
        if (this.J) {
            com.applovin.impl.adview.a aVar = new com.applovin.impl.adview.a(activity, ((Integer) nVar.a(com.applovin.impl.sdk.c.b.cC)).intValue(), 16842874);
            this.v = aVar;
            aVar.setColor(Color.parseColor("#75FFFFFF"));
            this.v.setBackgroundColor(Color.parseColor("#00000000"));
            this.v.setVisibility(8);
            AppLovinCommunicator.getInstance(activity).subscribe(this, "video_caching_failed");
        } else {
            this.v = null;
        }
        if (eVar.L()) {
            ProgressBar progressBar = new ProgressBar(activity, null, 16842872);
            this.z = progressBar;
            progressBar.setMax(YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_COUNT_UPPER_BOUND);
            this.z.setPadding(0, 0, 0, 0);
            if (com.applovin.impl.sdk.utils.g.d()) {
                this.z.setProgressTintList(ColorStateList.valueOf(eVar.M()));
            }
            this.A.a("PROGRESS_BAR", ((Long) nVar.a(com.applovin.impl.sdk.c.b.cz)).longValue(), new j.a() {
                @Override
                public void a() {
                    if (e.this.E) {
                        e.this.z.setVisibility(8);
                        return;
                    }
                    e.this.z.setProgress((int) ((((float) e.this.u.getCurrentPosition()) / ((float) e.this.C)) * 10000.0f));
                }

                @Override
                public boolean b() {
                    return !e.this.E;
                }
            });
        } else {
            this.z = null;
        }
        this.u = new SimpleExoPlayer.Builder(activity).build();
        b bVar = new b();
        this.u.addListener(bVar);
        this.u.setRepeatMode(0);
        PlayerView playerView = new PlayerView(activity);
        this.t = playerView;
        playerView.hideController();
        this.t.setControllerVisibilityListener(bVar);
        this.t.setPlayer(this.u);
        this.t.setOnTouchListener(new AppLovinTouchToClickListener(nVar, com.applovin.impl.sdk.c.b.aM, activity, bVar));
        y();
    }

    private void D() {
        t tVar;
        s C = this.a.C();
        if (C == null || !C.e() || this.E || (tVar = this.y) == null) {
            return;
        }
        final boolean z = tVar.getVisibility() == 4;
        final long f = C.f();
        AppLovinSdkUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (z) {
                    p.a(e.this.y, f, (Runnable) null);
                } else {
                    p.b(e.this.y, f, null);
                }
            }
        });
    }

    private static boolean a(boolean z, n nVar) {
        if (((Boolean) nVar.a(com.applovin.impl.sdk.c.b.cr)).booleanValue()) {
            if (!((Boolean) nVar.a(com.applovin.impl.sdk.c.b.cs)).booleanValue() || z) {
                return true;
            }
            return ((Boolean) nVar.a(com.applovin.impl.sdk.c.b.cu)).booleanValue();
        }
        return false;
    }

    protected void A() {
        this.D = C();
        this.u.setPlayWhenReady(false);
    }

    protected void B() {
        if (this.E) {
            if (w.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - postitial shown");
            }
        } else if (this.b.ad().a()) {
            if (w.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - app paused");
            }
        } else {
            long j = this.K;
            if (j < 0) {
                if (w.a()) {
                    w wVar = this.c;
                    wVar.b("AppLovinFullscreenActivity", "Invalid last video position, isVideoPlaying=" + this.u.isPlaying());
                    return;
                }
                return;
            }
            long aH = this.a.aH();
            if (aH > 0) {
                j = Math.max(0L, j - aH);
                this.u.seekTo(j);
            }
            if (w.a()) {
                w wVar2 = this.c;
                wVar2.b("AppLovinFullscreenActivity", "Resuming video at position " + j + "ms for MediaPlayer: " + this.u);
            }
            this.u.setPlayWhenReady(true);
            this.A.a();
            this.K = -1L;
            if (this.u.isPlaying()) {
                return;
            }
            u();
        }
    }

    public int C() {
        SimpleExoPlayer simpleExoPlayer = this.u;
        if (simpleExoPlayer == null) {
            return 0;
        }
        long currentPosition = simpleExoPlayer.getCurrentPosition();
        if (this.F) {
            return 100;
        }
        return currentPosition > 0 ? (int) ((((float) currentPosition) / ((float) this.C)) * 100.0f) : this.D;
    }

    @Override
    public void a() {
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Continue video from prompt - will resume in onWindowFocusChanged(true) when alert dismisses");
        }
    }

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

    public void a(PointF pointF) {
        if (!this.a.D()) {
            D();
            return;
        }
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Clicking through video");
        }
        Uri k = this.a.k();
        if (k != null) {
            this.b.u().trackAndLaunchVideoClick(this.a, k, pointF, this, this.f != null ? this.f.getContext() : this.b.L());
            com.applovin.impl.sdk.utils.j.a(this.n, this.a);
            this.d.b();
            this.k++;
        }
    }

    @Override
    public void a(ViewGroup viewGroup) {
        this.G.a(this.x, this.w, this.y, this.v, this.z, this.t, this.f, viewGroup);
        this.u.setPlayWhenReady(true);
        if (this.a.ak()) {
            this.q.a(this.a, new Runnable() {
                @Override
                public void run() {
                    e.this.a(250L);
                }
            });
        }
        if (this.J) {
            u();
        }
        this.f.renderAd(this.a);
        this.d.b(this.J ? 1L : 0L);
        if (this.w != null) {
            this.b.S().a(new z(this.b, new Runnable() {
                @Override
                public void run() {
                    e.this.z();
                }
            }), o.a.MAIN, this.a.r(), true);
        }
        super.b(this.B);
    }

    @Override
    public void b() {
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Skipping video from prompt");
        }
        c();
    }

    public void c() {
        this.N = SystemClock.elapsedRealtime() - this.O;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Skipping video with skip time: " + this.N + "ms");
        }
        this.d.f();
        this.j++;
        if (this.a.x()) {
            h();
        } else {
            x();
        }
    }

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

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

    @Override
    public void c(boolean z) {
        super.c(z);
        if (z) {
            a(((Boolean) this.b.a(com.applovin.impl.sdk.c.b.eN)).booleanValue() ? 0L : 250L);
        } else if (this.E) {
        } else {
            e();
        }
    }

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

    protected void d(boolean z) {
        if (com.applovin.impl.sdk.utils.g.d()) {
            AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) this.e.getDrawable(z ? R.drawable.unmute_to_mute : R.drawable.mute_to_unmute);
            if (animatedVectorDrawable != null) {
                this.x.setScaleType(ImageView.ScaleType.FIT_XY);
                this.x.setImageDrawable(animatedVectorDrawable);
                animatedVectorDrawable.start();
                return;
            }
        }
        Uri aA = z ? this.a.aA() : this.a.aB();
        StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
        this.x.setImageURI(aA);
        StrictMode.setThreadPolicy(allowThreadDiskReads);
    }

    @Override
    public void e() {
        w wVar;
        String str;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Pausing video");
        }
        if (this.u.isPlaying()) {
            this.K = this.u.getCurrentPosition();
            this.u.setPlayWhenReady(false);
            this.A.c();
            if (!w.a()) {
                return;
            }
            wVar = this.c;
            str = "Paused video at position " + this.K + "ms";
        } else if (!w.a()) {
            return;
        } else {
            wVar = this.c;
            str = "Nothing to pause";
        }
        wVar.b("AppLovinFullscreenActivity", str);
    }

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

    @Override
    public void h() {
        this.A.b();
        this.I.removeCallbacksAndMessages(null);
        l();
        super.h();
    }

    @Override
    public void j() {
        this.u.release();
        if (this.J) {
            AppLovinCommunicator.getInstance(this.e).unsubscribe(this, "video_caching_failed");
        }
        super.j();
    }

    @Override
    protected void l() {
        super.a(C(), this.J, q(), this.N);
    }

    @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.eO)).booleanValue() && j == this.a.getAdIdNumber() && this.J) {
                int i = messageData.getInt("load_response_code");
                String string = messageData.getString("load_exception_message");
                if ((string == null && i >= 200 && i < 300) || this.F || this.u.isPlaying()) {
                    return;
                }
                c("Video cache error during stream. ResponseCode=" + i + ", exception=" + string);
            }
        }
    }

    @Override
    public boolean q() {
        return this.a != null && C() >= this.a.N();
    }

    @Override
    protected boolean r() {
        return s() && !q();
    }

    @Override
    protected void t() {
        long j;
        int l;
        if (this.a.aa() >= 0 || this.a.ab() >= 0) {
            int i = (this.a.aa() > 0L ? 1 : (this.a.aa() == 0L ? 0 : -1));
            com.applovin.impl.sdk.ad.e eVar = this.a;
            if (i >= 0) {
                j = eVar.aa();
            } else {
                com.applovin.impl.sdk.ad.a aVar = (com.applovin.impl.sdk.ad.a) eVar;
                long j2 = this.C;
                long j3 = j2 > 0 ? 0 + j2 : 0L;
                if (aVar.ac() && ((l = (int) ((com.applovin.impl.sdk.ad.a) this.a).l()) > 0 || (l = (int) aVar.s()) > 0)) {
                    j3 += TimeUnit.SECONDS.toMillis(l);
                }
                double d = j3;
                double ab = this.a.ab();
                Double.isNaN(ab);
                Double.isNaN(d);
                j = (long) (d * (ab / 100.0d));
            }
            b(j);
        }
    }

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

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

    public void w() {
        boolean z = !this.B ? 1 : 0;
        this.B = z;
        this.u.setVolume(!z ? 1 : 0);
        d(this.B);
        a(this.B, 0L);
    }

    public void x() {
        A();
        this.G.a(this.g, this.f);
        a("javascript:al_onPoststitialShow(" + this.j + "," + this.k + ");", this.a.P());
        if (this.g != null) {
            int i = (this.a.s() > 0L ? 1 : (this.a.s() == 0L ? 0 : -1));
            m mVar = this.g;
            if (i >= 0) {
                a(mVar, this.a.s(), new Runnable() {
                    @Override
                    public void run() {
                        e.this.i = SystemClock.elapsedRealtime();
                    }
                });
            } else {
                mVar.setVisibility(0);
            }
        }
        this.E = true;
    }

    protected void y() {
        a(!this.J);
        ProgressiveMediaSource createMediaSource = new ProgressiveMediaSource.Factory(new DefaultDataSourceFactory(this.e, Util.getUserAgent(this.e, "com.applovin.sdk"))).createMediaSource(MediaItem.fromUri(this.a.h()));
        this.u.setVolume(!this.B ? 1 : 0);
        this.u.setMediaSource(createMediaSource);
        this.u.prepare();
        this.u.setPlayWhenReady(false);
    }

    protected void z() {
        if (this.M.compareAndSet(false, true)) {
            a(this.w, this.a.q(), new Runnable() {
                @Override
                public void run() {
                    e.this.N = -1L;
                    e.this.O = SystemClock.elapsedRealtime();
                }
            });
        }
    }
}