GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5

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


package com.applovin.impl.adview;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
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.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import com.applovin.impl.adview.AppLovinTouchToClickListener;
import com.applovin.impl.adview.k;
import com.applovin.impl.adview.w;
import com.applovin.impl.sdk.AppLovinBroadcastManager;
import com.applovin.impl.sdk.a.g;
import com.applovin.impl.sdk.b.b;
import com.applovin.impl.sdk.e.o;
import com.applovin.impl.sdk.f;
import com.applovin.impl.sdk.utils.AppKilledService;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.sdk.utils.Utils;
import com.applovin.sdk.AppLovinAd;
import com.applovin.sdk.AppLovinAdClickListener;
import com.applovin.sdk.AppLovinAdDisplayListener;
import com.applovin.sdk.AppLovinAdSize;
import com.applovin.sdk.AppLovinAdType;
import com.applovin.sdk.AppLovinSdkUtils;
import com.applovin.sdk.R;
import com.mopub.mobileads.resource.DrawableConstants;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class p extends Activity implements l, f.a {
    public static volatile q lastKnownWrapper;
    private FrameLayout C;
    private j D;
    private View E;
    private j F;
    private View G;
    private h H;
    private ImageView I;
    private com.applovin.impl.sdk.b.b K;
    private v L;
    private ProgressBar M;
    private w.a N;
    private a O;
    private com.applovin.impl.sdk.utils.m P;
    private com.applovin.impl.sdk.utils.a Q;
    private AppLovinBroadcastManager.Receiver R;

    private o f487a;
    private q b;
    private com.applovin.impl.sdk.d.d c;
    protected k countdownManager;
    public volatile com.applovin.impl.sdk.a.g currentAd;
    public com.applovin.impl.sdk.r logger;
    public com.applovin.impl.sdk.k sdk;
    public AppLovinVideoView videoView;
    private boolean z;
    private volatile boolean d = false;
    private volatile boolean e = false;
    private volatile boolean f = false;
    private volatile boolean g = false;
    private volatile boolean h = false;
    private volatile boolean i = false;
    private volatile boolean j = false;
    protected volatile boolean postitialWasDisplayed = false;
    private boolean k = false;
    protected volatile boolean videoMuted = false;
    private volatile boolean l = false;
    private boolean m = true;
    private boolean n = false;
    protected int computedLengthSeconds = 0;
    private long o = 0;
    private long p = 0;
    private long q = 0;
    private long r = 0;
    private long s = -2;
    private int t = 0;
    private int u = Integer.MIN_VALUE;
    private AtomicBoolean v = new AtomicBoolean(false);
    private AtomicBoolean w = new AtomicBoolean(false);
    private AtomicBoolean x = new AtomicBoolean(false);
    private int y = com.applovin.impl.sdk.f.f841a;
    private final Handler A = new Handler(Looper.getMainLooper());
    private final Handler B = new Handler(Looper.getMainLooper());
    private WeakReference<MediaPlayer> J = new WeakReference<>(null);

    public class AnonymousClass27 implements MediaPlayer.OnPreparedListener {
        AnonymousClass27() {
        }

        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            p.this.J = new WeakReference(mediaPlayer);
            float f = !p.this.i() ? 1 : 0;
            mediaPlayer.setVolume(f, f);
            int videoWidth = mediaPlayer.getVideoWidth();
            int videoHeight = mediaPlayer.getVideoHeight();
            p.this.computedLengthSeconds = (int) TimeUnit.MILLISECONDS.toSeconds(mediaPlayer.getDuration());
            p.this.videoView.setVideoSize(videoWidth, videoHeight);
            SurfaceHolder holder = p.this.videoView.getHolder();
            if (holder.getSurface() != null) {
                mediaPlayer.setDisplay(holder);
            }
            mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public boolean onError(MediaPlayer mediaPlayer2, final int i, final int i2) {
                    p.this.B.post(new Runnable() {
                        @Override
                        public void run() {
                            p.this.handleMediaError("Media player error (" + i + "," + i2 + ")");
                        }
                    });
                    return true;
                }
            });
            mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                @Override
                public boolean onInfo(MediaPlayer mediaPlayer2, int i, int i2) {
                    if (i != 3) {
                        if (i == 701) {
                            p.this.y();
                            if (p.this.c == null) {
                                return false;
                            }
                            p.this.c.g();
                            return false;
                        }
                        if (i != 702) {
                            return false;
                        }
                    }
                    p.this.z();
                    return false;
                }
            });
            if (p.this.p == 0) {
                p.this.q();
                p.this.k();
                p.this.v();
                p.this.u();
                p.this.playVideo();
                p.this.I();
            }
        }
    }

    public void A() {
        if (!C()) {
            skipVideo();
            return;
        }
        M();
        pauseReportRewardTask();
        this.logger.b("InterActivity", "Prompting incentivized ad close warning");
        this.K.b();
    }

    public void B() {
        d s;
        if (this.currentAd.U() && (s = this.f487a.getAdViewController().s()) != null) {
            s.a("javascript:al_onCloseButtonTapped();");
        }
        if (!D()) {
            dismiss();
        } else {
            this.logger.b("InterActivity", "Prompting incentivized non-video ad close warning");
            this.K.c();
        }
    }

    private boolean C() {
        return G() && !isFullyWatched() && ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.bq)).booleanValue() && this.K != null;
    }

    private boolean D() {
        return H() && !F() && ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.bv)).booleanValue() && this.K != null;
    }

    private int E() {
        if (!(this.currentAd instanceof com.applovin.impl.sdk.a.a)) {
            return 0;
        }
        float l = ((com.applovin.impl.sdk.a.a) this.currentAd).l();
        if (l <= 0.0f) {
            l = (float) this.currentAd.u();
        }
        double millisToSeconds = Utils.millisToSeconds(System.currentTimeMillis() - this.o);
        double d = l;
        Double.isNaN(d);
        return (int) Math.min((millisToSeconds / d) * 100.0d, 100.0d);
    }

    private boolean F() {
        return E() >= this.currentAd.P();
    }

    private boolean G() {
        return AppLovinAdType.INCENTIVIZED.equals(this.currentAd.getType());
    }

    private boolean H() {
        return !this.currentAd.hasVideoUrl() && G();
    }

    public void I() {
        int l;
        long j;
        if (this.currentAd != null) {
            if ((this.currentAd.ac() >= 0 || this.currentAd.ad() >= 0) && this.P == null) {
                if (this.currentAd.ac() >= 0) {
                    j = this.currentAd.ac();
                } else if (isVastAd()) {
                    com.applovin.impl.a.a aVar = (com.applovin.impl.a.a) this.currentAd;
                    com.applovin.impl.a.j l2 = aVar.l();
                    if (l2 == null || l2.b() <= 0) {
                        int duration = this.videoView.getDuration();
                        if (duration > 0) {
                            r2 = 0 + duration;
                        }
                    } else {
                        r2 = 0 + TimeUnit.SECONDS.toMillis(l2.b());
                    }
                    if (aVar.ae()) {
                        l = (int) aVar.u();
                    }
                    double d = r2;
                    double ad = this.currentAd.ad();
                    Double.isNaN(ad);
                    Double.isNaN(d);
                    j = (long) (d * (ad / 100.0d));
                } else {
                    if (this.currentAd instanceof com.applovin.impl.sdk.a.a) {
                        com.applovin.impl.sdk.a.a aVar2 = (com.applovin.impl.sdk.a.a) this.currentAd;
                        int duration2 = this.videoView.getDuration();
                        r2 = duration2 > 0 ? 0 + duration2 : 0L;
                        if (aVar2.ae()) {
                            l = (int) aVar2.l();
                            if (l <= 0) {
                                l = (int) aVar2.u();
                            }
                            r2 += TimeUnit.SECONDS.toMillis(l);
                        }
                    }
                    double d2 = r2;
                    double ad2 = this.currentAd.ad();
                    Double.isNaN(ad2);
                    Double.isNaN(d2);
                    j = (long) (d2 * (ad2 / 100.0d));
                }
                this.logger.b("InterActivity", "Scheduling report reward in " + TimeUnit.MILLISECONDS.toSeconds(j) + " seconds...");
                this.P = com.applovin.impl.sdk.utils.m.a(j, this.sdk, new Runnable() {
                    @Override
                    public void run() {
                        if (p.this.currentAd == null || p.this.currentAd.af().getAndSet(true)) {
                            return;
                        }
                        p.this.sdk.Q().a(new com.applovin.impl.sdk.e.u(p.this.currentAd, p.this.sdk), o.a.REWARD);
                    }
                });
            }
        }
    }

    private void J() {
        View view;
        com.applovin.impl.sdk.r rVar;
        StringBuilder sb;
        String str;
        o oVar = this.f487a;
        if (oVar == null) {
            exitWithError("AdView was null");
            return;
        }
        oVar.setAdDisplayListener(new AppLovinAdDisplayListener() {
            @Override
            public void adDisplayed(AppLovinAd appLovinAd) {
                if (p.this.e) {
                    return;
                }
                p.this.a(appLovinAd);
            }

            @Override
            public void adHidden(AppLovinAd appLovinAd) {
                p.this.b(appLovinAd);
            }
        });
        this.f487a.setAdClickListener(new AppLovinAdClickListener() {
            @Override
            public void adClicked(AppLovinAd appLovinAd) {
                com.applovin.impl.sdk.utils.i.a(p.this.b.e(), appLovinAd);
            }
        });
        this.currentAd = this.b.b();
        if (this.w.compareAndSet(false, true)) {
            this.sdk.t().trackImpression(this.currentAd);
            this.currentAd.setHasShown(true);
        }
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
        FrameLayout frameLayout = new FrameLayout(this);
        this.C = frameLayout;
        frameLayout.setLayoutParams(layoutParams);
        this.C.setBackgroundColor(DrawableConstants.CtaButton.BACKGROUND_COLOR);
        this.countdownManager = new k(this.A, this.sdk);
        j();
        if (this.currentAd.isVideoAd()) {
            this.l = this.currentAd.f();
            if (this.l) {
                rVar = this.logger;
                sb = new StringBuilder();
                str = "Preparing stream for ";
            } else {
                rVar = this.logger;
                sb = new StringBuilder();
                str = "Preparing cached video playback for ";
            }
            sb.append(str);
            sb.append(this.currentAd.h());
            rVar.b("InterActivity", sb.toString());
            com.applovin.impl.sdk.d.d dVar = this.c;
            if (dVar != null) {
                dVar.b(this.l ? 1L : 0L);
            }
        }
        this.videoMuted = i();
        Uri h = this.currentAd.h();
        a(h);
        if (h == null) {
            I();
        }
        this.D.bringToFront();
        if (n() && (view = this.E) != null) {
            view.bringToFront();
        }
        j jVar = this.F;
        if (jVar != null) {
            jVar.bringToFront();
        }
        if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue()) {
            this.C.addView(this.f487a);
            this.f487a.setVisibility(4);
        }
        this.f487a.renderAd(this.currentAd);
        if (this.currentAd.hasVideoUrl()) {
            return;
        }
        if (H()) {
            d(this.currentAd);
        }
        showPostitial();
    }

    private void K() {
        if (this.videoView != null) {
            boolean z = false;
            try {
                z = this.currentAd.aM();
            } catch (Throwable unused) {
            }
            this.t = getVideoPercentViewed();
            if (z) {
                this.videoView.pause();
            } else {
                this.videoView.stopPlayback();
            }
        }
    }

    private boolean L() {
        return this.videoMuted;
    }

    private void M() {
        AppLovinVideoView appLovinVideoView = this.videoView;
        this.sdk.a((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Integer>>) com.applovin.impl.sdk.c.d.u, (com.applovin.impl.sdk.c.d<Integer>) Integer.valueOf(appLovinVideoView != null ? appLovinVideoView.getCurrentPosition() : 0));
        this.sdk.a((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Boolean>>) com.applovin.impl.sdk.c.d.v, (com.applovin.impl.sdk.c.d<Boolean>) true);
        try {
            this.countdownManager.c();
        } catch (Throwable th) {
            this.logger.b("InterActivity", "Unable to pause countdown timers", th);
        }
        AppLovinVideoView appLovinVideoView2 = this.videoView;
        if (appLovinVideoView2 != null) {
            appLovinVideoView2.pause();
        }
    }

    private void N() {
        long max = Math.max(0L, ((Long) this.sdk.a(com.applovin.impl.sdk.c.b.cF)).longValue());
        if (max <= 0) {
            this.sdk.z().b("InterActivity", "Resuming video immediately");
            O();
            return;
        }
        this.sdk.z().b("InterActivity", "Resuming video with delay of " + max);
        this.B.postDelayed(new Runnable() {
            @Override
            public void run() {
                p.this.O();
            }
        }, max);
    }

    public void O() {
        AppLovinVideoView appLovinVideoView;
        if (this.postitialWasDisplayed || (appLovinVideoView = this.videoView) == null || appLovinVideoView.isPlaying()) {
            return;
        }
        this.videoView.seekTo(((Integer) this.sdk.b((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Integer>>) com.applovin.impl.sdk.c.d.u, (com.applovin.impl.sdk.c.d<Integer>) Integer.valueOf(this.videoView.getDuration()))).intValue());
        this.videoView.start();
        this.countdownManager.a();
    }

    private void P() {
        if (this.h) {
            return;
        }
        boolean z = true;
        this.h = true;
        try {
            int videoPercentViewed = getVideoPercentViewed();
            if (this.currentAd.hasVideoUrl()) {
                a(this.currentAd, videoPercentViewed, isFullyWatched());
                if (this.c != null) {
                    this.c.c(videoPercentViewed);
                }
            } else if ((this.currentAd instanceof com.applovin.impl.sdk.a.a) && H()) {
                int E = E();
                this.logger.b("InterActivity", "Rewarded playable engaged at " + E + " percent");
                com.applovin.impl.sdk.a.g gVar = this.currentAd;
                double d = (double) E;
                if (E < this.currentAd.P()) {
                    z = false;
                }
                a(gVar, d, z);
            }
            this.sdk.t().trackVideoEnd(this.currentAd, TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - this.o), videoPercentViewed, this.l);
            this.sdk.t().trackFullScreenAdClosed(this.currentAd, SystemClock.elapsedRealtime() - this.q, this.s, this.z, this.y);
        } catch (Throwable th) {
            com.applovin.impl.sdk.r rVar = this.logger;
            if (rVar != null) {
                rVar.b("InterActivity", "Failed to notify end listener.", th);
            }
        }
    }

    private int a(int i) {
        return AppLovinSdkUtils.dpToPx(this, i);
    }

    private int a(int i, boolean z) {
        if (z) {
            if (i == 0) {
                return 0;
            }
            if (i == 1) {
                return 9;
            }
            if (i == 2) {
                return 8;
            }
            return i == 3 ? 1 : -1;
        }
        if (i == 0) {
            return 1;
        }
        if (i == 1) {
            return 0;
        }
        if (i == 2) {
            return 9;
        }
        return i == 3 ? 8 : -1;
    }

    private void a(long j, final j jVar) {
        this.B.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (jVar.equals(p.this.D)) {
                    p.this.m();
                } else if (jVar.equals(p.this.F)) {
                    p.this.o();
                }
            }
        }, j);
    }

    public void a(PointF pointF) {
        if (!this.currentAd.D() || this.currentAd.k() == null) {
            e();
            f();
        } else {
            this.sdk.z().b("InterActivity", "Clicking through video...");
            clickThroughFromVideo(pointF);
        }
    }

    private void a(Uri uri) {
        AppLovinVideoView appLovinVideoView = new AppLovinVideoView(this, this.sdk);
        this.videoView = appLovinVideoView;
        if (uri != null) {
            appLovinVideoView.setOnPreparedListener(new AnonymousClass27());
            this.videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mediaPlayer) {
                    p.this.h();
                }
            });
            this.videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public boolean onError(MediaPlayer mediaPlayer, final int i, final int i2) {
                    p.this.B.post(new Runnable() {
                        @Override
                        public void run() {
                            p.this.handleMediaError("Video view error (" + i + "," + i2 + ")");
                        }
                    });
                    return true;
                }
            });
            StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
            this.videoView.setVideoURI(uri);
            StrictMode.setThreadPolicy(allowThreadDiskReads);
        }
        this.videoView.setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
        this.videoView.setOnTouchListener(new AppLovinTouchToClickListener(this.sdk, this, new AppLovinTouchToClickListener.OnClickListener() {
            @Override
            public void onClick(View view, PointF pointF) {
                p.this.a(pointF);
            }
        }));
        this.C.addView(this.videoView);
        setContentView(this.C);
        p();
        x();
    }

    public void a(final View view, final boolean z, long j) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(z ? 0.0f : 1.0f, z ? 1.0f : 0.0f);
        alphaAnimation.setDuration(j);
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                if (z) {
                    return;
                }
                view.setVisibility(4);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
                view.setVisibility(0);
            }
        });
        view.startAnimation(alphaAnimation);
    }

    public void a(AppLovinAd appLovinAd) {
        com.applovin.impl.sdk.utils.i.a(this.b.d(), appLovinAd);
        this.e = true;
        this.sdk.ac().a(appLovinAd);
        this.sdk.ak().a(appLovinAd);
        AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
            @Override
            public void run() {
                p pVar = p.this;
                pVar.b(pVar.videoMuted);
            }
        }, ((Long) this.sdk.a(com.applovin.impl.sdk.c.b.cJ)).longValue());
    }

    private void a(AppLovinAd appLovinAd, double d, boolean z) {
        com.applovin.impl.sdk.utils.i.a(this.b.c(), appLovinAd, d, z);
    }

    private void a(final String str) {
        q qVar = this.b;
        if (qVar != null) {
            final AppLovinAdDisplayListener d = qVar.d();
            if ((d instanceof com.applovin.impl.sdk.a.i) && this.x.compareAndSet(false, true)) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((com.applovin.impl.sdk.a.i) d).onAdDisplayFailed(str);
                    }
                });
            }
        }
    }

    private void a(final String str, long j) {
        if (j >= 0) {
            this.B.postDelayed(new Runnable() {
                @Override
                public void run() {
                    d s = p.this.f487a.getAdViewController().s();
                    if (s == null || !StringUtils.isValidString(str)) {
                        return;
                    }
                    s.a(str);
                }
            }, j);
        }
    }

    private void a(boolean z) {
        if (!com.applovin.impl.sdk.utils.f.d()) {
            Uri aE = z ? this.currentAd.aE() : this.currentAd.aF();
            StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
            this.I.setImageURI(aE);
            StrictMode.setThreadPolicy(allowThreadDiskReads);
            return;
        }
        AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) getDrawable(z ? R.drawable.unmute_to_mute : R.drawable.mute_to_unmute);
        if (animatedVectorDrawable != null) {
            this.I.setScaleType(ImageView.ScaleType.FIT_XY);
            this.I.setImageDrawable(animatedVectorDrawable);
            animatedVectorDrawable.start();
        }
    }

    private boolean a() {
        int identifier = getResources().getIdentifier((String) this.sdk.a(com.applovin.impl.sdk.c.b.cq), "bool", "android");
        return identifier > 0 && getResources().getBoolean(identifier);
    }

    public void b() {
        getWindow().getDecorView().setSystemUiVisibility(5894);
    }

    private void b(int i) {
        try {
            setRequestedOrientation(i);
        } catch (Throwable th) {
            this.sdk.z().b("InterActivity", "Failed to set requested orientation", th);
        }
    }

    private void b(int i, boolean z) {
        int i2;
        boolean booleanValue = ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.co)).booleanValue();
        int i3 = 1;
        if (this.b.f() == g.b.ACTIVITY_PORTRAIT) {
            i2 = 9;
            if (z) {
                if (i == 1 || i == 3) {
                    if (!booleanValue) {
                        return;
                    }
                }
            } else if (i == 0 || i == 2) {
                if (!booleanValue) {
                    return;
                }
                if (i != 0) {
                    i3 = 9;
                }
            }
            b(i3);
            return;
        }
        if (this.b.f() == g.b.ACTIVITY_LANDSCAPE) {
            i2 = 8;
            if (z) {
                if (i == 0 || i == 2) {
                    if (!booleanValue) {
                        return;
                    }
                }
                b(0);
                return;
            }
            if (i == 1 || i == 3) {
                if (!booleanValue) {
                    return;
                }
            }
            b(0);
            return;
        }
        return;
        b(i2);
    }

    public void b(AppLovinAd appLovinAd) {
        dismiss();
        c(appLovinAd);
    }

    private void b(String str) {
        com.applovin.impl.sdk.a.g gVar = this.currentAd;
        if (gVar == null || !gVar.V()) {
            return;
        }
        a(str, 0L);
    }

    public void b(boolean z) {
        d s;
        if (!this.currentAd.T() || (s = this.f487a.getAdViewController().s()) == null) {
            return;
        }
        try {
            s.a(z ? "javascript:al_mute();" : "javascript:al_unmute();");
        } catch (Throwable th) {
            this.logger.b("InterActivity", "Unable to forward mute setting to template.", th);
        }
    }

    private void c(AppLovinAd appLovinAd) {
        if (this.f) {
            return;
        }
        this.f = true;
        q qVar = this.b;
        if (qVar != null) {
            com.applovin.impl.sdk.utils.i.b(qVar.d(), appLovinAd);
        }
        this.sdk.ac().b(appLovinAd);
        this.sdk.ak().a();
    }

    private void c(boolean z) {
        this.videoMuted = z;
        MediaPlayer mediaPlayer = this.J.get();
        if (mediaPlayer != null) {
            float f = z ? 0 : 1;
            try {
                mediaPlayer.setVolume(f, f);
            } catch (IllegalStateException e) {
                this.logger.b("InterActivity", "Failed to set MediaPlayer muted: " + z, e);
            }
        }
    }

    private boolean c() {
        com.applovin.impl.sdk.k kVar;
        if (this.b == null || (kVar = this.sdk) == null || ((Boolean) kVar.a(com.applovin.impl.sdk.c.b.cj)).booleanValue()) {
            return true;
        }
        if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.ck)).booleanValue() && this.i) {
            return true;
        }
        return ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cl)).booleanValue() && this.postitialWasDisplayed;
    }

    private void d() {
        int i;
        if (this.sdk == null || !isFinishing()) {
            if (this.currentAd != null && (i = this.u) != Integer.MIN_VALUE) {
                b(i);
            }
            finish();
        }
    }

    private void d(AppLovinAd appLovinAd) {
        if (this.g) {
            return;
        }
        this.g = true;
        com.applovin.impl.sdk.utils.i.a(this.b.c(), appLovinAd);
    }

    private void e() {
        h hVar;
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cr)).booleanValue() || (hVar = this.H) == null || hVar.getVisibility() == 8) {
            return;
        }
        a(this.H, this.H.getVisibility() == 4, 750L);
    }

    private void f() {
        v vVar;
        u C = this.currentAd.C();
        if (C == null || !C.e() || this.postitialWasDisplayed || (vVar = this.L) == null) {
            return;
        }
        a(this.L, vVar.getVisibility() == 4, C.f());
    }

    private void g() {
        com.applovin.impl.sdk.k kVar = this.sdk;
        if (kVar != null) {
            kVar.a((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Boolean>>) com.applovin.impl.sdk.c.d.v, (com.applovin.impl.sdk.c.d<Boolean>) false);
            this.sdk.a((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Integer>>) com.applovin.impl.sdk.c.d.u, (com.applovin.impl.sdk.c.d<Integer>) 0);
        }
    }

    public void h() {
        this.d = true;
        showPostitial();
    }

    public boolean i() {
        return ((Integer) this.sdk.b((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Integer>>) com.applovin.impl.sdk.c.d.u, (com.applovin.impl.sdk.c.d<Integer>) 0)).intValue() > 0 ? this.videoMuted : ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cx)).booleanValue() ? this.sdk.p().isMuted() : ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cv)).booleanValue();
    }

    private void j() {
        j a2 = j.a(this.currentAd.v(), this);
        this.D = a2;
        a2.setVisibility(8);
        this.D.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                p.this.B();
            }
        });
        int a3 = a(this.currentAd.X());
        int i = (this.currentAd.aa() ? 3 : 5) | 48;
        int i2 = (this.currentAd.ab() ? 3 : 5) | 48;
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(a3, a3, i | 48);
        this.D.a(a3);
        int a4 = a(this.currentAd.Y());
        int a5 = a(this.currentAd.Z());
        layoutParams.setMargins(a5, a4, a5, a4);
        this.C.addView(this.D, layoutParams);
        j a6 = j.a(this.currentAd.w(), this);
        this.F = a6;
        a6.setVisibility(8);
        this.F.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                p.this.A();
            }
        });
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(a3, a3, i2);
        layoutParams2.setMargins(a5, a4, a5, a4);
        this.F.a(a3);
        this.C.addView(this.F, layoutParams2);
        this.F.bringToFront();
        if (n()) {
            int a7 = a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.bB)).intValue());
            View view = new View(this);
            this.E = view;
            view.setBackgroundColor(0);
            this.E.setVisibility(8);
            View view2 = new View(this);
            this.G = view2;
            view2.setBackgroundColor(0);
            this.G.setVisibility(8);
            int i3 = a3 + a7;
            int a8 = a4 - a(5);
            FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(i3, i3, i);
            layoutParams3.setMargins(a8, a8, a8, a8);
            FrameLayout.LayoutParams layoutParams4 = new FrameLayout.LayoutParams(i3, i3, i2);
            layoutParams4.setMargins(a8, a8, a8, a8);
            this.E.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view3) {
                    p.this.D.performClick();
                }
            });
            this.G.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view3) {
                    p.this.F.performClick();
                }
            });
            this.C.addView(this.E, layoutParams3);
            this.E.bringToFront();
            this.C.addView(this.G, layoutParams4);
            this.G.bringToFront();
        }
    }

    public void k() {
        if (this.I == null) {
            try {
                this.videoMuted = i();
                this.I = new ImageView(this);
                if (l()) {
                    this.sdk.z().b("InterActivity", "Mute button should be hidden");
                    return;
                }
                int a2 = a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cy)).intValue());
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(a2, a2, ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cA)).intValue());
                this.I.setScaleType(ImageView.ScaleType.FIT_CENTER);
                int a3 = a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cz)).intValue());
                layoutParams.setMargins(a3, a3, a3, a3);
                if ((this.videoMuted ? this.currentAd.aE() : this.currentAd.aF()) == null) {
                    this.sdk.z().e("InterActivity", "Attempting to add mute button but could not find uri");
                    return;
                }
                this.sdk.z().b("InterActivity", "Added mute button with params: " + layoutParams);
                a(this.videoMuted);
                this.I.setClickable(true);
                this.I.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        p.this.toggleMute();
                    }
                });
                this.C.addView(this.I, layoutParams);
                this.I.bringToFront();
            } catch (Exception e) {
                this.sdk.z().a("InterActivity", "Failed to attach mute button", e);
            }
        }
    }

    private boolean l() {
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.ct)).booleanValue()) {
            return true;
        }
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cu)).booleanValue() || i()) {
            return false;
        }
        return !((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cw)).booleanValue();
    }

    public void m() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    if (p.this.i) {
                        p.this.D.setVisibility(0);
                        return;
                    }
                    p.this.q = SystemClock.elapsedRealtime();
                    p.this.i = true;
                    if (p.this.n() && p.this.E != null) {
                        p.this.E.setVisibility(0);
                        p.this.E.bringToFront();
                    }
                    p.this.D.setVisibility(0);
                    p.this.D.bringToFront();
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
                    alphaAnimation.setDuration(400L);
                    alphaAnimation.setRepeatCount(0);
                    p.this.D.startAnimation(alphaAnimation);
                } catch (Throwable unused) {
                    p.this.dismiss();
                }
            }
        });
    }

    public boolean n() {
        return ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.bB)).intValue() > 0;
    }

    public void o() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    if (p.this.j || p.this.F == null) {
                        return;
                    }
                    p.this.s = -1L;
                    p.this.r = SystemClock.elapsedRealtime();
                    p.this.j = true;
                    p.this.F.setVisibility(0);
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
                    alphaAnimation.setDuration(400L);
                    alphaAnimation.setRepeatCount(0);
                    p.this.F.startAnimation(alphaAnimation);
                    if (!p.this.n() || p.this.G == null) {
                        return;
                    }
                    p.this.G.setVisibility(0);
                    p.this.G.bringToFront();
                } catch (Throwable th) {
                    p.this.logger.d("InterActivity", "Unable to show skip button: " + th);
                }
            }
        });
    }

    private void p() {
        j jVar;
        if (this.currentAd.s() >= 0) {
            if (!this.k || (jVar = this.F) == null) {
                jVar = this.D;
            }
            a(Utils.secondsToMillisLong((float) this.currentAd.s()), jVar);
        }
    }

    public void q() {
        boolean z = ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.ci)).booleanValue() && t() > 0;
        if (this.H == null && z) {
            this.H = new h(this);
            int G = this.currentAd.G();
            this.H.setTextColor(G);
            this.H.setTextSize(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.ch)).intValue());
            this.H.setFinishedStrokeColor(G);
            this.H.setFinishedStrokeWidth(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cg)).intValue());
            this.H.setMax(t());
            this.H.setProgress(t());
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cf)).intValue()), a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cf)).intValue()), ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.ce)).intValue());
            int a2 = a(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cd)).intValue());
            layoutParams.setMargins(a2, a2, a2, a2);
            this.C.addView(this.H, layoutParams);
            this.H.bringToFront();
            this.H.setVisibility(0);
            final long s = s();
            this.countdownManager.a("COUNTDOWN_CLOCK", 1000L, new k.a() {
                @Override
                public void a() {
                    if (p.this.H != null) {
                        long seconds = TimeUnit.MILLISECONDS.toSeconds(s - p.this.videoView.getCurrentPosition());
                        if (seconds <= 0) {
                            p.this.H.setVisibility(8);
                            p.this.n = true;
                        } else if (p.this.r()) {
                            p.this.H.setProgress((int) seconds);
                        }
                    }
                }

                @Override
                public boolean b() {
                    return p.this.r();
                }
            });
        }
    }

    public boolean r() {
        return (this.n || this.postitialWasDisplayed || !this.videoView.isPlaying()) ? false : true;
    }

    private long s() {
        return TimeUnit.SECONDS.toMillis(t());
    }

    private int t() {
        int F = this.currentAd.F();
        return (F <= 0 && ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cI)).booleanValue()) ? this.computedLengthSeconds + 1 : F;
    }

    public void u() {
        if (this.M == null && this.currentAd.N()) {
            this.logger.c("InterActivity", "Attaching video progress bar...");
            ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
            this.M = progressBar;
            progressBar.setMax(((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cD)).intValue());
            this.M.setPadding(0, 0, 0, 0);
            if (com.applovin.impl.sdk.utils.f.d()) {
                try {
                    this.M.setProgressTintList(ColorStateList.valueOf(this.currentAd.O()));
                } catch (Throwable th) {
                    this.logger.b("InterActivity", "Unable to update progress bar color.", th);
                }
            }
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.videoView.getWidth(), 20, 80);
            layoutParams.setMargins(0, 0, 0, ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cE)).intValue());
            this.C.addView(this.M, layoutParams);
            this.M.bringToFront();
            this.countdownManager.a("PROGRESS_BAR", ((Long) this.sdk.a(com.applovin.impl.sdk.c.b.cC)).longValue(), new k.a() {
                @Override
                public void a() {
                    if (p.this.M != null) {
                        if (!p.this.shouldContinueFullLengthVideoCountdown()) {
                            p.this.M.setVisibility(8);
                            return;
                        }
                        p.this.M.setProgress((int) ((p.this.videoView.getCurrentPosition() / p.this.videoView.getDuration()) * ((Integer) p.this.sdk.a(com.applovin.impl.sdk.c.b.cD)).intValue()));
                    }
                }

                @Override
                public boolean b() {
                    return p.this.shouldContinueFullLengthVideoCountdown();
                }
            });
        }
    }

    public void v() {
        final u C = this.currentAd.C();
        if (StringUtils.isValidString(this.currentAd.B()) && C != null && this.L == null) {
            this.logger.c("InterActivity", "Attaching video button...");
            this.L = w();
            double a2 = C.a();
            Double.isNaN(a2);
            double b = C.b();
            Double.isNaN(b);
            int width = this.videoView.getWidth();
            int height = this.videoView.getHeight();
            double d = width;
            Double.isNaN(d);
            double d2 = height;
            Double.isNaN(d2);
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) ((a2 / 100.0d) * d), (int) ((b / 100.0d) * d2), C.d());
            int a3 = a(C.c());
            layoutParams.setMargins(a3, a3, a3, a3);
            this.C.addView(this.L, layoutParams);
            this.L.bringToFront();
            if (C.i() > 0.0f) {
                this.L.setVisibility(4);
                this.B.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        long g = C.g();
                        p pVar = p.this;
                        pVar.a((View) pVar.L, true, g);
                        p.this.L.bringToFront();
                    }
                }, Utils.secondsToMillisLong(C.i()));
            }
            if (C.j() > 0.0f) {
                this.B.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        long h = C.h();
                        p pVar = p.this;
                        pVar.a((View) pVar.L, false, h);
                    }
                }, Utils.secondsToMillisLong(C.j()));
            }
        }
    }

    private v w() {
        this.logger.b("InterActivity", "Create video button with HTML = " + this.currentAd.B());
        w wVar = new w(this.sdk);
        this.N = new w.a() {
            @Override
            public void a(v vVar) {
                p.this.logger.b("InterActivity", "Clicking through from video button...");
                p.this.clickThroughFromVideo(vVar.getAndClearLastClickLocation());
            }

            @Override
            public void b(v vVar) {
                p.this.logger.b("InterActivity", "Closing ad from video button...");
                p.this.dismiss();
            }

            @Override
            public void c(v vVar) {
                p.this.logger.b("InterActivity", "Skipping video from video button...");
                p.this.skipVideo();
            }
        };
        wVar.a(new WeakReference<>(this.N));
        v vVar = new v(wVar, getApplicationContext());
        vVar.a(this.currentAd.B());
        return vVar;
    }

    private void x() {
        if (this.l) {
            a aVar = new a(this, ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.cH)).intValue(), android.R.attr.progressBarStyleLarge);
            this.O = aVar;
            aVar.setColor(Color.parseColor("#75FFFFFF"));
            this.O.setBackgroundColor(Color.parseColor("#00000000"));
            this.O.setVisibility(8);
            this.C.addView(this.O, new FrameLayout.LayoutParams(-1, -1, 17));
            this.C.bringChildToFront(this.O);
        }
    }

    public void y() {
        a aVar = this.O;
        if (aVar != null) {
            aVar.a();
        }
    }

    public void z() {
        a aVar = this.O;
        if (aVar != null) {
            aVar.b();
        }
    }

    public void clickThroughFromVideo(PointF pointF) {
        try {
            this.sdk.t().trackAndLaunchVideoClick(this.currentAd, this.f487a, this.currentAd.k(), pointF);
            com.applovin.impl.sdk.utils.i.a(this.b.e(), this.currentAd);
            if (this.c != null) {
                this.c.b();
            }
        } catch (Throwable th) {
            this.sdk.z().b("InterActivity", "Encountered error while clicking through video.", th);
        }
    }

    public void continueVideo() {
        O();
    }

    @Override
    public void dismiss() {
        com.applovin.impl.sdk.r.f("InterActivity", "Dismissing ad after " + (System.currentTimeMillis() - this.o) + " milliseconds elapsed");
        com.applovin.impl.sdk.k kVar = this.sdk;
        if (kVar != null) {
            if (((Boolean) kVar.a(com.applovin.impl.sdk.c.b.cs)).booleanValue()) {
                stopService(new Intent(getBaseContext(), (Class<?>) AppKilledService.class));
                this.sdk.ai().unregisterReceiver(this.R);
            }
            this.sdk.ah().b(this);
        }
        g();
        P();
        if (this.b != null) {
            if (this.currentAd != null) {
                c(this.currentAd);
                com.applovin.impl.sdk.d.d dVar = this.c;
                if (dVar != null) {
                    dVar.c();
                    this.c = null;
                }
                a("javascript:al_onPoststitialDismiss();", this.currentAd.S());
            }
            this.b.g();
        }
        lastKnownWrapper = null;
        d();
    }

    public void exitWithError(String str) {
        a(str);
        try {
            com.applovin.impl.sdk.r.c("InterActivity", "Failed to properly render an Interstitial Activity, due to error: " + str, new Throwable("Initialized = " + q.b + "; CleanedUp = " + q.c));
            c(new com.applovin.impl.sdk.a.h(this.currentAd != null ? this.currentAd.getAdZone() : com.applovin.impl.sdk.a.d.a(str), this.sdk));
        } catch (Exception e) {
            com.applovin.impl.sdk.r.c("InterActivity", "Failed to show a video ad due to error:", e);
        }
        dismiss();
    }

    public boolean getPostitialWasDisplayed() {
        return this.postitialWasDisplayed;
    }

    public int getVideoPercentViewed() {
        if (this.d) {
            return 100;
        }
        AppLovinVideoView appLovinVideoView = this.videoView;
        if (appLovinVideoView == null) {
            this.logger.e("InterActivity", "No video view detected on video end");
            return 0;
        }
        int duration = appLovinVideoView.getDuration();
        if (duration <= 0) {
            return this.t;
        }
        double currentPosition = this.videoView.getCurrentPosition();
        double d = duration;
        Double.isNaN(currentPosition);
        Double.isNaN(d);
        return (int) ((currentPosition / d) * 100.0d);
    }

    public void handleMediaError(String str) {
        this.logger.e("InterActivity", str);
        if (this.v.compareAndSet(false, true)) {
            a(str);
            dismiss();
        }
    }

    public boolean isFullyWatched() {
        return getVideoPercentViewed() >= this.currentAd.P();
    }

    public boolean isVastAd() {
        return this.currentAd instanceof com.applovin.impl.a.a;
    }

    @Override
    public void onBackPressed() {
        j jVar;
        if (this.currentAd != null) {
            if (this.currentAd.aC() && !this.postitialWasDisplayed) {
                return;
            }
            if (this.currentAd.aD() && this.postitialWasDisplayed) {
                return;
            }
        }
        if (c()) {
            this.logger.b("InterActivity", "Back button was pressed; forwarding to Android for handling...");
        } else {
            try {
                if (!this.postitialWasDisplayed && this.k && this.F != null && this.F.getVisibility() == 0 && this.F.getAlpha() > 0.0f) {
                    this.logger.b("InterActivity", "Back button was pressed; forwarding as a click to skip button.");
                    jVar = this.F;
                } else if (this.D == null || this.D.getVisibility() != 0 || this.D.getAlpha() <= 0.0f) {
                    this.logger.b("InterActivity", "Back button was pressed, but was not eligible for dismissal.");
                    b("javascript:al_onBackPressed();");
                    return;
                } else {
                    this.logger.b("InterActivity", "Back button was pressed; forwarding as a click to close button.");
                    jVar = this.D;
                }
                jVar.performClick();
                b("javascript:al_onBackPressed();");
                return;
            } catch (Exception unused) {
            }
        }
        super.onBackPressed();
    }

    @Override
    public void onCreate(Bundle bundle) {
        com.applovin.impl.sdk.d.d dVar;
        String stringExtra;
        String str;
        ActivityManager activityManager;
        super.onCreate(bundle);
        if (bundle != null) {
            this.w.set(bundle.getBoolean("instance_impression_tracked"));
        }
        requestWindowFeature(1);
        StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
        try {
            stringExtra = getIntent().getStringExtra("com.applovin.interstitial.wrapper_id");
        } catch (Throwable th) {
            try {
                if (this.logger != null) {
                    this.logger.b("InterActivity", "Encountered error during onCreate.", th);
                }
                exitWithError("An error was encountered during interstitial ad creation.");
            } finally {
                StrictMode.setThreadPolicy(allowThreadDiskReads);
            }
        }
        if (stringExtra == null || stringExtra.isEmpty()) {
            str = "Wrapper ID is null";
        } else {
            q a2 = q.a(stringExtra);
            this.b = a2;
            if (a2 == null && lastKnownWrapper != null) {
                this.b = lastKnownWrapper;
            }
            if (this.b != null) {
                final com.applovin.impl.sdk.a.g b = this.b.b();
                this.sdk = this.b.a();
                this.logger = this.b.a().z();
                if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cs)).booleanValue()) {
                    this.R = new AppLovinBroadcastManager.Receiver() {
                        @Override
                        public void onReceive(Context context, Intent intent, Map<String, Object> map) {
                            p.this.sdk.t().trackAppKilled(b);
                            p.this.sdk.ai().unregisterReceiver(this);
                        }
                    };
                    this.sdk.ai().registerReceiver(this.R, new IntentFilter(AppKilledService.ACTION_APP_KILLED));
                }
                if (b != null) {
                    int intValue = ((Integer) this.sdk.a(com.applovin.impl.sdk.c.b.eO)).intValue();
                    if (intValue != -1 && (activityManager = (ActivityManager) getSystemService("activity")) != null) {
                        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                        activityManager.getMemoryInfo(memoryInfo);
                        if (memoryInfo.availMem < intValue) {
                            exitWithError("Not enough available memory");
                            return;
                        }
                    }
                    this.c = new com.applovin.impl.sdk.d.d(b, this.sdk);
                    if (b.ak()) {
                        this.sdk.ah().a(this);
                    }
                    View findViewById = findViewById(android.R.id.content);
                    if (findViewById != null) {
                        if (b.hasVideoUrl()) {
                            findViewById.setBackgroundColor(DrawableConstants.CtaButton.BACKGROUND_COLOR);
                        } else {
                            findViewById.setBackgroundColor(b.H());
                        }
                    }
                    this.o = System.currentTimeMillis();
                    getWindow().setFlags(16777216, 16777216);
                    int rotation = Utils.getRotation(this);
                    boolean isTablet = AppLovinSdkUtils.isTablet(this);
                    int a3 = a(rotation, isTablet);
                    if (bundle == null) {
                        this.u = a3;
                    } else {
                        this.u = bundle.getInt("original_orientation", a3);
                    }
                    if (!b.E()) {
                        this.logger.b("InterActivity", "Locking activity orientation to targeted orientation...");
                    } else {
                        if (a3 != -1) {
                            this.logger.b("InterActivity", "Locking activity orientation to current orientation: " + a3);
                            b(a3);
                            o oVar = new o(this.sdk.W(), AppLovinAdSize.INTERSTITIAL, this);
                            this.f487a = oVar;
                            oVar.getAdViewController().a(this.c);
                            this.b.a((l) this);
                            this.k = ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cG)).booleanValue();
                            com.applovin.impl.sdk.b.b bVar = new com.applovin.impl.sdk.b.b(this, this.sdk);
                            this.K = bVar;
                            bVar.a(new b.a() {
                                @Override
                                public void a() {
                                    p.this.continueVideo();
                                    p.this.resumeReportRewardTask();
                                }

                                @Override
                                public void b() {
                                    p.this.skipVideo();
                                    p.this.resumeReportRewardTask();
                                }
                            });
                            this.Q = new com.applovin.impl.sdk.utils.a() {
                                @Override
                                public void onActivityCreated(Activity activity, Bundle bundle2) {
                                    if (p.this.sdk == null || !((Boolean) p.this.sdk.a(com.applovin.impl.sdk.c.b.eD)).booleanValue() || p.this.f) {
                                        return;
                                    }
                                    if (activity.getClass().getName().equals(Utils.retrieveLauncherActivityFullyQualifiedName(p.this.getApplicationContext()))) {
                                        p.this.sdk.Q().a(new com.applovin.impl.sdk.e.y(p.this.sdk, new Runnable() {
                                            @Override
                                            public void run() {
                                                com.applovin.impl.sdk.r.i("AppLovinInterstitialActivity", "Dismissing on-screen ad due to app relaunched via launcher.");
                                                p.this.dismiss();
                                            }
                                        }), o.a.MAIN);
                                    }
                                }
                            };
                            this.sdk.ad().a(this.Q);
                            StrictMode.setThreadPolicy(allowThreadDiskReads);
                            g();
                            dVar = this.c;
                            if (dVar != null) {
                                dVar.a();
                            }
                            J();
                        }
                        this.logger.e("InterActivity", "Unable to detect current orientation. Locking to targeted orientation...");
                    }
                    b(rotation, isTablet);
                    o oVar2 = new o(this.sdk.W(), AppLovinAdSize.INTERSTITIAL, this);
                    this.f487a = oVar2;
                    oVar2.getAdViewController().a(this.c);
                    this.b.a((l) this);
                    this.k = ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cG)).booleanValue();
                    com.applovin.impl.sdk.b.b bVar2 = new com.applovin.impl.sdk.b.b(this, this.sdk);
                    this.K = bVar2;
                    bVar2.a(new b.a() {
                        @Override
                        public void a() {
                            p.this.continueVideo();
                            p.this.resumeReportRewardTask();
                        }

                        @Override
                        public void b() {
                            p.this.skipVideo();
                            p.this.resumeReportRewardTask();
                        }
                    });
                    this.Q = new com.applovin.impl.sdk.utils.a() {
                        @Override
                        public void onActivityCreated(Activity activity, Bundle bundle2) {
                            if (p.this.sdk == null || !((Boolean) p.this.sdk.a(com.applovin.impl.sdk.c.b.eD)).booleanValue() || p.this.f) {
                                return;
                            }
                            if (activity.getClass().getName().equals(Utils.retrieveLauncherActivityFullyQualifiedName(p.this.getApplicationContext()))) {
                                p.this.sdk.Q().a(new com.applovin.impl.sdk.e.y(p.this.sdk, new Runnable() {
                                    @Override
                                    public void run() {
                                        com.applovin.impl.sdk.r.i("AppLovinInterstitialActivity", "Dismissing on-screen ad due to app relaunched via launcher.");
                                        p.this.dismiss();
                                    }
                                }), o.a.MAIN);
                            }
                        }
                    };
                    this.sdk.ad().a(this.Q);
                    StrictMode.setThreadPolicy(allowThreadDiskReads);
                    g();
                    dVar = this.c;
                    if (dVar != null) {
                    }
                    J();
                }
                str = "No current ad found.";
            } else {
                str = "Wrapper is null; initialized state: " + q.b;
            }
        }
        exitWithError(str);
        StrictMode.setThreadPolicy(allowThreadDiskReads);
        g();
        dVar = this.c;
        if (dVar != null) {
        }
        J();
    }

    @Override
    protected void onDestroy() {
        try {
            if (this.f487a != null) {
                ViewParent parent = this.f487a.getParent();
                if (parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(this.f487a);
                }
                this.f487a.destroy();
                this.f487a = null;
            }
            if (this.videoView != null) {
                this.videoView.pause();
                this.videoView.stopPlayback();
            }
            if (this.sdk != null) {
                MediaPlayer mediaPlayer = this.J.get();
                if (mediaPlayer != null) {
                    mediaPlayer.release();
                }
                this.sdk.ad().b(this.Q);
            }
            if (this.countdownManager != null) {
                this.countdownManager.b();
            }
            if (this.B != null) {
                this.B.removeCallbacksAndMessages(null);
            }
            if (this.A != null) {
                this.A.removeCallbacksAndMessages(null);
            }
        } catch (Throwable th) {
            try {
                if (this.logger != null) {
                    this.logger.a("InterActivity", "Unable to destroy video view", th);
                }
            } catch (Throwable th2) {
                if (this.currentAd != null) {
                    P();
                    c(this.currentAd);
                }
                throw th2;
            }
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        this.logger.b("InterActivity", "App paused...");
        this.p = System.currentTimeMillis();
        if (this.postitialWasDisplayed) {
            M();
        }
        this.K.a();
        pauseReportRewardTask();
        b("javascript:al_onAppPaused();");
    }

    @Override
    public void onResume() {
        j jVar;
        try {
            super.onResume();
            this.logger.b("InterActivity", "App resumed...");
            if (!this.m) {
                com.applovin.impl.sdk.d.d dVar = this.c;
                if (dVar != null) {
                    dVar.d(System.currentTimeMillis() - this.p);
                }
                boolean z = false;
                if (!((Boolean) this.sdk.b((com.applovin.impl.sdk.c.d<com.applovin.impl.sdk.c.d<Boolean>>) com.applovin.impl.sdk.c.d.v, (com.applovin.impl.sdk.c.d<Boolean>) false)).booleanValue() || this.K.d() || this.postitialWasDisplayed) {
                    if ((this.currentAd instanceof com.applovin.impl.sdk.a.a) && ((com.applovin.impl.sdk.a.a) this.currentAd).m()) {
                        z = true;
                    }
                    if (this.currentAd != null) {
                        if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cc)).booleanValue()) {
                            if (this.postitialWasDisplayed) {
                                jVar = this.D;
                                if (jVar != null) {
                                }
                            }
                        }
                    }
                    resumeReportRewardTask();
                } else {
                    N();
                    y();
                    if (this.currentAd != null) {
                        if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cc)).booleanValue()) {
                            if (!this.postitialWasDisplayed) {
                                if (this.k) {
                                    jVar = this.F;
                                }
                            }
                        }
                    }
                    resumeReportRewardTask();
                }
            } else if (!this.K.d() && !this.postitialWasDisplayed && this.currentAd != null) {
                y();
            }
            b("javascript:al_onAppResumed();");
        } catch (IllegalArgumentException unused) {
            exitWithError("Error was encountered in onResume().");
        }
    }

    @Override
    public void onRingerModeChanged(int i) {
        String str;
        if (this.y != com.applovin.impl.sdk.f.f841a) {
            this.z = true;
        }
        d s = this.f487a.getAdViewController().s();
        if (s != null) {
            if (!com.applovin.impl.sdk.f.a(i) || com.applovin.impl.sdk.f.a(this.y)) {
                str = i == 2 ? "javascript:al_muteSwitchOff();" : "javascript:al_muteSwitchOn();";
            }
            s.a(str);
        }
        this.y = i;
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putBoolean("instance_impression_tracked", this.w.get());
        bundle.putInt("original_orientation", this.u);
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        String str;
        super.onWindowFocusChanged(z);
        com.applovin.impl.sdk.k kVar = this.sdk;
        if (z) {
            if (kVar != null) {
                this.logger.b("InterActivity", "Window gained focus");
                try {
                    if (com.applovin.impl.sdk.utils.f.c() && ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.cB)).booleanValue() && a()) {
                        b();
                        this.B.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                p.this.b();
                            }
                        }, 2500L);
                    } else {
                        getWindow().setFlags(1024, 1024);
                    }
                    if (!this.postitialWasDisplayed) {
                        N();
                        resumeReportRewardTask();
                    }
                } catch (Throwable th) {
                    this.logger.b("InterActivity", "Setting window flags failed.", th);
                }
                this.m = false;
                b("javascript:al_onWindowFocusChanged( " + z + " );");
            }
            str = "Window gained focus. SDK is null.";
        } else {
            if (kVar != null) {
                this.logger.b("InterActivity", "Window lost focus");
                if (!this.postitialWasDisplayed) {
                    M();
                    pauseReportRewardTask();
                }
                this.m = false;
                b("javascript:al_onWindowFocusChanged( " + z + " );");
            }
            str = "Window lost focus. SDK is null.";
        }
        com.applovin.impl.sdk.r.f("InterActivity", str);
        this.m = false;
        b("javascript:al_onWindowFocusChanged( " + z + " );");
    }

    public void pauseReportRewardTask() {
        com.applovin.impl.sdk.utils.m mVar = this.P;
        if (mVar != null) {
            mVar.b();
        }
    }

    public void playVideo() {
        d(this.currentAd);
        this.videoView.start();
        this.countdownManager.a();
    }

    public void resumeReportRewardTask() {
        com.applovin.impl.sdk.utils.m mVar = this.P;
        if (mVar != null) {
            mVar.c();
        }
    }

    public boolean shouldContinueFullLengthVideoCountdown() {
        return (this.d || this.postitialWasDisplayed) ? false : true;
    }

    public void showPostitial() {
        try {
            K();
            if (this.f487a != null) {
                ViewParent parent = this.f487a.getParent();
                if ((parent instanceof ViewGroup) && (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue() || parent != this.C)) {
                    ((ViewGroup) parent).removeView(this.f487a);
                }
                FrameLayout frameLayout = ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue() ? this.C : new FrameLayout(this);
                frameLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
                frameLayout.setBackgroundColor(this.currentAd.H());
                if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue()) {
                    this.f487a.setVisibility(0);
                } else {
                    frameLayout.addView(this.f487a);
                }
                if (this.C != null) {
                    if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue()) {
                        com.applovin.impl.sdk.utils.b.a(this.C, this.f487a);
                    } else {
                        this.C.removeAllViewsInLayout();
                    }
                }
                if (n() && this.E != null) {
                    if (this.E.getParent() instanceof ViewGroup) {
                        ((ViewGroup) this.E.getParent()).removeView(this.E);
                    }
                    frameLayout.addView(this.E);
                    this.E.bringToFront();
                }
                if (this.D != null) {
                    ViewParent parent2 = this.D.getParent();
                    if (parent2 instanceof ViewGroup) {
                        ((ViewGroup) parent2).removeView(this.D);
                    }
                    frameLayout.addView(this.D);
                    this.D.bringToFront();
                }
                if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eF)).booleanValue()) {
                    setContentView(frameLayout);
                }
                if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.eC)).booleanValue()) {
                    this.f487a.setVisibility(4);
                    this.f487a.setVisibility(0);
                }
                a("javascript:al_onPoststitialShow();", this.currentAd.R());
            }
            if ((this.currentAd instanceof com.applovin.impl.sdk.a.a) && ((com.applovin.impl.sdk.a.a) this.currentAd).m()) {
                this.logger.b("InterActivity", "Skip showing of close button");
            } else if (this.currentAd.u() >= 0) {
                a(Utils.secondsToMillisLong((float) this.currentAd.u()), this.D);
            } else if (this.currentAd.u() == -2) {
                this.D.setVisibility(0);
            } else {
                a(0L, this.D);
            }
            this.postitialWasDisplayed = true;
        } catch (Throwable th) {
            this.logger.b("InterActivity", "Encountered error while showing postitial. Dismissing...", th);
            dismiss();
        }
    }

    public void skipVideo() {
        this.s = SystemClock.elapsedRealtime() - this.r;
        com.applovin.impl.sdk.d.d dVar = this.c;
        if (dVar != null) {
            dVar.f();
        }
        if (this.currentAd.x()) {
            dismiss();
        } else {
            showPostitial();
        }
    }

    public void toggleMute() {
        boolean z = !L();
        try {
            c(z);
            a(z);
            b(z);
        } catch (Throwable th) {
            this.logger.b("InterActivity", "Unable to set volume to " + z, th);
        }
    }
}