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

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


package com.appnext.ads.interstitial;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Base64;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import androidx.palette.graphics.Palette;
import com.appnext.R;
import com.appnext.ads.AdsError;
import com.appnext.core.Ad;
import com.appnext.core.AppnextActivity;
import com.appnext.core.AppnextAd;
import com.appnext.core.AppnextError;
import com.appnext.core.SettingsManager;
import com.appnext.core.callbacks.OnAdClicked;
import com.appnext.core.callbacks.OnAdClosed;
import com.appnext.core.callbacks.OnAdError;
import com.appnext.core.callbacks.OnAdOpened;
import com.appnext.core.f;
import com.appnext.core.g;
import com.appnext.core.i;
import com.appnext.core.n;
import com.appnext.core.p;
import com.appnext.core.result.ResultPageActivity;
import com.appnext.core.result.d;
import com.appnext.core.webview.AppnextWebView;
import com.appnext.core.webview.WebAppInterface;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class InterstitialActivity extends AppnextActivity {
    private ArrayList<AppnextAd> ads;
    protected WebView am;
    private Interstitial ao;
    private InterstitialAd ap;
    private Handler at;
    private f.a au;
    private Boolean autoPlay;
    private WebAppInterface av;
    private String ay;
    private Boolean canClose;
    private AppnextAd j;
    private Boolean mute;
    private boolean an = false;
    private String aq = "";
    private boolean ar = false;
    private int as = 0;
    private boolean aw = false;
    private boolean ax = false;
    private String az = "";
    private boolean aA = false;
    private Runnable aB = new Runnable() {
        @Override
        public final void run() {
            InterstitialActivity.this.pageFinished();
        }
    };

    @Override
    public void onCreate(Bundle bundle) {
        setRequestedOrientation(7);
        super.onCreate(bundle);
        try {
            if (Interstitial.currentAd == null) {
                finish();
                return;
            }
            this.ao = new Interstitial(Interstitial.currentAd);
            if (getRequestedOrientation() == 6) {
                a(this, "loaded_landscape");
            } else {
                a(this, "loaded_portrait");
            }
            this.cv = new RelativeLayout(this);
            setContentView(this.cv);
            this.cv.getLayoutParams().width = -1;
            this.cv.getLayoutParams().height = -1;
            this.cv.setBackgroundColor(-1);
            this.placementID = getIntent().getExtras().getString("id");
            if (getIntent().hasExtra("auto_play")) {
                Boolean valueOf = Boolean.valueOf(getIntent().getBooleanExtra("auto_play", true));
                this.autoPlay = valueOf;
                if (valueOf.booleanValue()) {
                    a(this, "auto_play_on");
                } else {
                    a(this, "auto_play_off");
                }
            }
            if (getIntent().hasExtra("can_close")) {
                this.canClose = Boolean.valueOf(getIntent().getBooleanExtra("can_close", false));
            }
            if (getIntent().hasExtra("mute")) {
                Boolean valueOf2 = Boolean.valueOf(getIntent().getBooleanExtra("mute", true));
                this.mute = valueOf2;
                if (valueOf2.booleanValue()) {
                    a(this, "mute_on");
                } else {
                    a(this, "mute_off");
                }
            }
            if (getIntent().hasExtra("pview")) {
                this.ct = getIntent().getStringExtra("pview");
                this.banner = getIntent().getStringExtra("banner");
                this.guid = getIntent().getStringExtra("guid");
            }
            if (getIntent().getSerializableExtra("ads") != null) {
                this.ads = (ArrayList) getIntent().getSerializableExtra("ads");
            }
            this.at = new Handler();
            AppnextWebView.q(this).a(this.ao.getPageUrl(), new AppnextWebView.c() {
                @Override
                public final void f(String str) {
                    InterstitialActivity.this.r();
                }

                @Override
                public final void error(String str) {
                    try {
                        InterstitialActivity.this.r();
                    } catch (Throwable unused) {
                    }
                }
            });
            this.au = new f.a() {
                @Override
                public final void onMarket(String str) {
                    try {
                        new StringBuilder("marketUrl ").append(str);
                        if (InterstitialActivity.this.handler != null) {
                            InterstitialActivity.this.handler.removeCallbacks(null);
                        }
                        InterstitialActivity.this.S();
                    } catch (Throwable unused) {
                    }
                }

                @Override
                public final void error(String str) {
                    try {
                        if (InterstitialActivity.this.handler != null) {
                            InterstitialActivity.this.handler.removeCallbacks(null);
                        }
                        InterstitialActivity.this.S();
                        String unused = InterstitialActivity.this.placementID;
                        StringBuilder sb = new StringBuilder();
                        sb.append(new InterstitialAd(InterstitialActivity.this.j).getAppURL());
                        sb.append(" ");
                        sb.append(str);
                    } catch (Throwable unused2) {
                    }
                }
            };
            this.userAction = new p(this, new p.a() {
                @Override
                public final void report(String str) {
                }

                @Override
                public final Ad c() {
                    return InterstitialActivity.this.ao;
                }

                @Override
                public final AppnextAd d() {
                    return InterstitialActivity.this.j;
                }

                @Override
                public final SettingsManager e() {
                    return InterstitialActivity.this.getConfig();
                }
            });
            n.aa().a(new Runnable() {
                @Override
                public final void run() {
                    try {
                        InterstitialActivity.this.az = g.b((Context) InterstitialActivity.this, true);
                    } catch (Throwable unused) {
                    }
                }
            });
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onCreate", th);
        }
    }

    public void r() {
        try {
            AppnextWebView q = AppnextWebView.q(this);
            this.am = q.C(this.ads != null ? "fullscreen" : "interstitial");
            WebView a2 = q.a(this, this.ao.getPlacementID(), this.ao.getAUID(), this.ao.getPageUrl(), s(), this.ao.getFallback(), this.ads != null ? "fullscreen" : "interstitial");
            this.am = a2;
            a2.setWebViewClient(new WebViewClient() {
                @Override
                public final boolean shouldOverrideUrlLoading(WebView webView, String str) {
                    if (str == null) {
                        return false;
                    }
                    if (str.startsWith("http")) {
                        webView.loadUrl(str);
                        return true;
                    }
                    return super.shouldOverrideUrlLoading(webView, str);
                }

                @Override
                public final void onPageFinished(WebView webView, String str) {
                    super.onPageFinished(webView, str);
                    InterstitialActivity.this.at.removeCallbacksAndMessages(null);
                    InterstitialActivity.this.pageFinished();
                }
            });
            this.am.setWebChromeClient(new WebChromeClient() {
                @Override
                public final boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                    new StringBuilder("console ").append(consoleMessage.message());
                    if (consoleMessage.message().contains("pause")) {
                        return true;
                    }
                    if (consoleMessage.message().contains("TypeError") || consoleMessage.message().contains("has no method") || consoleMessage.message().contains("is not a function")) {
                        InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
                        InterstitialActivity.this.finish();
                        return true;
                    }
                    return true;
                }
            });
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$initWebView", th);
            onError(AppnextError.INTERNAL_ERROR);
            finish();
        }
    }

    public void pageFinished() {
        try {
            if (this.at != null) {
                this.at.removeCallbacks(this.aB);
            }
            this.an = true;
            String string = getIntent().getExtras().getString("creative");
            this.aq = string;
            if (string == null || string.equals(Interstitial.TYPE_MANAGED)) {
                this.aq = d("creative");
            }
            n.aa().a(new Runnable() {
                @Override
                public final void run() {
                    InterstitialActivity.this.t();
                }
            });
            if (this.am == null) {
                onError(AppnextError.INTERNAL_ERROR);
                finish();
                return;
            }
            if (this.am.getParent() != null) {
                ((ViewGroup) this.am.getParent()).removeView(this.am);
            }
            this.cv.addView(this.am);
            this.am.getLayoutParams().width = -1;
            this.am.getLayoutParams().height = -1;
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$pageFinished", th);
        }
    }

    public void c(final String str) {
        n.aa().a(new Runnable() {
            @Override
            public final void run() {
                try {
                    if (TextUtils.isEmpty(InterstitialActivity.this.placementID) || TextUtils.isEmpty(str)) {
                        return;
                    }
                    com.appnext.core.adswatched.a.l(InterstitialActivity.this).j(str, InterstitialActivity.this.ao.getAUID());
                } catch (Throwable unused) {
                }
            }
        });
    }

    @Override
    protected final SettingsManager getConfig() {
        return c.E();
    }

    @Override
    protected void onResume() {
        super.onResume();
        try {
            if (this.aA) {
                a();
                finish();
                return;
            }
            if (this.an && this.autoPlay != null && this.autoPlay.booleanValue()) {
                loadJS("Appnext.Layout.Video.play();");
            }
            try {
                this.am.loadUrl("javascript:(function() { try{Appnext.countToClose();}catch(e){}})()");
            } catch (Throwable unused) {
            }
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onResume", th);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        try {
            if (this.ar || this.am == null) {
                return;
            }
            this.am.loadUrl("javascript:(function() { Appnext.Layout.Video.pause();})()");
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onPause", th);
        }
    }

    @Override
    public void onBackPressed() {
        try {
            if (this.canClose != null) {
                if (!this.canClose.booleanValue()) {
                    return;
                }
            } else if (!Boolean.parseBoolean(d("can_close"))) {
                return;
            }
            loadJS("Appnext.Layout.destroy('internal');");
            this.ar = true;
            a();
            finish();
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onBackPressed", th);
        }
    }

    @Override
    protected final void onError(final String str) {
        try {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    if (InterstitialActivity.this.ao != null) {
                        try {
                            OnAdError onAdErrorCallback = InterstitialActivity.this.ao.getOnAdErrorCallback();
                            if (onAdErrorCallback != null) {
                                onAdErrorCallback.adError(str);
                            }
                        } catch (Throwable unused) {
                        }
                    }
                }
            });
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onError", th);
        }
    }

    public void e(String str) {
        OnAdClicked onAdClickedCallback;
        try {
            com.appnext.ads.interstitial.a.C();
            AppnextAd appnextAd = (AppnextAd) com.appnext.ads.interstitial.a.parseAd(str);
            if (appnextAd == null) {
                return;
            }
            this.j = new InterstitialAd(appnextAd);
            if (this.ao != null && (onAdClickedCallback = this.ao.getOnAdClickedCallback()) != null) {
                onAdClickedCallback.adClicked();
            }
            b(this.j, this.au);
            a(this, "click_event");
            if (this.j.getBannerID().equals(this.ap != null ? this.ap.getBannerID() : "")) {
                if (this.aw) {
                    return;
                }
                this.aw = true;
                a(this, "interstitial_main_click");
            } else if (this.ax) {
            } else {
                this.ax = true;
                a(this, "interstitial_suggested_click");
            }
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$adClick", th);
        }
    }

    @Override
    public final void b(AppnextAd appnextAd, f.a aVar) {
        try {
            a(this.cv, getResources().getDrawable(R.drawable.apnxt_loader));
            super.b(appnextAd, aVar);
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$doClick", th);
        }
    }

    protected final WebAppInterface s() {
        if (this.av == null) {
            this.av = new WebInterface();
        }
        return this.av;
    }

    public class WebInterface extends WebAppInterface {
        @Override
        @JavascriptInterface
        public String filterAds(String str) {
            return str;
        }

        @Override
        @JavascriptInterface
        public void gotoAppWall() {
        }

        @Override
        @JavascriptInterface
        public String loadAds() {
            return "";
        }

        @Override
        @JavascriptInterface
        public void videoPlayed() {
        }

        public WebInterface() {
            super(InterstitialActivity.this);
        }

        @Override
        @JavascriptInterface
        public void destroy(String str) {
            try {
                if (str.equals("c_close")) {
                    InterstitialActivity.this.aA = true;
                    InterstitialActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            try {
                                JSONObject jSONObject = new JSONObject(InterstitialActivity.this.ap.getAdJSON());
                                jSONObject.put("urlApp", jSONObject.getString("urlApp") + "&tem_id=156");
                                InterstitialActivity.this.e(jSONObject.toString());
                            } catch (JSONException unused) {
                                InterstitialActivity.this.e(InterstitialActivity.this.ap.getAdJSON());
                            }
                        }
                    });
                } else if (str.equals("close")) {
                    InterstitialActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            InterstitialActivity.this.a();
                            InterstitialActivity.this.finish();
                        }
                    });
                } else {
                    InterstitialActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            InterstitialActivity.this.onError(AdsError.AD_NOT_READY);
                            InterstitialActivity.this.finish();
                        }
                    });
                }
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$destroy", th);
            }
        }

        @Override
        @JavascriptInterface
        public void notifyImpression(String str) {
            super.notifyImpression(str);
            try {
                if (InterstitialActivity.this.ap != null) {
                    InterstitialActivity.this.c(InterstitialActivity.this.ap.getBannerID());
                    InterstitialActivity.this.ap.setImpressionURL(str);
                    InterstitialActivity.this.handler.postDelayed(new a(str), Long.parseLong(InterstitialActivity.this.getConfig().t("postpone_impression_sec")) * 1000);
                }
                if (InterstitialActivity.this.autoPlay == null || !InterstitialActivity.this.autoPlay.booleanValue()) {
                    return;
                }
                play();
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$notifyImpression", th);
            }
        }

        @Override
        @JavascriptInterface
        public void postView(String str) {
            try {
                if (InterstitialActivity.this.ap != null) {
                    InterstitialActivity.this.c(g.f(str, "b"));
                }
                if (Boolean.parseBoolean(InterstitialActivity.this.d("pview"))) {
                    InterstitialActivity.this.handler.postDelayed(new b(str), Long.parseLong(InterstitialActivity.this.getConfig().t("postpone_vta_sec")) * 1000);
                }
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$postView", th);
            }
        }

        @Override
        @JavascriptInterface
        public void openStore(final String str) {
            InterstitialActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    InterstitialActivity.this.e(str);
                }
            });
        }

        @Override
        @JavascriptInterface
        public void play() {
            try {
                String unused = InterstitialActivity.this.placementID;
                InterstitialActivity.this.play();
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$play", th);
            }
        }

        @Override
        @JavascriptInterface
        public void openLink(String str) {
            try {
                InterstitialActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$openLink", th);
            }
        }

        @Override
        @JavascriptInterface
        public void logSTP(String str, String str2) {
            try {
                g.a(InterstitialActivity.this.ao, InterstitialActivity.this.ap, str, str2, InterstitialActivity.this.getConfig());
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$logSTP", th);
            }
        }

        @Override
        @JavascriptInterface
        public void jsError(String str) {
            try {
                if (TextUtils.isEmpty(str) && (str.contains("is not a function") || str.contains("has no method"))) {
                    InterstitialActivity interstitialActivity = InterstitialActivity.this;
                    int i = interstitialActivity.as;
                    interstitialActivity.as = i + 1;
                    if (i < 5) {
                        InterstitialActivity.this.at.postDelayed(InterstitialActivity.this.aB, 500L);
                        return;
                    }
                    InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
                    InterstitialActivity.this.finish();
                    return;
                }
                new StringBuilder("jsError ").append(str);
                InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
                InterstitialActivity.this.finish();
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$jsError", th);
            }
        }

        @Override
        @JavascriptInterface
        public void openResultPage(String str) {
            try {
                d.ay().a(new com.appnext.core.result.c() {
                    @Override
                    public final String v() {
                        return "160";
                    }

                    @Override
                    public final JSONObject getConfigParams() throws JSONException {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("vid", "2.6.6.473");
                        jSONObject.put("tid", InterstitialActivity.this.ao == null ? "" : InterstitialActivity.this.ao.getTID());
                        jSONObject.put("auid", InterstitialActivity.this.ao != null ? InterstitialActivity.this.ao.getAUID() : "");
                        jSONObject.put("osid", "100");
                        jSONObject.put("tem_id", "1601");
                        jSONObject.put("id", getPlacementId());
                        jSONObject.put("cat", InterstitialActivity.this.ap.getCategories());
                        jSONObject.put("lockcat", InterstitialActivity.this.ap.getSpecificCategories());
                        jSONObject.put("pview", InterstitialActivity.this.getConfig().t("pview"));
                        jSONObject.put("devn", g.V());
                        jSONObject.put("dosv", Build.VERSION.SDK_INT);
                        jSONObject.put("dds", "0");
                        jSONObject.put("ads_type", "banner");
                        jSONObject.put("country", InterstitialActivity.this.ap.getCountry());
                        jSONObject.put("gdpr", i.a(InterstitialActivity.this.ap, InterstitialActivity.this.getConfig()));
                        return jSONObject;
                    }

                    @Override
                    public final AppnextAd getSelectedAd() {
                        return InterstitialActivity.this.ap;
                    }

                    @Override
                    public final String getPlacementId() {
                        return InterstitialActivity.this.placementID;
                    }

                    @Override
                    public final String w() {
                        return com.appnext.ads.interstitial.a.C().k(InterstitialActivity.this.ao);
                    }

                    @Override
                    public final String x() {
                        return InterstitialActivity.this.ay;
                    }

                    @Override
                    public final SettingsManager y() {
                        return InterstitialActivity.this.getConfig();
                    }

                    @Override
                    public final Ad z() {
                        return InterstitialActivity.this.ao;
                    }

                    @Override
                    public final com.appnext.core.result.a A() {
                        return new com.appnext.core.result.a() {
                            @Override
                            public final Object B() {
                                return null;
                            }

                            @Override
                            public final String getFallbackScript() {
                                return null;
                            }

                            @Override
                            public final String getJSurl() {
                                return "https://cdn.appnext.com/tools/sdk/interstitial/v75/result.min.js";
                            }

                            @Override
                            public final WebViewClient getWebViewClient() {
                                return null;
                            }
                        };
                    }
                });
                Intent intent = new Intent(InterstitialActivity.this, ResultPageActivity.class);
                intent.putExtra("shouldClose", false);
                intent.setFlags(65536);
                InterstitialActivity.this.startActivity(intent);
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$openResultPage", th);
            }
        }
    }

    private class a implements Runnable {
        AppnextAd aF;

        a(String str) {
            try {
                InterstitialAd interstitialAd = new InterstitialAd(InterstitialActivity.this.ap);
                this.aF = interstitialAd;
                interstitialAd.setImpressionURL(str);
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$Impression", th);
            }
        }

        @Override
        public final void run() {
            try {
                if (InterstitialActivity.this.userAction != null) {
                    InterstitialActivity.this.userAction.d(this.aF);
                    InterstitialActivity.this.a(InterstitialActivity.this, "impression_event");
                }
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$Impression", th);
            }
        }
    }

    private class b implements Runnable {
        AppnextAd aF;

        b(String str) {
            try {
                com.appnext.ads.interstitial.a.C();
                this.aF = (AppnextAd) com.appnext.ads.interstitial.a.parseAd(str);
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$PostView", th);
            }
        }

        @Override
        public final void run() {
            try {
                InterstitialActivity.this.a(this.aF, (f.a) null);
            } catch (Throwable th) {
                com.appnext.base.a.a("InterstitialActivity$PostView", th);
            }
        }
    }

    public void play() {
        loadJS("Appnext.Layout.Video.play();");
    }

    public void a() {
        OnAdClosed onAdClosedCallback;
        try {
            if (this.ao == null || (onAdClosedCallback = this.ao.getOnAdClosedCallback()) == null) {
                return;
            }
            onAdClosedCallback.onAdClosed();
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onClose", th);
        }
    }

    public void a(Context context, String str) {
        try {
            if (this.ao != null) {
                g.a(context, this.ao.getTID(), this.ao.getVID(), this.ao.getAUID(), this.ao.getPlacementID(), this.ao.getSessionId(), str, "current_interstitial", this.ap != null ? this.ap.getBannerID() : "", this.ap != null ? this.ap.getCampaignID() : "");
            }
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$report", th);
        }
    }

    private void loadJS(final String str) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                if (InterstitialActivity.this.am != null) {
                    try {
                        WebView webView = InterstitialActivity.this.am;
                        webView.loadUrl("javascript:(function() { try { " + str + "} catch(err){ Appnext.jsError(err.message); }})()");
                    } catch (Throwable th) {
                        com.appnext.base.a.a("InterstitialActivity$loadJS", th);
                    }
                }
            }
        });
    }

    protected final synchronized void t() {
        boolean z;
        InterstitialAd interstitialAd;
        String buttonText;
        try {
            ArrayList<AppnextAd> b2 = com.appnext.ads.interstitial.a.C().b(this, this.ao, this.aq);
            if (b2 == null) {
                finish();
                onError(AppnextError.NO_ADS);
                return;
            }
            String a2 = com.appnext.ads.interstitial.a.C().a(b2);
            if (a2 == null) {
                finish();
                onError(AppnextError.NO_ADS);
                return;
            }
            String replace = a2.replace("\u2028", "\\u2028").replace("\u2029", "\\u2029");
            this.ay = replace;
            this.ap = new InterstitialAd(b2.get(0));
            int i = getResources().getConfiguration().orientation;
            JSONObject u = u();
            AppnextAd appnextAd = b2.get(0);
            boolean z2 = true;
            if (appnextAd.getVideoUrl().equals("") && appnextAd.getVideoUrlHigh().equals("") && appnextAd.getVideoUrl30Sec().equals("") && appnextAd.getVideoUrlHigh30Sec().equals("")) {
                z = false;
                if (!z) {
                    StringBuilder sb = new StringBuilder();
                    if (this.autoPlay == null || !this.autoPlay.booleanValue()) {
                        z2 = false;
                    }
                    sb.append(z2);
                    u.put("remote_auto_play", sb.toString());
                } else {
                    u.put("remote_auto_play", "false");
                }
                interstitialAd = new InterstitialAd(b2.get(0));
                if (!interstitialAd.getButtonText().equals("")) {
                    if (g.b(this, interstitialAd.getAdPackage())) {
                        buttonText = d("existing_button_text");
                    } else {
                        buttonText = d("new_button_text");
                    }
                } else {
                    buttonText = interstitialAd.getButtonText();
                }
                u.put("b_title", buttonText);
                loadJS("Appnext.setParams(" + u.toString() + ");");
                loadJS("Appnext.loadInterstitial(" + replace + ");");
                if (this.ap != null) {
                    com.appnext.ads.interstitial.a.C().a(this, this.ap.getBannerID(), Interstitial.currentAd);
                }
                this.handler.post(new Runnable() {
                    @Override
                    public final void run() {
                        OnAdOpened onAdOpenedCallback;
                        if (Interstitial.currentAd == null || (onAdOpenedCallback = Interstitial.currentAd.getOnAdOpenedCallback()) == null) {
                            return;
                        }
                        onAdOpenedCallback.adOpened();
                    }
                });
            }
            z = true;
            if (!z) {
            }
            interstitialAd = new InterstitialAd(b2.get(0));
            if (!interstitialAd.getButtonText().equals("")) {
            }
            u.put("b_title", buttonText);
            loadJS("Appnext.setParams(" + u.toString() + ");");
            loadJS("Appnext.loadInterstitial(" + replace + ");");
            if (this.ap != null) {
            }
            this.handler.post(new Runnable() {
                @Override
                public final void run() {
                    OnAdOpened onAdOpenedCallback;
                    if (Interstitial.currentAd == null || (onAdOpenedCallback = Interstitial.currentAd.getOnAdOpenedCallback()) == null) {
                        return;
                    }
                    onAdOpenedCallback.adOpened();
                }
            });
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$loadAdsData", th);
            finish();
            onError(AppnextError.INTERNAL_ERROR);
        }
    }

    protected final JSONObject u() throws JSONException {
        String str;
        try {
            String d = this.ao.getButtonColor().equals("") ? d("button_color") : this.ao.getButtonColor();
            if (d.startsWith("#")) {
                d = d.substring(1);
            }
            if (this.autoPlay == null) {
                this.autoPlay = Boolean.valueOf(Boolean.parseBoolean(d("auto_play")));
            }
            if (this.mute == null) {
                this.mute = Boolean.valueOf(Boolean.parseBoolean(d("mute")));
            }
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("id", this.placementID);
                jSONObject.put("cat", this.ao.getCategories());
                jSONObject.put("lockcat", this.ao.getSpecificCategories());
                jSONObject.put("pbk", this.ao.getPostback());
                jSONObject.put("b_color", d);
                if (this.ads == null) {
                    jSONObject.put("skip_title", this.ao.getSkipText().equals("") ? d("skip_title") : this.ao.getSkipText());
                    jSONObject.put("pview", this.ads != null ? "false" : d("pview"));
                    jSONObject.put("video_length", d("video_length"));
                    jSONObject.put("min_internet_connection", d("min_internet_connection"));
                    jSONObject.put("min_internet_connection_video", d("min_internet_connection_video"));
                    StringBuilder sb = new StringBuilder();
                    sb.append(this.mute);
                    jSONObject.put("mute", sb.toString());
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append(this.autoPlay);
                    jSONObject.put("auto_play", sb2.toString());
                    jSONObject.put("remove_poster_on_auto_play", d("remove_poster_on_auto_play"));
                    jSONObject.put("show_rating", d("show_rating"));
                    jSONObject.put("show_desc", d("show_desc"));
                    jSONObject.put("creative", this.aq);
                    jSONObject.put("remote_auto_play", true);
                }
                jSONObject.put("stp_flag", d("stp_flag"));
                jSONObject.put("ext", "t");
                jSONObject.put("dct", g.c(this));
                jSONObject.put("did", this.az);
                jSONObject.put("devn", g.V());
                jSONObject.put("dosv", Build.VERSION.SDK_INT);
                jSONObject.put("dds", "0");
                jSONObject.put("urlApp_protection", d("urlApp_protection"));
                jSONObject.put("vid", this.ao.getVID());
                jSONObject.put("tid", this.ao.getTID());
                jSONObject.put("auid", this.ao.getAUID());
                jSONObject.put("osid", "100");
                jSONObject.put("ads_type", "interstitial");
                jSONObject.put("country", this.ap.getCountry());
                jSONObject.put("gdpr", i.a(this.ap, c.E()));
                jSONObject.put("lang_settings", new JSONObject(com.appnext.core.a.a.n(this).ag()).toString());
                String language = this.ao.getLanguage();
                if (language == null || language.equals("")) {
                    language = Locale.getDefault().getLanguage().toUpperCase();
                }
                jSONObject.put("lang", language);
                jSONObject.put("tem", new JSONArray(d("S1")).toString());
                jSONObject.put("click_x", d("clickType_A"));
                if (getIntent() != null && getIntent().hasExtra("show_desc")) {
                    jSONObject.put("show_desc", getIntent().getStringExtra("show_desc"));
                }
                try {
                    Bitmap p = g.p(this.ap.getImageURL());
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    p.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
                    String str2 = "data:image/" + this.ap.getImageURL().substring(this.ap.getImageURL().lastIndexOf(46) + 1) + ";base64," + Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
                    try {
                        Palette.Swatch vibrantSwatch = Palette.from(p).generate().getVibrantSwatch();
                        if (vibrantSwatch != null) {
                            jSONObject.put("icon_color", String.format("#%06X", Integer.valueOf(vibrantSwatch.getRgb() & 16777215)));
                        } else {
                            jSONObject.put("icon_color", "");
                        }
                        jSONObject.put("icon_src", str2);
                    }
                } catch (Throwable th) {
                    str = "InterstitialActivity$getAdParams";
                    try {
                        com.appnext.base.a.a(str, th);
                    } catch (Throwable th2) {
                        th = th2;
                        com.appnext.base.a.a(str, th);
                        return new JSONObject();
                    }
                }
                return jSONObject;
            } catch (Throwable th3) {
                th = th3;
                str = "InterstitialActivity$getAdParams";
            }
        } catch (Throwable th4) {
            th = th4;
            str = "InterstitialActivity$getAdParams";
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        try {
            com.appnext.ads.interstitial.a.C().g(this.ao);
            this.ao.destroy();
            this.ao = null;
            if (this.at != null) {
                this.at.removeCallbacksAndMessages(null);
            }
            this.at = null;
            this.aB = null;
            this.ap = null;
            if (this.am != null) {
                this.am.stopLoading();
                if (this.am.getParent() != null) {
                    ((ViewGroup) this.am.getParent()).removeView(this.am);
                }
                this.am.setWebChromeClient(null);
                this.am.setWebViewClient(null);
                this.am.destroy();
                this.am = null;
            }
            AppnextWebView.q(this).a(s());
            this.av = null;
            this.au = null;
        } catch (Throwable th) {
            com.appnext.base.a.a("InterstitialActivity$onDestroy", th);
        }
    }

    public String d(String str) {
        String t = c.E().t(str);
        return t == null ? "" : t;
    }
}