4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1

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


package com.m4399.gamecenter.plugin.main.controllers.web;

import android.content.Context;
import android.support.annotation.Keep;
import android.text.TextUtils;
import android.webkit.JavascriptInterface;
import com.framework.rxbus.RxBus;
import com.framework.rxbus.annotation.Subscribe;
import com.framework.rxbus.annotation.Tag;
import com.m4399.gamecenter.aidl.K;
import com.m4399.gamecenter.plugin.main.helpers.bi;
import com.m4399.gamecenter.plugin.main.widget.web.BaseWebViewLayout;
import com.m4399.gamecenter.plugin.main.widget.web.WebViewLayout;

public class RechargeJSInterface extends BaseJsInterface {
    public static final String INJECTED_RECHARGEAPI = "rechargeAPI";
    private static boolean chV;
    private RxBusHandler chU;

    public RechargeJSInterface(WebViewLayout webViewLayout, Context context) {
        super(webViewLayout, context);
    }

    @Override
    public void init(BaseWebViewLayout baseWebViewLayout, Context context) {
        super.init(baseWebViewLayout, context);
        this.chU = new RxBusHandler(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.chU.unregister();
        if (chV) {
            bi.destroyRecharge();
        }
    }

    @JavascriptInterface
    public void openRecharge(final String str) {
        if (this.mContext == null || TextUtils.isEmpty(str)) {
            return;
        }
        bi.loadPlugin(this.mContext, new com.m4399.gamecenter.plugin.main.manager.plugin.d() {
            @Override
            public void onCancel() {
            }

            @Override
            public void onSuccess() {
                bi.invokeRechargeMethod("openRecharge", RechargeJSInterface.this.mContext, str);
                boolean unused = RechargeJSInterface.chV = true;
            }
        });
    }

    public void rechargeComplete(String str) {
        if (this.mWebView != null) {
            this.mWebView.loadUrl("javascript:void function () {if(document.getElementById(\"4399h5pay\")!=undefined){var iframeWindow=document.getElementById(\"4399h5pay\").contentWindow;try{rechargeComplete(" + str + ")}catch(err){iframeWindow.postMessage(" + str + ",\"http://save.api.4399.com\")}}else{try{rechargeComplete(" + str + ")}catch(err){console.log(\"error\")}}}()");
        }
    }

    public static class RxBusHandler {
        private RechargeJSInterface chY;

        public RxBusHandler(RechargeJSInterface rechargeJSInterface) {
            this.chY = rechargeJSInterface;
            RxBus.register(this);
        }

        public void unregister() {
            RxBus.unregister(this);
        }

        @Keep
        @Subscribe(tags = {@Tag(K.rxbus.TAG_RECHARGE_COMPLETED)})
        public void onRechargeComplete(String str) {
            this.chY.rechargeComplete(str);
        }
    }
}