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

以下内容为反编译后的 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.e;
import com.appnext.core.f;
import com.appnext.core.k;
import com.appnext.core.p;
import com.appnext.core.q;
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 com.bytedance.sdk.openadsdk.preload.falconx.statistic.StatisticData;
import com.google.android.exoplayer2.C;
import com.mopub.common.Constants;
import com.mopub.network.ImpressionData;
import com.my.tracker.ads.AdFormat;
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 AppnextAd aE;
    private com.appnext.ads.b aF;
    private ArrayList<AppnextAd> ads;
    private Boolean autoPlay;
    protected WebView bP;
    private Interstitial bR;
    private InterstitialAd bS;
    private Handler bV;
    private e.a bW;
    private WebAppInterface bX;
    private String ca;
    private Boolean canClose;
    private Boolean mute;
    private boolean bQ = false;
    private String bT = "";
    private boolean closed = false;
    private int bU = 0;
    private boolean bY = false;
    private boolean bZ = false;
    private String cc = "";
    private boolean cd = false;
    private Runnable ce = new Runnable() {
        @Override
        public final void run() {
            InterstitialActivity.l(InterstitialActivity.this);
        }
    };

    protected static void a(String str, String str2, String str3) {
    }

    static boolean a(InterstitialActivity interstitialActivity, boolean z) {
        interstitialActivity.cd = true;
        return true;
    }

    static int u(InterstitialActivity interstitialActivity) {
        int i = interstitialActivity.bU;
        interstitialActivity.bU = i + 1;
        return i;
    }

    @Override
    public void onCreate(Bundle bundle) {
        setRequestedOrientation(7);
        super.onCreate(bundle);
        if (Interstitial.currentAd == null) {
            finish();
            return;
        }
        this.bR = new Interstitial(Interstitial.currentAd);
        if (getRequestedOrientation() == 6) {
            report(com.appnext.ads.a.ai);
        } else {
            report(com.appnext.ads.a.aj);
        }
        this.gl = new RelativeLayout(this);
        setContentView(this.gl);
        this.gl.getLayoutParams().width = -1;
        this.gl.getLayoutParams().height = -1;
        this.gl.setBackgroundColor(-1);
        try {
            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()) {
                    report(com.appnext.ads.a.ae);
                } else {
                    report(com.appnext.ads.a.af);
                }
            }
            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()) {
                    report(com.appnext.ads.a.ag);
                } else {
                    report(com.appnext.ads.a.ah);
                }
            }
            if (getIntent().hasExtra("pview")) {
                this.gj = getIntent().getStringExtra("pview");
                this.banner = getIntent().getStringExtra(AdFormat.BANNER);
                this.guid = getIntent().getStringExtra("guid");
            }
            if (getIntent().getSerializableExtra("ads") != null) {
                this.ads = (ArrayList) getIntent().getSerializableExtra("ads");
            }
            this.bV = new Handler();
            AppnextWebView.u(this).a(this.bR.getPageUrl(), new AppnextWebView.c() {
                @Override
                public final void f(String str) {
                    InterstitialActivity.a(InterstitialActivity.this);
                }

                @Override
                public final void error(String str) {
                    InterstitialActivity.a(InterstitialActivity.this);
                }
            });
            this.bW = new e.a() {
                @Override
                public final void onMarket(String str) {
                    new StringBuilder("marketUrl ").append(str);
                    if (InterstitialActivity.this.handler != null) {
                        InterstitialActivity.this.handler.removeCallbacks(null);
                    }
                    InterstitialActivity.this.ba();
                }

                @Override
                public final void error(String str) {
                    if (InterstitialActivity.this.handler != null) {
                        InterstitialActivity.this.handler.removeCallbacks(null);
                    }
                    InterstitialActivity.this.ba();
                    String unused = InterstitialActivity.this.placementID;
                    StringBuilder sb = new StringBuilder();
                    sb.append(new InterstitialAd(InterstitialActivity.this.aE).getAppURL());
                    sb.append(" ");
                    sb.append(str);
                }
            };
            this.userAction = new q(this, new q.a() {
                @Override
                public final void report(String str) {
                }

                @Override
                public final Ad e() {
                    return InterstitialActivity.this.bR;
                }

                @Override
                public final AppnextAd f() {
                    return InterstitialActivity.this.aE;
                }

                @Override
                public final p g() {
                    return InterstitialActivity.this.getConfig();
                }
            });
            new Thread(new Runnable() {
                @Override
                public final void run() {
                    InterstitialActivity interstitialActivity = InterstitialActivity.this;
                    interstitialActivity.cc = f.b((Context) interstitialActivity, true);
                }
            }).start();
        } catch (Throwable unused) {
            finish();
        }
    }

    private void v() {
        try {
            AppnextWebView u = AppnextWebView.u(this);
            this.bP = u.ai(this.ads != null ? "fullscreen" : "interstitial");
            WebView a2 = u.a(this, this.bR.getPageUrl(), w(), this.bR.getFallback(), this.ads != null ? "fullscreen" : "interstitial");
            this.bP = a2;
            a2.setWebViewClient(new AnonymousClass7());
            this.bP.setWebChromeClient(new AnonymousClass8());
        } catch (Throwable unused) {
            onError(AppnextError.INTERNAL_ERROR);
            finish();
        }
    }

    public final class AnonymousClass7 extends WebViewClient {
        AnonymousClass7() {
        }

        @Override
        public final boolean shouldOverrideUrlLoading(WebView webView, String str) {
            if (str == null) {
                return false;
            }
            if (str.startsWith(Constants.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.bV.removeCallbacksAndMessages(null);
            InterstitialActivity.l(InterstitialActivity.this);
        }
    }

    public final class AnonymousClass8 extends WebChromeClient {
        AnonymousClass8() {
        }

        @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")) {
                return true;
            }
            InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
            InterstitialActivity.this.finish();
            return true;
        }
    }

    private void pageFinished() {
        Handler handler = this.bV;
        if (handler != null) {
            handler.removeCallbacks(this.ce);
        }
        this.bQ = true;
        String string = getIntent().getExtras().getString("creative");
        this.bT = string;
        if (string == null || string.equals(Interstitial.TYPE_MANAGED)) {
            this.bT = d("creative");
        }
        new Thread(new AnonymousClass10()).start();
        WebView webView = this.bP;
        if (webView == null) {
            onError(AppnextError.INTERNAL_ERROR);
            finish();
            return;
        }
        if (webView.getParent() != null) {
            ((ViewGroup) this.bP.getParent()).removeView(this.bP);
        }
        this.gl.addView(this.bP);
        this.bP.getLayoutParams().width = -1;
        this.bP.getLayoutParams().height = -1;
    }

    public final class AnonymousClass10 implements Runnable {
        AnonymousClass10() {
        }

        @Override
        public final void run() {
            InterstitialActivity.this.x();
        }
    }

    @Override
    protected final p getConfig() {
        return c.K();
    }

    @Override
    protected void onResume() {
        Boolean bool;
        super.onResume();
        if (this.cd) {
            onClose();
            finish();
            return;
        }
        if (this.bQ && (bool = this.autoPlay) != null && bool.booleanValue()) {
            loadJS("Appnext.Layout.Video.play();");
        }
        try {
            this.bP.loadUrl("javascript:(function() { try{Appnext.countToClose();}catch(e){}})()");
        } catch (Throwable unused) {
        }
    }

    @Override
    protected void onPause() {
        WebView webView;
        super.onPause();
        if (this.closed || (webView = this.bP) == null) {
            return;
        }
        webView.loadUrl("javascript:(function() { Appnext.Layout.Video.pause();})()");
    }

    @Override
    public void onBackPressed() {
        Boolean bool = this.canClose;
        if (bool != null) {
            if (!bool.booleanValue()) {
                return;
            }
        } else if (!Boolean.parseBoolean(d("can_close"))) {
            return;
        }
        loadJS("Appnext.Layout.destroy('internal');");
        this.closed = true;
        onClose();
        finish();
    }

    @Override
    protected final void onError(final String str) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                if (InterstitialActivity.this.bR == null || InterstitialActivity.this.bR.getOnAdErrorCallback() == null) {
                    return;
                }
                InterstitialActivity.this.bR.getOnAdErrorCallback().adError(str);
            }
        });
    }

    private void e(String str) {
        com.appnext.ads.interstitial.a.G();
        AppnextAd appnextAd = (AppnextAd) com.appnext.ads.interstitial.a.parseAd(str);
        if (appnextAd == null) {
            return;
        }
        this.aE = new InterstitialAd(appnextAd);
        Interstitial interstitial = this.bR;
        if (interstitial != null && interstitial.getOnAdClickedCallback() != null) {
            this.bR.getOnAdClickedCallback().adClicked();
        }
        b(this.aE, this.bW);
        report(com.appnext.ads.a.V);
        String bannerID = this.aE.getBannerID();
        InterstitialAd interstitialAd = this.bS;
        if (bannerID.equals(interstitialAd != null ? interstitialAd.getBannerID() : "")) {
            if (this.bY) {
                return;
            }
            this.bY = true;
            report(com.appnext.ads.a.al);
            return;
        }
        if (this.bZ) {
            return;
        }
        this.bZ = true;
        report(com.appnext.ads.a.ak);
    }

    @Override
    public final void b(AppnextAd appnextAd, e.a aVar) {
        a(this.gl, getResources().getDrawable(R.drawable.apnxt_loader));
        super.b(appnextAd, aVar);
    }

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

    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) {
            if (str.equals("c_close")) {
                InterstitialActivity.a(InterstitialActivity.this, true);
                InterstitialActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        try {
                            JSONObject jSONObject = new JSONObject(InterstitialActivity.this.bS.getAdJSON());
                            jSONObject.put("urlApp", jSONObject.getString("urlApp") + "&tem_id=156");
                            InterstitialActivity.b(InterstitialActivity.this, jSONObject.toString());
                        } catch (JSONException unused) {
                            InterstitialActivity.b(InterstitialActivity.this, InterstitialActivity.this.bS.getAdJSON());
                        }
                    }
                });
            } else if (str.equals("close")) {
                InterstitialActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        InterstitialActivity.this.onClose();
                        InterstitialActivity.this.finish();
                    }
                });
            } else {
                InterstitialActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        InterstitialActivity.this.onError(AdsError.AD_NOT_READY);
                        InterstitialActivity.this.finish();
                    }
                });
            }
        }

        @Override
        @JavascriptInterface
        public void notifyImpression(String str) {
            super.notifyImpression(str);
            if (InterstitialActivity.this.bS != null) {
                InterstitialActivity.this.bS.setImpressionURL(str);
                InterstitialActivity.this.handler.postDelayed(new a(str), Long.parseLong(InterstitialActivity.this.getConfig().get("postpone_impression_sec")) * 1000);
            }
            if (InterstitialActivity.this.autoPlay == null || !InterstitialActivity.this.autoPlay.booleanValue()) {
                return;
            }
            play();
        }

        @Override
        @JavascriptInterface
        public void postView(String str) {
            if (Boolean.parseBoolean(InterstitialActivity.this.ads != null ? "false" : InterstitialActivity.this.d("pview"))) {
                InterstitialActivity.this.handler.postDelayed(new b(str), Long.parseLong(InterstitialActivity.this.getConfig().get("postpone_vta_sec")) * 1000);
            }
        }

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

        @Override
        @JavascriptInterface
        public void play() {
            String unused = InterstitialActivity.this.placementID;
            InterstitialActivity.this.loadJS("Appnext.Layout.Video.play();");
        }

        @Override
        @JavascriptInterface
        public void openLink(String str) {
            InterstitialActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
        }

        @Override
        @JavascriptInterface
        public void logSTP(String str, String str2) {
            f.a(InterstitialActivity.this.bR, InterstitialActivity.this.bS, str, str2, InterstitialActivity.this.getConfig());
        }

        @Override
        @JavascriptInterface
        public void jsError(String str) {
            if (TextUtils.isEmpty(str) && (str.contains("is not a function") || str.contains("has no method"))) {
                if (InterstitialActivity.u(InterstitialActivity.this) < 5) {
                    InterstitialActivity.this.bV.postDelayed(InterstitialActivity.this.ce, 500L);
                    return;
                } else {
                    InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
                    InterstitialActivity.this.finish();
                    return;
                }
            }
            new StringBuilder("jsError ").append(str);
            InterstitialActivity.this.onError(AppnextError.INTERNAL_ERROR);
            InterstitialActivity.this.finish();
        }

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

                @Override
                public final JSONObject getConfigParams() throws JSONException {
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("vid", "2.5.1.472");
                    jSONObject.put("tid", InterstitialActivity.this.bR == null ? "" : InterstitialActivity.this.bR.getTID());
                    jSONObject.put("auid", InterstitialActivity.this.bR != null ? InterstitialActivity.this.bR.getAUID() : "");
                    jSONObject.put("osid", StatisticData.ERROR_CODE_NOT_FOUND);
                    jSONObject.put("tem_id", "1601");
                    jSONObject.put("id", getPlacementId());
                    jSONObject.put("cat", InterstitialActivity.this.bS.getCategories());
                    jSONObject.put("pview", InterstitialActivity.this.getConfig().get("pview"));
                    jSONObject.put("devn", f.be());
                    jSONObject.put("dosv", Build.VERSION.SDK_INT);
                    jSONObject.put("dds", "0");
                    jSONObject.put("ads_type", AdFormat.BANNER);
                    jSONObject.put(ImpressionData.COUNTRY, InterstitialActivity.this.bS.getCountry());
                    jSONObject.put("gdpr", k.a(InterstitialActivity.this.bS, InterstitialActivity.this.getConfig()));
                    return jSONObject;
                }

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

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

                @Override
                public final String A() {
                    return com.appnext.ads.interstitial.a.G().l(InterstitialActivity.this.bR);
                }

                @Override
                public final String B() {
                    return InterstitialActivity.this.ca;
                }

                @Override
                public final p C() {
                    return InterstitialActivity.this.getConfig();
                }

                @Override
                public final Ad D() {
                    return InterstitialActivity.this.bR;
                }

                @Override
                public final com.appnext.core.result.a E() {
                    return new com.appnext.core.result.a() {
                        @Override
                        public final Object F() {
                            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, (Class<?>) ResultPageActivity.class);
            intent.putExtra("shouldClose", false);
            intent.setFlags(C.DEFAULT_BUFFER_SEGMENT_SIZE);
            InterstitialActivity.this.startActivity(intent);
        }
    }

    private class a implements Runnable {
        AppnextAd ch;

        a(String str) {
            InterstitialAd interstitialAd = new InterstitialAd(InterstitialActivity.this.bS);
            this.ch = interstitialAd;
            interstitialAd.setImpressionURL(str);
        }

        @Override
        public final void run() {
            try {
                if (InterstitialActivity.this.userAction != null) {
                    InterstitialActivity.this.userAction.e(this.ch);
                    InterstitialActivity.this.report(com.appnext.ads.a.G);
                }
            } catch (Throwable unused) {
            }
        }
    }

    private class b implements Runnable {
        AppnextAd ch;

        b(String str) {
            try {
                com.appnext.ads.interstitial.a.G();
                this.ch = (AppnextAd) com.appnext.ads.interstitial.a.parseAd(str);
            } catch (Throwable unused) {
            }
        }

        @Override
        public final void run() {
            InterstitialActivity.this.a(this.ch, (e.a) null);
        }
    }

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

    private void stop() {
        WebView webView = this.bP;
        if (webView != null) {
            webView.loadUrl("javascript:(function() { Appnext.Layout.Video.pause();})()");
        }
    }

    public void onClose() {
        Interstitial interstitial = this.bR;
        if (interstitial == null || interstitial.getOnAdClosedCallback() == null) {
            return;
        }
        this.bR.getOnAdClosedCallback().onAdClosed();
    }

    public void report(String str) {
        Interstitial interstitial = this.bR;
        if (interstitial != null) {
            String tid = interstitial.getTID();
            String vid = this.bR.getVID();
            String auid = this.bR.getAUID();
            String placementID = this.bR.getPlacementID();
            String sessionId = this.bR.getSessionId();
            InterstitialAd interstitialAd = this.bS;
            String bannerID = interstitialAd != null ? interstitialAd.getBannerID() : "";
            InterstitialAd interstitialAd2 = this.bS;
            f.a(tid, vid, auid, placementID, sessionId, str, "current_interstitial", bannerID, interstitialAd2 != null ? interstitialAd2.getCampaignID() : "");
        }
    }

    public void loadJS(final String str) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                if (InterstitialActivity.this.bP != null) {
                    InterstitialActivity.this.bP.loadUrl("javascript:(function() { try { " + str + "} catch(err){ Appnext.jsError(err.message); }})()");
                }
            }
        });
    }

    protected final synchronized void x() {
        boolean z;
        InterstitialAd interstitialAd;
        String buttonText;
        try {
            ArrayList<AppnextAd> b2 = com.appnext.ads.interstitial.a.G().b(this, this.bR, this.bT);
            if (b2 == null) {
                finish();
                onError(AppnextError.NO_ADS);
                return;
            }
            String a2 = com.appnext.ads.interstitial.a.G().a(b2);
            if (a2 == null) {
                finish();
                onError(AppnextError.NO_ADS);
                return;
            }
            String replace = a2.replace("\u2028", "\\u2028").replace("\u2029", "\\u2029");
            this.ca = replace;
            this.bS = new InterstitialAd(b2.get(0));
            int i = getResources().getConfiguration().orientation;
            JSONObject y = y();
            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);
                    y.put("remote_auto_play", sb.toString());
                } else {
                    y.put("remote_auto_play", "false");
                }
                interstitialAd = new InterstitialAd(b2.get(0));
                if (!interstitialAd.getButtonText().equals("")) {
                    if (f.c(this, interstitialAd.getAdPackage())) {
                        buttonText = d("existing_button_text");
                    } else {
                        buttonText = d("new_button_text");
                    }
                } else {
                    buttonText = interstitialAd.getButtonText();
                }
                y.put("b_title", buttonText);
                loadJS("Appnext.setParams(" + y.toString() + ");");
                loadJS("Appnext.loadInterstitial(" + replace + ");");
                com.appnext.ads.interstitial.a.G().a(this.bS.getBannerID(), Interstitial.currentAd);
                this.handler.post(new Runnable() {
                    @Override
                    public final void run() {
                        if (Interstitial.currentAd == null || Interstitial.currentAd.getOnAdOpenedCallback() == null) {
                            return;
                        }
                        Interstitial.currentAd.getOnAdOpenedCallback().adOpened();
                    }
                });
            }
            z = true;
            if (!z) {
            }
            interstitialAd = new InterstitialAd(b2.get(0));
            if (!interstitialAd.getButtonText().equals("")) {
            }
            y.put("b_title", buttonText);
            loadJS("Appnext.setParams(" + y.toString() + ");");
            loadJS("Appnext.loadInterstitial(" + replace + ");");
            com.appnext.ads.interstitial.a.G().a(this.bS.getBannerID(), Interstitial.currentAd);
            this.handler.post(new Runnable() {
                @Override
                public final void run() {
                    if (Interstitial.currentAd == null || Interstitial.currentAd.getOnAdOpenedCallback() == null) {
                        return;
                    }
                    Interstitial.currentAd.getOnAdOpenedCallback().adOpened();
                }
            });
        } catch (Throwable th) {
            finish();
            onError(AppnextError.INTERNAL_ERROR);
            f.b(th);
        }
    }

    protected final JSONObject y() throws JSONException {
        String d = this.bR.getButtonColor().equals("") ? d("button_color") : this.bR.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();
        jSONObject.put("id", this.placementID);
        jSONObject.put("cat", this.bR.getCategories());
        jSONObject.put("pbk", this.bR.getPostback());
        jSONObject.put("b_color", d);
        if (this.ads == null) {
            jSONObject.put("skip_title", this.bR.getSkipText().equals("") ? d("skip_title") : this.bR.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.bT);
            jSONObject.put("remote_auto_play", true);
        }
        jSONObject.put("stp_flag", d("stp_flag"));
        jSONObject.put("ext", com.appnext.base.a.c.d.COLUMN_TYPE);
        jSONObject.put("dct", f.o(this));
        jSONObject.put("did", this.cc);
        jSONObject.put("devn", f.be());
        jSONObject.put("dosv", Build.VERSION.SDK_INT);
        jSONObject.put("dds", "0");
        jSONObject.put("urlApp_protection", d("urlApp_protection"));
        jSONObject.put("vid", this.bR.getVID());
        jSONObject.put("tid", this.bR.getTID());
        jSONObject.put("auid", this.bR.getAUID());
        jSONObject.put("osid", StatisticData.ERROR_CODE_NOT_FOUND);
        jSONObject.put("ads_type", "interstitial");
        jSONObject.put(ImpressionData.COUNTRY, this.bS.getCountry());
        jSONObject.put("gdpr", k.a(this.bS, c.K()));
        jSONObject.put("lang_settings", new JSONObject(com.appnext.core.a.b.bp().bq()).toString());
        String language = this.bR.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 Y = f.Y(this.bS.getImageURL());
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            Y.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
            String str = "data:image/" + this.bS.getImageURL().substring(this.bS.getImageURL().lastIndexOf(46) + 1) + ";base64," + Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
            try {
                Palette.Swatch vibrantSwatch = Palette.from(Y).generate().getVibrantSwatch();
                if (vibrantSwatch != null) {
                    jSONObject.put("icon_color", String.format("#%06X", Integer.valueOf(vibrantSwatch.getRgb() & 16777215)));
                } else {
                    jSONObject.put("icon_color", "");
                }
            } catch (Throwable unused) {
                jSONObject.put("icon_color", "");
            }
            jSONObject.put("icon_src", str);
        } catch (Throwable unused2) {
        }
        return jSONObject;
    }

    private static String a(int i) {
        return String.format("#%06X", Integer.valueOf(i & 16777215));
    }

    private static boolean hasVideo(AppnextAd appnextAd) {
        return (appnextAd.getVideoUrl().equals("") && appnextAd.getVideoUrlHigh().equals("") && appnextAd.getVideoUrl30Sec().equals("") && appnextAd.getVideoUrlHigh30Sec().equals("")) ? false : true;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        try {
            com.appnext.ads.interstitial.a.G().g(this.bR);
            this.bR.destroy();
            this.bR = null;
            if (this.bV != null) {
                this.bV.removeCallbacksAndMessages(null);
            }
            this.bV = null;
            this.ce = null;
            this.bS = null;
            if (this.bP != null) {
                this.bP.stopLoading();
                if (this.bP.getParent() != null) {
                    ((ViewGroup) this.bP.getParent()).removeView(this.bP);
                }
                this.bP.setWebChromeClient(null);
                this.bP.setWebViewClient(null);
                this.bP.destroy();
                this.bP = null;
            }
            AppnextWebView.u(this).a(w());
            this.bX = null;
            this.bW = null;
            if (this.aF != null) {
                this.aF.a(this);
                this.aF = null;
            }
        } catch (Throwable unused) {
        }
    }

    public String d(String str) {
        String str2 = c.K().get(str);
        return str2 == null ? "" : str2;
    }

    static void a(InterstitialActivity interstitialActivity) {
        try {
            AppnextWebView u = AppnextWebView.u(interstitialActivity);
            interstitialActivity.bP = u.ai(interstitialActivity.ads != null ? "fullscreen" : "interstitial");
            WebView a2 = u.a(interstitialActivity, interstitialActivity.bR.getPageUrl(), interstitialActivity.w(), interstitialActivity.bR.getFallback(), interstitialActivity.ads != null ? "fullscreen" : "interstitial");
            interstitialActivity.bP = a2;
            a2.setWebViewClient(new AnonymousClass7());
            interstitialActivity.bP.setWebChromeClient(new AnonymousClass8());
        } catch (Throwable unused) {
            interstitialActivity.onError(AppnextError.INTERNAL_ERROR);
            interstitialActivity.finish();
        }
    }

    static void l(InterstitialActivity interstitialActivity) {
        Handler handler = interstitialActivity.bV;
        if (handler != null) {
            handler.removeCallbacks(interstitialActivity.ce);
        }
        interstitialActivity.bQ = true;
        String string = interstitialActivity.getIntent().getExtras().getString("creative");
        interstitialActivity.bT = string;
        if (string == null || string.equals(Interstitial.TYPE_MANAGED)) {
            interstitialActivity.bT = interstitialActivity.d("creative");
        }
        new Thread(new AnonymousClass10()).start();
        WebView webView = interstitialActivity.bP;
        if (webView == null) {
            interstitialActivity.onError(AppnextError.INTERNAL_ERROR);
            interstitialActivity.finish();
            return;
        }
        if (webView.getParent() != null) {
            ((ViewGroup) interstitialActivity.bP.getParent()).removeView(interstitialActivity.bP);
        }
        interstitialActivity.gl.addView(interstitialActivity.bP);
        interstitialActivity.bP.getLayoutParams().width = -1;
        interstitialActivity.bP.getLayoutParams().height = -1;
    }

    static void b(InterstitialActivity interstitialActivity, String str) {
        com.appnext.ads.interstitial.a.G();
        AppnextAd appnextAd = (AppnextAd) com.appnext.ads.interstitial.a.parseAd(str);
        if (appnextAd != null) {
            interstitialActivity.aE = new InterstitialAd(appnextAd);
            Interstitial interstitial = interstitialActivity.bR;
            if (interstitial != null && interstitial.getOnAdClickedCallback() != null) {
                interstitialActivity.bR.getOnAdClickedCallback().adClicked();
            }
            interstitialActivity.b(interstitialActivity.aE, interstitialActivity.bW);
            interstitialActivity.report(com.appnext.ads.a.V);
            String bannerID = interstitialActivity.aE.getBannerID();
            InterstitialAd interstitialAd = interstitialActivity.bS;
            if (bannerID.equals(interstitialAd != null ? interstitialAd.getBannerID() : "")) {
                if (interstitialActivity.bY) {
                    return;
                }
                interstitialActivity.bY = true;
                interstitialActivity.report(com.appnext.ads.a.al);
                return;
            }
            if (interstitialActivity.bZ) {
                return;
            }
            interstitialActivity.bZ = true;
            interstitialActivity.report(com.appnext.ads.a.ak);
        }
    }
}