导航菜单

页面标题

页面副标题

Chaupal v3.2 - MagicXActivity.java 源代码

正在查看: Chaupal v3.2 应用的 MagicXActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.razorpay;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.Toast;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;

@Metadata
public final class MagicXActivity extends Activity {

    @NotNull
    public static final J$_M_ Companion = new J$_M_((byte) 0);
    public static final int MAGICX_REQUEST_CODE = 98001;
    public static final int MAGICX_RESPONSE_CODE = 99002;

    @NotNull
    private static final String TAG = "MagicXActivity";
    private JSONArray itemsToBeAddedToCart;
    private boolean magicxLoaded;
    private ViewGroup parentContainer;
    private String storefrontUrl;
    private View viewCover;
    private WebView webView;

    public final void dismissHalfTransparentPage() {
        if (this.viewCover != null) {
            this.magicxLoaded = true;
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    MagicXActivity.m9dismissHalfTransparentPage$lambda1(MagicXActivity.this);
                }
            });
        }
    }

    public static final void m9dismissHalfTransparentPage$lambda1(MagicXActivity magicXActivity) {
        Intrinsics.checkNotNullParameter(magicXActivity, "this$0");
        ViewGroup viewGroup = magicXActivity.parentContainer;
        View view = null;
        if (viewGroup == null) {
            Intrinsics.w("parentContainer");
            viewGroup = null;
        }
        View view2 = magicXActivity.viewCover;
        if (view2 == null) {
            Intrinsics.w("viewCover");
        } else {
            view = view2;
        }
        viewGroup.removeView(view);
        CheckoutUtils.a();
    }

    private final void handleShouldInterceptRequest(String str) {
    }

    private final void setSettingsForWebView() {
        WebView webView = this.webView;
        WebView webView2 = null;
        if (webView == null) {
            Intrinsics.w("webView");
            webView = null;
        }
        webView.getSettings().setJavaScriptEnabled(true);
        WebView webView3 = this.webView;
        if (webView3 == null) {
            Intrinsics.w("webView");
            webView3 = null;
        }
        webView3.getSettings().setDomStorageEnabled(true);
        WebView webView4 = this.webView;
        if (webView4 == null) {
            Intrinsics.w("webView");
        } else {
            webView2 = webView4;
        }
        webView2.addJavascriptInterface(this, "MagicXBridge");
    }

    private final void setWebViewClientForMagicX() {
        WebView webView = this.webView;
        if (webView == null) {
            Intrinsics.w("webView");
            webView = null;
        }
        webView.setWebViewClient(new MagicXActivity$setWebViewClientForMagicX$1(this));
    }

    private final void showHalfTransparentPage() {
        if (this.viewCover != null) {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    MagicXActivity.m10showHalfTransparentPage$lambda0(MagicXActivity.this);
                }
            });
        }
    }

    public static final void m10showHalfTransparentPage$lambda0(MagicXActivity magicXActivity) {
        Intrinsics.checkNotNullParameter(magicXActivity, "this$0");
        ViewGroup viewGroup = magicXActivity.parentContainer;
        View view = null;
        if (viewGroup == null) {
            Intrinsics.w("parentContainer");
            viewGroup = null;
        }
        View view2 = magicXActivity.viewCover;
        if (view2 == null) {
            Intrinsics.w("viewCover");
        } else {
            view = view2;
        }
        viewGroup.addView(view);
        CheckoutUtils.e(magicXActivity, "#000000");
    }

    @JavascriptInterface
    public final void errorFromJs(@NotNull String str) {
        Intrinsics.checkNotNullParameter(str, "error");
        Toast.makeText(this, str, 1).show();
    }

    @Override
    protected final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        View findViewById = findViewById(android.R.id.content);
        Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(android.R.id.content)");
        this.parentContainer = (ViewGroup) findViewById;
        this.webView = new WebView(this);
        setSettingsForWebView();
        setWebViewClientForMagicX();
        View view = new View(this);
        this.viewCover = view;
        view.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        View view2 = this.viewCover;
        String str = null;
        if (view2 == null) {
            Intrinsics.w("viewCover");
            view2 = null;
        }
        view2.setBackgroundColor(Color.parseColor("#cc000000"));
        String stringExtra = getIntent().getStringExtra("url");
        if (stringExtra != null) {
            this.storefrontUrl = stringExtra;
        }
        String stringExtra2 = getIntent().getStringExtra("itemsJsonArray");
        if (stringExtra2 != null) {
            this.itemsToBeAddedToCart = new JSONArray(stringExtra2);
        }
        if (this.storefrontUrl == null && this.itemsToBeAddedToCart == null) {
            Intent intent = new Intent();
            intent.putExtra("response", new JSONObject("{\n    \"error\":{\n        \"code\":\"BAD_REQUEST_ERROR\",\n        \"description\":\"Storefront URL or Items List not provided\",\n        \"step\":\"initialization\"\n    }\n}").toString());
            bf.i iVar = bf.i.a;
            setResult(99002, intent);
            finishActivity(98001);
            return;
        }
        ViewGroup viewGroup = this.parentContainer;
        if (viewGroup == null) {
            Intrinsics.w("parentContainer");
            viewGroup = null;
        }
        WebView webView = this.webView;
        if (webView == null) {
            Intrinsics.w("webView");
            webView = null;
        }
        viewGroup.addView(webView);
        showHalfTransparentPage();
        WebView webView2 = this.webView;
        if (webView2 == null) {
            Intrinsics.w("webView");
            webView2 = null;
        }
        String str2 = this.storefrontUrl;
        if (str2 == null) {
            Intrinsics.w("storefrontUrl");
        } else {
            str = str2;
        }
        webView2.loadUrl(str);
    }
}