Driving Zone: Germany v1.22.4版本的 MD5 值为:2b6e2d8e8733a3104dcc306c5770286c

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


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

import android.R;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.media.MediaPlayer;
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.util.Log;
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.AppLovinVideoView;
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.f.o;
import com.applovin.impl.sdk.f.z;
import com.applovin.impl.sdk.n;
import com.applovin.impl.sdk.utils.AppLovinSdkExtraParameterKey;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.sdk.utils.Utils;
import com.applovin.impl.sdk.utils.h;
import com.applovin.impl.sdk.utils.k;
import com.applovin.impl.sdk.utils.r;
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 java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

public class f extends com.applovin.impl.adview.activity.b.a implements AppLovinCommunicatorSubscriber {
    protected ImageView A;
    protected final j B;
    protected boolean C;
    protected long D;
    protected boolean E;
    private final com.applovin.impl.adview.activity.a.c F;
    private MediaPlayer G;
    private final b H;
    private final a I;
    private final Handler J;
    private final boolean K;
    private int L;
    private int M;
    private boolean N;
    private final AtomicBoolean O;
    private final AtomicBoolean P;
    private long Q;
    private long R;
    protected final AppLovinVideoView 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) {
            w wVar = f.this.c;
            if (w.a()) {
                f.this.c.b("AppLovinFullscreenActivity", "Clicking through from video button...");
            }
            f.this.a(tVar.getAndClearLastClickLocation());
        }

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

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

    private class b implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, AppLovinTouchToClickListener.OnClickListener {
        private b() {
        }

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

        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            w wVar = f.this.c;
            if (w.a()) {
                f.this.c.b("AppLovinFullscreenActivity", "Video completed");
            }
            f.this.N = true;
            if (!f.this.k) {
                f.this.A();
            } else if (f.this.t()) {
                f.this.F();
            }
        }

        @Override
        public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
            f.this.c("Video view error (" + i + "," + i2 + ")");
            f.this.u.start();
            return true;
        }

        @Override
        public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
            w wVar = f.this.c;
            if (w.a()) {
                f.this.c.b("AppLovinFullscreenActivity", "MediaPlayer Info: (" + i + ", " + i2 + ")");
            }
            if (i == 701) {
                f.this.x();
                f.this.d.g();
                return false;
            }
            if (i != 3) {
                if (i != 702) {
                    return false;
                }
                f.this.y();
                return false;
            }
            f.this.B.a();
            if (f.this.w != null) {
                f.this.C();
            }
            f.this.y();
            if (!f.this.s.c()) {
                return false;
            }
            f.this.e();
            return false;
        }

        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            f.this.G = mediaPlayer;
            mediaPlayer.setOnInfoListener(f.this.H);
            mediaPlayer.setOnErrorListener(f.this.H);
            float f = !f.this.C ? 1 : 0;
            mediaPlayer.setVolume(f, f);
            f.this.c(mediaPlayer.getDuration());
            f.this.u();
            w wVar = f.this.c;
            if (w.a()) {
                f.this.c.b("AppLovinFullscreenActivity", "MediaPlayer prepared: " + f.this.G);
            }
        }
    }

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

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

    public f(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.F = new com.applovin.impl.adview.activity.a.c(this.f1288a, this.e, this.b);
        this.A = null;
        this.H = new b();
        this.I = new a();
        Handler handler = new Handler(Looper.getMainLooper());
        this.J = handler;
        this.B = new j(handler, this.b);
        this.K = this.f1288a.f();
        this.C = Utils.isVideoMutedInitially(this.b);
        this.M = -1;
        this.O = new AtomicBoolean();
        this.P = new AtomicBoolean();
        this.Q = -2L;
        this.R = 0L;
        if (!eVar.hasVideoUrl()) {
            throw new IllegalStateException("Attempting to use fullscreen video ad presenter for non-video ad");
        }
        AppLovinVideoView appLovinVideoView = new AppLovinVideoView(activity);
        this.u = appLovinVideoView;
        appLovinVideoView.setOnPreparedListener(this.H);
        this.u.setOnCompletionListener(this.H);
        this.u.setOnErrorListener(this.H);
        this.u.setOnTouchListener(new AppLovinTouchToClickListener(nVar, com.applovin.impl.sdk.d.b.aS, activity, this.H));
        c cVar = new c();
        if (eVar.r() >= 0) {
            m mVar = new m(eVar.x(), activity);
            this.w = mVar;
            mVar.setVisibility(8);
            this.w.setOnClickListener(cVar);
        } else {
            this.w = null;
        }
        if (a(this.C, nVar)) {
            ImageView imageView = new ImageView(activity);
            this.x = imageView;
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            this.x.setClickable(true);
            this.x.setOnClickListener(cVar);
            e(this.C);
        } else {
            this.x = null;
        }
        String C = eVar.C();
        if (StringUtils.isValidString(C)) {
            u uVar = new u(nVar);
            uVar.a(new WeakReference<>(this.I));
            t tVar = new t(uVar, activity);
            this.y = tVar;
            tVar.a(C);
        } else {
            this.y = null;
        }
        if (this.K) {
            com.applovin.impl.adview.a aVar = new com.applovin.impl.adview.a(activity, ((Integer) nVar.a(com.applovin.impl.sdk.d.b.cG)).intValue(), R.attr.progressBarStyleLarge);
            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.O()) {
            this.z = null;
            return;
        }
        ProgressBar progressBar = new ProgressBar(activity, null, R.attr.progressBarStyleHorizontal);
        this.z = progressBar;
        progressBar.setMax(10000);
        this.z.setPadding(0, 0, 0, 0);
        if (h.d()) {
            this.z.setProgressTintList(ColorStateList.valueOf(eVar.P()));
        }
        this.B.a("PROGRESS_BAR", ((Long) nVar.a(com.applovin.impl.sdk.d.b.cD)).longValue(), new j.a() {
            @Override
            public void a() {
                if (f.this.E) {
                    f.this.z.setVisibility(8);
                } else {
                    f.this.z.setProgress((int) ((f.this.u.getCurrentPosition() / ((float) f.this.D)) * 10000.0f));
                }
            }

            @Override
            public boolean b() {
                return !f.this.E;
            }
        });
    }

    public void C() {
        if (this.P.compareAndSet(false, true)) {
            a(this.w, this.f1288a.r(), new Runnable() {
                @Override
                public void run() {
                    f.this.Q = -1L;
                    f.this.R = SystemClock.elapsedRealtime();
                }
            });
        }
    }

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

    public void E() {
        if (this.E) {
            w wVar = this.c;
            if (w.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - postitial shown");
                return;
            }
            return;
        }
        if (this.b.ae().isApplicationPaused()) {
            w wVar2 = this.c;
            if (w.a()) {
                this.c.d("AppLovinFullscreenActivity", "Skip video resume - app paused");
                return;
            }
            return;
        }
        if (this.M < 0) {
            w wVar3 = this.c;
            if (w.a()) {
                this.c.b("AppLovinFullscreenActivity", "Invalid last video position");
                return;
            }
            return;
        }
        w wVar4 = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Resuming video at position " + this.M + "ms for MediaPlayer: " + this.G);
        }
        this.u.seekTo(this.M);
        this.u.start();
        this.B.a();
        this.M = -1;
        a(new Runnable() {
            @Override
            public void run() {
                if (f.this.v != null) {
                    f.this.v.a();
                    f.this.a(new Runnable() {
                        @Override
                        public void run() {
                            f.this.v.b();
                        }
                    }, 2000L);
                }
            }
        }, 250L);
    }

    public void F() {
        this.F.a(this.h);
        this.j = SystemClock.elapsedRealtime();
    }

    private static boolean a(boolean z, n nVar) {
        if (!((Boolean) nVar.a(com.applovin.impl.sdk.d.b.cv)).booleanValue()) {
            return false;
        }
        if (!((Boolean) nVar.a(com.applovin.impl.sdk.d.b.cw)).booleanValue() || z) {
            return true;
        }
        return ((Boolean) nVar.a(com.applovin.impl.sdk.d.b.cy)).booleanValue();
    }

    private void d(boolean z) {
        this.L = B();
        if (z) {
            this.u.pause();
        } else {
            this.u.stopPlayback();
        }
    }

    private void e(boolean z) {
        if (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.x.setScaleType(ImageView.ScaleType.FIT_XY);
                this.x.setImageDrawable(animatedVectorDrawable);
                animatedVectorDrawable.start();
                return;
            }
        }
        Uri aC = z ? this.f1288a.aC() : this.f1288a.aD();
        StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
        this.x.setImageURI(aC);
        StrictMode.setThreadPolicy(allowThreadDiskReads);
    }

    public void A() {
        w wVar = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Showing postitial...");
        }
        d(this.f1288a.aJ());
        this.F.a(this.g, this.f);
        a("javascript:al_onPoststitialShow(" + this.l + "," + this.m + ");", this.f1288a.S());
        if (this.g != null) {
            long t = this.f1288a.t();
            m mVar = this.g;
            if (t >= 0) {
                a(mVar, this.f1288a.t(), new Runnable() {
                    @Override
                    public void run() {
                        f.this.j = SystemClock.elapsedRealtime();
                    }
                });
            } else {
                mVar.setVisibility(0);
            }
        }
        v();
        this.E = true;
    }

    public int B() {
        long currentPosition = this.u.getCurrentPosition();
        if (this.N) {
            return 100;
        }
        return currentPosition > 0 ? (int) ((((float) currentPosition) / ((float) this.D)) * 100.0f) : this.L;
    }

    @Override
    public void a() {
        w wVar = this.c;
        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() {
                f.this.E();
            }
        }, j);
    }

    public void a(PointF pointF) {
        if (!this.f1288a.E()) {
            D();
            return;
        }
        w wVar = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Clicking through video");
        }
        Uri k = this.f1288a.k();
        if (k != null) {
            this.b.u().trackAndLaunchVideoClick(this.f1288a, k, pointF, this, this.f != null ? this.f.getContext() : this.b.N());
            k.a(this.p, this.f1288a);
            this.d.b();
            this.m++;
        }
    }

    @Override
    public void a(ViewGroup viewGroup) {
        String str;
        this.F.a(this.x, this.w, this.y, this.v, this.z, this.u, this.f, this.A, viewGroup);
        if (h.g() && (str = this.b.p().getExtraParameters().get(AppLovinSdkExtraParameterKey.AUDIO_FOCUS_REQUEST)) != null) {
            this.u.setAudioFocusRequest(Integer.parseInt(str));
        }
        StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
        a(!this.K);
        this.u.setVideoURI(this.f1288a.h());
        StrictMode.setThreadPolicy(allowThreadDiskReads);
        if (this.f1288a.am()) {
            this.s.a(this.f1288a, new Runnable() {
                @Override
                public void run() {
                    f.this.a(250L);
                }
            });
        }
        this.u.start();
        if (this.K) {
            x();
        }
        this.f.renderAd(this.f1288a);
        this.d.b(this.K ? 1L : 0L);
        if (this.w != null) {
            this.b.T().a(new z(this.b, new Runnable() {
                @Override
                public void run() {
                    f.this.C();
                }
            }), o.a.MAIN, this.f1288a.s(), true);
        }
        super.b(this.C);
    }

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

    public void c() {
        this.Q = SystemClock.elapsedRealtime() - this.R;
        w wVar = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Skipping video with skip time: " + this.Q + "ms");
        }
        this.d.f();
        this.l++;
        if (this.f1288a.y()) {
            h();
        } else {
            A();
        }
    }

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

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

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

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

    @Override
    public void e() {
        w wVar = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Pausing video");
        }
        this.M = this.u.getCurrentPosition();
        this.u.pause();
        this.B.c();
        w wVar2 = this.c;
        if (w.a()) {
            this.c.b("AppLovinFullscreenActivity", "Paused video at position " + this.M + "ms");
        }
    }

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

    @Override
    public void h() {
        this.B.b();
        this.J.removeCallbacksAndMessages(null);
        m();
        super.h();
    }

    @Override
    public void k() {
        w wVar = this.c;
        if (w.a()) {
            this.c.c("AppLovinFullscreenActivity", "Destroying video components");
        }
        try {
            if (this.K) {
                AppLovinCommunicator.getInstance(this.e).unsubscribe(this, "video_caching_failed");
            }
            if (this.u != null) {
                this.u.pause();
                this.u.stopPlayback();
            }
            if (this.G != null) {
                this.G.release();
            }
        } catch (Throwable th) {
            Log.e("AppLovinFullscreenActivity", "Unable to destroy presenter", th);
        }
        super.k();
    }

    @Override
    protected void m() {
        super.a(B(), this.K, r(), this.Q);
    }

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

    @Override
    public boolean r() {
        return B() >= this.f1288a.Q();
    }

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

    @Override
    protected void u() {
        long ae;
        int l;
        if (this.f1288a.ad() >= 0 || this.f1288a.ae() >= 0) {
            long ad = this.f1288a.ad();
            com.applovin.impl.sdk.ad.e eVar = this.f1288a;
            if (ad >= 0) {
                ae = eVar.ad();
            } else {
                com.applovin.impl.sdk.ad.a aVar = (com.applovin.impl.sdk.ad.a) eVar;
                long j = this.D;
                long j2 = j > 0 ? 0 + j : 0L;
                if (aVar.af() && ((l = (int) ((com.applovin.impl.sdk.ad.a) this.f1288a).l()) > 0 || (l = (int) aVar.t()) > 0)) {
                    j2 += TimeUnit.SECONDS.toMillis(l);
                }
                ae = (long) (j2 * (this.f1288a.ae() / 100.0d));
            }
            b(ae);
        }
    }

    @Override
    public void w() {
        super.w();
        this.F.a(this.y);
        this.F.a((View) this.w);
        if (!t() || this.E) {
            F();
        }
    }

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

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

    public void z() {
        if (this.G == null) {
            return;
        }
        try {
            float f = !this.C ? 0 : 1;
            this.G.setVolume(f, f);
            boolean z = this.C ? false : true;
            this.C = z;
            e(z);
            a(this.C, 0L);
        } catch (Throwable unused) {
        }
    }
}