导航菜单

页面标题

页面副标题

Chaupal v3.2 - MagicXActivity$setWebViewClientForMagicX$1.java 源代码

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

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


package com.razorpay;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.Log;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONArray;

@Metadata
public final class MagicXActivity$setWebViewClientForMagicX$1 extends WebViewClient {
    final MagicXActivity this$0;

    MagicXActivity$setWebViewClientForMagicX$1(MagicXActivity magicXActivity) {
        this.this$0 = magicXActivity;
    }

    public static final void m11onPageFinished$lambda0(MagicXActivity magicXActivity) {
        WebView webView;
        JSONArray jSONArray;
        Intrinsics.checkNotNullParameter(magicXActivity, "this$0");
        webView = magicXActivity.webView;
        if (webView == null) {
            Intrinsics.w("webView");
            webView = null;
        }
        StringBuilder sb2 = new StringBuilder("\n                            fetch(window.Shopify.routes.root + 'cart/clear.js')\n                              .then(res => {res.json()}).then(data => {\n                                const stringifiedFormData = { 'items': ");
        jSONArray = magicXActivity.itemsToBeAddedToCart;
        if (jSONArray == null) {
            Intrinsics.w("itemsToBeAddedToCart");
            jSONArray = null;
        }
        sb2.append(jSONArray);
        sb2.append("}\n\n\n                                fetch(window.Shopify.routes.root + 'cart/add.js', {\n                                  method: 'POST',\n                                  headers: {\n                                    'Content-Type': 'application/json'\n                                  },\n                                  body: JSON.stringify(stringifiedFormData)\n                                })\n                                .then(response => {\n                                  openRzpLogin();\n                                  return response.json();\n                                }).then(data=>{\n\n                                })\n                                .catch((error) => {\n                                  MagicXBridge.errorFromJs(JSON.stringify(error));\n                                });\n                              }).catch((error)=>{\n                                MagicXBridge.errorFromJs(JSON.stringify(error));\n                              });\n                        ");
        webView.evaluateJavascript(kotlin.text.j.f(sb2.toString()), null);
    }

    @Override
    public final void onPageFinished(WebView webView, String str) {
        String str2;
        str2 = this.this$0.storefrontUrl;
        if (str2 == null) {
            Intrinsics.w("storefrontUrl");
            str2 = null;
        }
        if (kotlin.text.j.s(str2, str, true)) {
            final MagicXActivity magicXActivity = this.this$0;
            magicXActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    MagicXActivity$setWebViewClientForMagicX$1.m11onPageFinished$lambda0(MagicXActivity.this);
                }
            });
        }
        super.onPageFinished(webView, str);
    }

    @Override
    public final void onPageStarted(WebView webView, String str, Bitmap bitmap) {
        super.onPageStarted(webView, str, bitmap);
    }

    @Override
    public final WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
        String url;
        boolean z;
        String str;
        boolean z2;
        if (webResourceRequest != null) {
            MagicXActivity magicXActivity = this.this$0;
            if (Build.VERSION.SDK_INT >= 21) {
                z2 = magicXActivity.magicxLoaded;
                if (z2) {
                    String uri = webResourceRequest.getUrl().toString();
                    Intrinsics.checkNotNullExpressionValue(uri, "it.url.toString()");
                    if (kotlin.text.j.F(uri, "https://api.razorpay.com/v1/checkout/public?", false, 2, (Object) null)) {
                        magicXActivity.magicxLoaded = false;
                        magicXActivity.finish();
                        return null;
                    }
                }
                String uri2 = webResourceRequest.getUrl().toString();
                Intrinsics.checkNotNullExpressionValue(uri2, "it.url.toString()");
                if (kotlin.text.j.F(uri2, "https://api.razorpay.com/v1/magic/order?", false, 2, (Object) null)) {
                    magicXActivity.dismissHalfTransparentPage();
                }
                String uri3 = webResourceRequest.getUrl().toString();
                Intrinsics.checkNotNullExpressionValue(uri3, "it.url.toString()");
                if (!kotlin.text.j.F(uri3, "https://checkout.razorpay.com/app/shopify/v1/payment/", false, 2, (Object) null)) {
                    return super.shouldInterceptRequest(webView, webResourceRequest);
                }
                Intent intent = new Intent();
                intent.putExtra("checkout_url", webResourceRequest.getUrl().toString());
                bf.i iVar = bf.i.a;
                magicXActivity.setResult(99002, intent);
                magicXActivity.finish();
                return null;
            }
            if (webView != null && (url = webView.getUrl()) != null) {
                z = magicXActivity.magicxLoaded;
                if (z && kotlin.text.j.F(url, "https://api.razorpay.com/v1/checkout/public?", false, 2, (Object) null)) {
                    magicXActivity.magicxLoaded = false;
                    magicXActivity.finish();
                    return null;
                }
                if (kotlin.text.j.F(url, "https://api.razorpay.com/v1/magic/order?", false, 2, (Object) null)) {
                    magicXActivity.dismissHalfTransparentPage();
                }
                StringBuilder sb2 = new StringBuilder();
                str = magicXActivity.storefrontUrl;
                if (str == null) {
                    Intrinsics.w("storefrontUrl");
                    str = null;
                }
                sb2.append(str);
                sb2.append("checkout?checkout");
                if (!kotlin.text.j.F(url, sb2.toString(), false, 2, (Object) null)) {
                    return super.shouldInterceptRequest(webView, webResourceRequest);
                }
                Intent intent2 = new Intent();
                intent2.putExtra("checkout_url", url);
                bf.i iVar2 = bf.i.a;
                magicXActivity.setResult(99002, intent2);
                magicXActivity.finish();
                return null;
            }
        }
        return super.shouldInterceptRequest(webView, webResourceRequest);
    }

    @Override
    public final boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
        Log.d("OVERRIDE", String.valueOf(webResourceRequest != null ? webResourceRequest.getUrl() : null));
        return super.shouldOverrideUrlLoading(webView, webResourceRequest);
    }
}