九游游戏中心HD v4.6.8.1版本的 MD5 值为:78c397802cc5ffdcc7f5502ede90502e

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


package cn.ninegame.hybird.api.bridge;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.FragmentActivity;
import android.support.v4.media.session.PlaybackStateCompat;
import android.text.Html;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import cn.ninegame.aegissdk.h5challenge.inter.H5NcScene;
import cn.ninegame.b.a.a;
import cn.ninegame.framework.NineGameClientApplication;
import cn.ninegame.framework.adapter.BaseActivityWrapper;
import cn.ninegame.gamemanager.activity.MainActivity;
import cn.ninegame.gamemanager.download.DownloadExecutor;
import cn.ninegame.gamemanager.download.ao;
import cn.ninegame.gamemanager.download.fragment.SpecialDownloadPage;
import cn.ninegame.gamemanager.download.model.pojo.DownloadRecord;
import cn.ninegame.gamemanager.game.base.pojo.Game;
import cn.ninegame.gamemanager.game.follow.model.InterestedGame;
import cn.ninegame.gamemanager.game.gamedetail.comment.CommentParameter;
import cn.ninegame.gamemanager.game.gameinfo.model.InstalledGamesManager;
import cn.ninegame.gamemanager.game.gift.MyGiftInfo;
import cn.ninegame.gamemanager.game.mygame.GameInfoExecutor;
import cn.ninegame.gamemanager.game.packagemanager.InstalledGameInfo;
import cn.ninegame.gamemanager.home.usercenter.model.pojo.TaskRewardInfo;
import cn.ninegame.gamemanager.home.usercenter.model.pojo.UserCenterInfo;
import cn.ninegame.gamemanager.home.usercenter.model.pojo.UserMemberInfo;
import cn.ninegame.gamemanager.startup.fragment.RemoteSplashFragment;
import cn.ninegame.gamemanagerhd.R;
import cn.ninegame.genericframework.basic.IResultListener;
import cn.ninegame.hybird.BaseTabFragment;
import cn.ninegame.library.b.b;
import cn.ninegame.library.dynamicconfig.DynamicConfig;
import cn.ninegame.library.imageloader.a;
import cn.ninegame.library.network.datadroid.requestmanager.Request;
import cn.ninegame.library.network.datadroid.requestmanager.RequestManager;
import cn.ninegame.library.network.net.model.Body;
import cn.ninegame.library.network.net.widget.CombineRequest;
import cn.ninegame.library.network.net.widget.CombineRequestInfo;
import cn.ninegame.library.stat.StatInfo;
import cn.ninegame.library.uilib.adapter.downloadbtn.DownLoadItemDataWrapper;
import cn.ninegame.library.uilib.adapter.slidingmenu.GalleryFragment;
import cn.ninegame.library.uilib.adapter.webFragment.BaseWebPageFragment;
import cn.ninegame.library.uilib.adapter.webFragment.SpecialPage;
import cn.ninegame.library.uilib.adapter.webFragment.WebDialogPage;
import cn.ninegame.library.util.am;
import cn.ninegame.library.util.au;
import cn.ninegame.library.util.bc;
import cn.ninegame.library.util.be;
import cn.ninegame.library.util.cb;
import cn.ninegame.library.util.cc;
import cn.ninegame.library.util.u;
import cn.ninegame.location.model.NGLocationInfo;
import cn.ninegame.modules.account.LoginInfo;
import cn.ninegame.modules.forum.fragment.LocalAlbumFragment;
import cn.ninegame.share.core.ShareParameter;
import cn.ninegame.sns.favorite.model.pojo.WebFavoriteParameterInfo;
import cn.ninegame.sns.user.info.model.pojo.UserGuest;
import cn.ninegame.sns.user.relationship.model.FollowUserResult;
import cn.uc.downloadlib.logic.DownloadCfgFile;
import com.UCMobile.Apollo.ApolloMetaData;
import com.sina.weibo.sdk.exception.WeiboAuthException;
import com.ta.utdid2.android.utils.NetworkUtils;
import com.tmall.applink.TMAppLinkSDK;
import com.tmall.applink.exception.TBAppLinkException;
import com.tmall.applink.param.TBDetailParam;
import com.tmall.applink.param.TBShopParam;
import com.tmall.applink.param.TBURIParam;
import com.tmall.applink.util.TBAppLinkPhoneUtil;
import com.tmall.applink.util.TBAppLinkUtil;
import com.uc.media.interfaces.IProxyHandler;
import com.uc.webview.export.WebView;
import com.uc.webview.export.internal.interfaces.IWaStat;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class NineGameClientJSBridge {
    public static final String[] f1735a = {cn.ninegame.framework.a.b.PAGE_TYPE_GUILD_MANAGER_GROUP, cn.ninegame.framework.a.b.PAGE_TYPE_GUILD_MANAGER_SETTING_INFO, cn.ninegame.framework.a.b.PAGE_TYPE_GUILD_MANAGER_NOTICE};
    private static final Pattern b = Pattern.compile("'", 8);
    private static final Map<String, Integer> c = new HashMap();

    public static void startupApp(WebView webView, JSONObject jSONObject) {
        try {
            if (cn.ninegame.library.util.g.b(NineGameClientApplication.a(), Game.getPkgName(jSONObject))) {
                cn.ninegame.library.stat.n.a(jSONObject, "btn_open", (String) null, (String) null, (String) null);
            }
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static void startDownloadApp(WebView webView, JSONObject jSONObject) {
        try {
            DownLoadItemDataWrapper parseJsonObject = DownLoadItemDataWrapper.parseJsonObject(jSONObject);
            if (parseJsonObject != null && !parseJsonObject.isContentNull()) {
                Bundle bundle = new Bundle();
                bundle.putParcelable("bundle_download_item_data_wrapper", parseJsonObject);
                bundle.putBoolean("bundle_download_check_before_download", true);
                cn.ninegame.genericframework.basic.g.a().b().a("download_start_download_app", bundle);
            }
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static void installApp(WebView webView, JSONObject jSONObject) {
        DownloadRecord b2 = ((cn.ninegame.gamemanager.download.model.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.download.model.a.class)).b(Game.getGameId(jSONObject), Game.getPkgName(jSONObject));
        if (b2 != null) {
            Bundle bundle = new Bundle();
            bundle.putParcelable("parcelable_val", b2);
            bundle.putInt("cmd", 6);
            cn.ninegame.framework.ipc.g.a().a(DownloadExecutor.class, null, bundle);
            cn.ninegame.library.stat.n.a(jSONObject, "btn_install", (String) null, (String) null, (String) null);
        }
    }

    public static void getCurDownloadingTasksAsync(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new b(cn.ninegame.library.i.a.b.j.IPC, jSONObject, webView));
    }

    public static void getPackageState(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new k(cn.ninegame.library.i.a.b.j.OTHER, jSONObject, webView));
    }

    public static void getAppInstalledInfo(WebView webView, JSONObject jSONObject) {
        String b2 = cc.b(jSONObject, "callbackId");
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new t(cn.ninegame.library.i.a.b.j.IPC, cc.b(jSONObject, InterestedGame.PACKAGE_NAME), new JSONObject(), webView, b2));
    }

    public static void startAppByUrl(WebView webView, JSONObject jSONObject) {
    }

    public static JSONObject b(JSONObject jSONObject) {
        long j;
        long j2 = 0;
        JSONObject jSONObject2 = new JSONObject();
        JSONObject jSONObject3 = new JSONObject();
        try {
            int gameId = Game.getGameId(jSONObject);
            jSONObject2.put("gameId", gameId);
            int gameType = Game.getGameType(jSONObject);
            if (gameType == 1) {
                String pkgName = Game.getPkgName(jSONObject);
                int versionCode = Game.getVersionCode(jSONObject);
                String str = cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g;
                String a2 = cn.ninegame.gamemanager.game.packagemanager.helper.b.a(gameId, pkgName, versionCode);
                cn.ninegame.gamemanager.download.model.a aVar = (cn.ninegame.gamemanager.download.model.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.download.model.a.class);
                DownloadRecord b2 = aVar.b(gameId, pkgName);
                if (b2 != null) {
                    long j3 = b2.downloadedBytes;
                    long j4 = b2.fileLength;
                    DownloadRecord c2 = aVar.c(gameId, pkgName);
                    if (c2 != null) {
                        j = c2.fileLength + j4;
                        j2 = j3 + c2.downloadedBytes;
                    } else {
                        j = j4;
                        j2 = j3;
                    }
                } else {
                    j = 0;
                }
                jSONObject3.put("network", str);
                jSONObject3.put("downloadedBytes", j2);
                jSONObject3.put("fileSize", j);
                jSONObject2.put("data", jSONObject3);
                jSONObject2.put(InterestedGame.PKG_NAME, pkgName);
                jSONObject2.put("state", a2);
            } else if (gameType == 2) {
                jSONObject2.put("state", "400");
            } else {
                jSONObject2.put("state", "1");
            }
            jSONObject3.put(InterestedGame.IS_FOLLOW, cn.ninegame.gamemanager.game.mygame.c.a().a(gameId));
            jSONObject3.put(DownloadRecord.KEY_ITEM_GAME_ICON, a(Game.getGameIcon(jSONObject)));
            jSONObject2.put("data", jSONObject3);
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        return jSONObject2;
    }

    public static JSONArray b(JSONArray jSONArray) {
        long j;
        String a2;
        long j2;
        if (jSONArray == null || jSONArray.length() == 0) {
            return null;
        }
        JSONArray jSONArray2 = new JSONArray();
        int[] iArr = new int[jSONArray.length()];
        for (int i = 0; i < jSONArray.length(); i++) {
            iArr[i] = Game.getGameId(cc.b(jSONArray, i));
        }
        HashMap<Integer, DownloadRecord> a3 = ((cn.ninegame.gamemanager.download.model.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.download.model.a.class)).a(iArr);
        HashMap<Integer, Boolean> a4 = cn.ninegame.gamemanager.game.mygame.c.a().b().a(iArr);
        int i2 = 0;
        while (true) {
            int i3 = i2;
            if (i3 >= jSONArray.length()) {
                return jSONArray2;
            }
            JSONObject jSONObject = new JSONObject();
            JSONObject jSONObject2 = new JSONObject();
            try {
                JSONObject b2 = cc.b(jSONArray, i3);
                int i4 = iArr[i3];
                jSONObject.put("gameId", i4);
                int gameType = Game.getGameType(b2);
                if (gameType == 1) {
                    String pkgName = Game.getPkgName(b2);
                    int versionCode = Game.getVersionCode(b2);
                    String str = cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g;
                    DownloadRecord downloadRecord = a3.get(Integer.valueOf(i4));
                    if (downloadRecord == null) {
                        j = 0;
                        a2 = cn.ninegame.gamemanager.game.packagemanager.helper.b.a(i4, pkgName, versionCode, -1, 0, 0);
                        j2 = 0;
                    } else {
                        long j3 = downloadRecord.downloadedBytes;
                        long j4 = downloadRecord.fileLength;
                        j = j3;
                        a2 = cn.ninegame.gamemanager.game.packagemanager.helper.b.a(i4, pkgName, versionCode, downloadRecord.downloadState, downloadRecord.versionCode, downloadRecord.errorState);
                        j2 = j4;
                    }
                    jSONObject2.put("network", str);
                    jSONObject2.put("downloadedBytes", j);
                    jSONObject2.put("fileSize", j2);
                    jSONObject.put("data", jSONObject2);
                    jSONObject.put(InterestedGame.PKG_NAME, pkgName);
                    jSONObject.put("state", a2);
                } else if (gameType == 2) {
                    jSONObject.put("state", "400");
                } else {
                    jSONObject.put("state", "1");
                }
                if (a4.get(Integer.valueOf(i4)) != null) {
                    jSONObject2.put(InterestedGame.IS_FOLLOW, true);
                } else {
                    jSONObject2.put(InterestedGame.IS_FOLLOW, false);
                }
                jSONObject2.put(DownloadRecord.KEY_ITEM_GAME_ICON, a(Game.getGameIcon(b2)));
                jSONObject.put("data", jSONObject2);
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.b(e);
            }
            jSONArray2.put(jSONObject);
            cn.ninegame.library.stat.b.b.a(jSONObject.toString(), new Object[0]);
            i2 = i3 + 1;
        }
    }

    private static String a(String str) {
        String b2 = cn.ninegame.library.imageloader.g.d().b(str);
        return b2 == null ? "" : b2;
    }

    public static void stopDownloadApp(WebView webView, JSONObject jSONObject) {
        Bundle bundle = new Bundle();
        bundle.putInt("game_id", Game.getGameId(jSONObject));
        bundle.putString("bundle_package_name", Game.getPkgName(jSONObject));
        bundle.putBoolean("bundle_should_callback_js", true);
        cn.ninegame.genericframework.basic.g.a().b().a("download_stop_download_app", bundle);
    }

    public static void setEnableTouchScrollForWebView(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            boolean optBoolean = jSONObject.optBoolean("flag");
            cn.ninegame.library.i.i.c(new aa("NineGameClientJSBridge[setEnableTouchScrollForWebView]", cn.ninegame.library.i.a.b.j.UI, (BaseWebPageFragment) ((cn.ninegame.library.b.a) webView).f1846a, optBoolean));
        }
    }

    @Deprecated
    public static void showMessage(WebView webView, JSONObject jSONObject) {
        try {
            cc.i(jSONObject.getString("msg"));
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static void showReportDialog(WebView webView, JSONObject jSONObject) {
        if (webView != null && jSONObject != null) {
            Bundle bundle = new Bundle();
            bundle.putString("jsonObject", jSONObject == null ? "" : jSONObject.toString());
            cn.ninegame.genericframework.basic.g.a().b().a("show_report_dialog", bundle);
        }
    }

    public static void setTabTitle(WebView webView, JSONObject jSONObject) {
        int i;
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            cn.ninegame.library.b.a aVar = (cn.ninegame.library.b.a) webView;
            BaseWebPageFragment baseWebPageFragment = (BaseWebPageFragment) aVar.f1846a;
            String optString = jSONObject.optString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE);
            if (jSONObject.has("index")) {
                i = jSONObject.optInt("index");
            } else {
                i = -1;
            }
            cn.ninegame.library.i.i.c(new ad("NineGameClientJSBridge[setTabTitle]", cn.ninegame.library.i.a.b.j.UI, i, baseWebPageFragment, optString, aVar));
        }
    }

    public static void switchTab(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            int b2 = cn.ninegame.library.util.l.b(jSONObject);
            String c2 = cn.ninegame.library.util.l.c(jSONObject);
            cn.ninegame.library.i.i.c(new ae("NineGameClientJSBridge[switchTab]", cn.ninegame.library.i.a.b.j.UI, c2, ((cn.ninegame.library.b.a) webView).f1846a, b2));
        }
    }

    public static void setSession(WebView webView, JSONObject jSONObject) {
        try {
            cn.ninegame.library.storage.a.a().a(jSONObject.getString("key"), jSONObject.getString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE));
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static String getSession(WebView webView, JSONObject jSONObject) {
        JSONException jSONException;
        String str;
        String str2 = null;
        boolean z = true;
        String str3 = "";
        try {
            String string = jSONObject.getString("key");
            str = cn.ninegame.library.storage.a.a().a(string);
            if (str != null) {
                try {
                    if (jSONObject.has("clearCache") && jSONObject.getBoolean("clearCache")) {
                        cn.ninegame.library.storage.a.a().b(string);
                    }
                    if (!jSONObject.has("callbackId")) {
                        return str;
                    }
                    str2 = jSONObject.getString("callbackId");
                } catch (JSONException e) {
                    jSONException = e;
                    z = false;
                    str3 = jSONException.getMessage();
                    cn.ninegame.library.stat.b.b.a(jSONException);
                    callbackJS((cn.ninegame.library.b.a) webView, str2, z, str3, str);
                    return "";
                }
            }
        } catch (JSONException e2) {
            jSONException = e2;
            str = null;
        }
        callbackJS((cn.ninegame.library.b.a) webView, str2, z, str3, str);
        return "";
    }

    public static void setPackageInfo(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            Bundle bundle = new Bundle();
            bundle.putString("json_value", jSONObject.toString());
            cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_webview_event_set_download_object", bundle));
        }
    }

    public static void addStat(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            cn.ninegame.library.stat.n.a(jSONObject, (String) null, (String) null, (String) null, (String) null);
        } else {
            cn.ninegame.library.stat.b.b.d("%s jsonObject is null or have no value mapped by 'key'", "JSBridge#");
        }
    }

    public static void addBehaviorStat(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            Iterator<String> keys = jSONObject.keys();
            ArrayList arrayList = new ArrayList();
            String str = null;
            String str2 = null;
            String str3 = null;
            while (keys.hasNext()) {
                String next = keys.next();
                if ("where".equals(next)) {
                    str3 = cc.b(jSONObject, "where");
                } else if ("doWhat".equals(next)) {
                    str = cc.b(jSONObject, "doWhat");
                } else if ("region".equals(next)) {
                    str2 = cc.b(jSONObject, "region");
                } else {
                    arrayList.add(next);
                    arrayList.add(cc.a(jSONObject, next, ""));
                }
            }
            String[] strArr = (String[]) arrayList.toArray(new String[0]);
            if (TextUtils.isEmpty(str3)) {
                cn.ninegame.library.stat.a.b.b().a(str, strArr);
            } else {
                cn.ninegame.library.stat.a.b.b().a(str3, str2, str, strArr);
            }
        }
    }

    public static void showSlideShow(WebView webView, JSONObject jSONObject) {
        Bundle bundle = null;
        if (jSONObject != null) {
            bundle = new Bundle();
            bundle.putString("args_jsonobject", jSONObject.toString());
        }
        cn.ninegame.genericframework.basic.g.a().b().c(GalleryFragment.class.getName(), bundle);
    }

    private static JSONObject a(WebView webView) {
        try {
            float f = webView.getResources().getDisplayMetrics().density;
            JSONObject jSONObject = new JSONObject();
            int width = webView.getWidth();
            int height = webView.getHeight();
            if (width == 0) {
                width = webView.getResources().getDisplayMetrics().widthPixels;
            }
            if (height == 0) {
                height = webView.getResources().getDisplayMetrics().heightPixels;
            }
            jSONObject.put("width", width / f);
            jSONObject.put("height", height / f);
            return jSONObject;
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
            return null;
        }
    }

    private static String c(JSONObject jSONObject) {
        cn.ninegame.b.a.a unused;
        try {
            StringBuilder sb = new StringBuilder();
            unused = a.C0021a.f309a;
            return am.a(sb.append(cn.ninegame.b.a.a.b()).append(jSONObject.getString("path")).toString(), jSONObject.getString("encoding"));
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
            return null;
        }
    }

    public static String readFile(WebView webView, JSONObject jSONObject) {
        try {
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        if (!jSONObject.has("callbackId")) {
            return c(jSONObject);
        }
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new af(cn.ninegame.library.i.a.b.j.IO, jSONObject, webView));
        return null;
    }

    public static void setWebViewState(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            try {
                if (!(webView instanceof cn.ninegame.library.b.a)) {
                    return;
                }
                cn.ninegame.framework.adapter.t tVar = new cn.ninegame.framework.adapter.t();
                tVar.f391a = jSONObject.optString("state");
                tVar.b = jSONObject.optString("errorType");
                tVar.c = jSONObject.optString("errorMsg");
                if (!TextUtils.isEmpty(tVar.f391a)) {
                    cn.ninegame.library.i.i.c(new ag("NineGameClientJSBridge[setWebViewState]", cn.ninegame.library.i.a.b.j.UI, tVar, webView));
                }
            } catch (Exception e) {
            }
        }
    }

    public static void setHitPageBottomThreshold(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            cn.ninegame.library.i.i.c(new ah("NineGameClientJSBridge[setHitPageBottomThreshold]", cn.ninegame.library.i.a.b.j.UI, webView, jSONObject.optInt("threshold")));
        }
    }

    public static void setNavTitle(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            cn.ninegame.library.b.a aVar = (cn.ninegame.library.b.a) webView;
            String optString = jSONObject.optString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE, "");
            aVar.i = optString;
            aVar.d(optString);
            cn.ninegame.library.i.i.c(new c("NineGameClientJSBridge[setNavTitle]", cn.ninegame.library.i.a.b.j.UI, (BaseWebPageFragment) aVar.f1846a, optString));
        }
    }

    public static void setConfig(WebView webView) {
    }

    public static String getConfig(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            try {
            } catch (JSONException e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
            if (jSONObject.has("key")) {
                String string = jSONObject.getString("key");
                if ("image_disabled".equals(string)) {
                    return "0";
                }
                if ("h5_api_server".equals(string)) {
                    String b2 = cn.ninegame.library.network.net.c.d.a(1).b();
                    String b3 = cn.ninegame.library.network.net.c.d.a(2).b();
                    String b4 = cn.ninegame.library.network.net.c.d.a(5).b();
                    String b5 = cn.ninegame.library.network.net.c.d.a(6).b();
                    JSONObject jSONObject2 = new JSONObject();
                    cc.b(jSONObject2, Body.CONST_CLIENT, b2);
                    cc.b(jSONObject2, "guild", b3);
                    cc.b(jSONObject2, "sns_api_server", b4);
                    cc.b(jSONObject2, "publicAccount", b5);
                    return jSONObject2.toString();
                } else if ("isSupportTrial".equals(string)) {
                    return (cc.h() && Build.VERSION.SDK_INT > 8 && cc.g()) ? "1" : "0";
                } else if ("activity_id".equals(string)) {
                    return getActivityId();
                } else {
                    if (!"console_filter".equals(string) && !"stat_filter".equals(string) && !"console_level".equals(string)) {
                        if ("client_api_server".equals(string)) {
                            return cn.ninegame.library.network.net.c.d.a(1).a();
                        }
                        if ("image_cache_dir".equals(string)) {
                            return "file://" + cn.ninegame.library.util.l.l(NineGameClientApplication.a()).getAbsolutePath();
                        }
                        if ("uninstall_level".equals(string)) {
                            return cn.ninegame.library.dynamicconfig.b.a().a(string);
                        }
                        if (Body.CONST_CLIENT_CHANNEL.equals(string)) {
                            return cn.ninegame.library.util.l.h(NineGameClientApplication.a());
                        }
                        if (!"network_type".equals(string)) {
                            if ("native_text_link_reg".equals(string)) {
                                JSONObject c2 = c();
                                if (c2 != null) {
                                    return c2.toString();
                                }
                                return null;
                            } else if ("support_h5_file_upload".equals(string)) {
                                return "1";
                            } else {
                                if ("support_new_page_type".equals(string)) {
                                    return b().toString();
                                }
                                return "{}";
                            }
                        }
                        return cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g;
                    }
                    return "";
                }
            }
        }
        JSONObject jSONObject3 = new JSONObject();
        if (cn.ninegame.gamemanager.startup.b.b.m.a().d().a("pref_no_images", false)) {
            jSONObject3.put("image_disabled", "1");
        } else {
            jSONObject3.put("image_disabled", "0");
        }
        jSONObject3.put(Body.CONST_CLIENT_CHANNEL, cn.ninegame.library.util.l.h(NineGameClientApplication.a()));
        jSONObject3.put("network_type", cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g);
        jSONObject3.put("h5_api_server", cn.ninegame.library.network.net.c.d.a(1).b());
        jSONObject3.put("isSupportTrial", (cc.h() && Build.VERSION.SDK_INT > 8 && cc.g()) ? "1" : "0");
        jSONObject3.put("activity_id", getActivityId());
        jSONObject3.put("console_filter", "");
        jSONObject3.put("stat_filter", "");
        jSONObject3.put("console_level", "");
        jSONObject3.put("client_api_server", cn.ninegame.library.network.net.c.d.a(1).a());
        jSONObject3.put("guild_api_server", cn.ninegame.library.network.net.c.d.a(2).a());
        jSONObject3.put("sns_api_server", cn.ninegame.library.network.net.c.d.a(5).b());
        jSONObject3.put("im_biz_server", cn.ninegame.library.network.net.c.d.a(3).b());
        jSONObject3.put("public_account_server", cn.ninegame.library.network.net.c.d.a(6).a());
        jSONObject3.put("image_cache_dir", "file://" + cn.ninegame.library.util.l.l(NineGameClientApplication.a()).getAbsolutePath());
        jSONObject3.put("uninstall_level", cn.ninegame.library.dynamicconfig.b.a().a("uninstall_level"));
        jSONObject3.put("native_text_link_reg", c());
        jSONObject3.put("support_h5_file_upload", "1");
        jSONObject3.put("support_new_page_type", b());
        cn.ninegame.library.stat.b.b.a(" %s getConfig json = %s", "JSBridge#", jSONObject3.toString());
        return jSONObject3.toString();
    }

    private static JSONArray b() {
        JSONArray jSONArray = new JSONArray();
        for (String str : f1735a) {
            jSONArray.put(str);
        }
        return jSONArray;
    }

    private static JSONObject c() {
        JSONObject a2 = cn.ninegame.library.util.d.b.a();
        cn.ninegame.library.f.h.a();
        cc.b(a2, "white_host", cn.ninegame.library.f.h.b());
        cn.ninegame.library.f.h.a();
        cc.b(a2, "black_host", cn.ninegame.library.f.h.c());
        cc.b(a2, "host_level", cn.ninegame.library.f.h.d());
        return a2;
    }

    public static String encryptDataSync(WebView webView, JSONObject jSONObject) {
        try {
            return Base64.encodeToString(cn.ninegame.library.f.f.a(jSONObject.getString("data").getBytes()), 0);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
            return null;
        }
    }

    public static String getPermissionDesc(WebView webView, JSONObject jSONObject) {
        try {
            JSONArray jSONArray = jSONObject.getJSONArray(InstalledGamesManager.MESSAGE_PARAMS_KEY_IDS);
            JSONObject jSONObject2 = new JSONObject();
            for (int i = 0; i < jSONArray.length(); i++) {
                jSONArray.getInt(i);
            }
            return jSONObject2.toString();
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
            return "{}";
        }
    }

    public static String getEnv(WebView webView, JSONObject jSONObject) {
        cn.ninegame.b.a.a aVar;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        String str = null;
        try {
            String string = jSONObject.getString("key");
            if (Body.CONST_CLIENT_UUID.equals(string)) {
                str = cn.ninegame.library.util.l.a();
            } else if ("imei".equals(string)) {
                str = be.d(a2);
            } else if (TBAppLinkPhoneUtil.IMSI.equals(string)) {
                str = be.a();
            } else if ("model".equals(string)) {
                str = Build.MODEL;
            } else if ("mac".equals(string)) {
                str = be.f(a2);
            } else if (!"network".equals(string)) {
                if ("apk_version".equals(string)) {
                    str = bc.c(a2);
                } else if ("version_code".equals(string)) {
                    str = bc.a(a2);
                } else if ("template_version".equals(string)) {
                    aVar = a.C0021a.f309a;
                    str = String.valueOf(aVar.f());
                } else if ("system_version".equals(string)) {
                    str = Build.VERSION.RELEASE;
                } else if ("cpu_cores".equals(string)) {
                    str = String.valueOf(cc.c());
                } else if (IWaStat.KEY_CPU_FREQ.equals(string)) {
                    str = String.valueOf(cc.d());
                } else if ("webview_real_width".equals(string)) {
                    str = String.valueOf(webView.getResources().getDisplayMetrics().widthPixels);
                } else if ("webview_real_height".equals(string)) {
                    str = String.valueOf(webView.getResources().getDisplayMetrics().heightPixels);
                } else if ("density".equals(string)) {
                    str = String.valueOf(webView.getResources().getDisplayMetrics().density);
                } else if ("webview_dimension_width".equals(string)) {
                    JSONObject a3 = a(webView);
                    if (a3 != null) {
                        str = String.valueOf(a3.get("width"));
                    }
                } else if ("webview_dimension_height".equals(string)) {
                    JSONObject a4 = a(webView);
                    if (a4 != null) {
                        str = String.valueOf(a4.get("height"));
                    }
                } else if ("ram_total".equals(string)) {
                    str = String.valueOf(am.e());
                } else if ("storage_external".equals(string)) {
                    str = String.valueOf(am.f());
                } else if ("storage_internal".equals(string)) {
                    str = String.valueOf(am.g());
                } else if ("storage_total".equals(string)) {
                    str = String.valueOf(am.h());
                } else if ("mode".equals(string)) {
                    str = !cn.ninegame.library.stat.b.b.a() ? "prod" : "dev";
                } else if (Body.CONST_CLIENT_CHANNEL.equals(string)) {
                    str = cn.ninegame.library.util.l.h(a2);
                } else if ("spread".equals(string)) {
                    str = String.valueOf(a2.getResources().getBoolean(R.bool.spread));
                } else if ("build".equals(string)) {
                    str = a2.getResources().getString(R.string.build);
                } else if ("app_name".equals(string)) {
                    str = a2.getResources().getString(R.string.app_name);
                } else if ("app_flag".equals(string)) {
                    str = a2.getResources().getString(R.string.server_app_flag);
                } else if (ApolloMetaData.KEY_IP.equals(string)) {
                    str = cc.i(a2);
                } else if ("memory".equals(string)) {
                    str = String.valueOf((cc.h(a2) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
                } else if ("mem_free".equals(string)) {
                    str = String.valueOf((cc.g(a2) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
                } else if (Body.CONST_CLIENT_UTDID.equals(string)) {
                    str = cn.ninegame.library.util.l.e(NineGameClientApplication.a());
                }
            } else {
                str = cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g;
            }
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        return str;
    }

    public static void setLotteryState(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new d(cn.ninegame.library.i.a.b.j.OTHER, cn.ninegame.library.i.a.b.k.LOWER));
    }

    public static void setGameDetailPageScroll(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            try {
                if (webView instanceof cn.ninegame.library.b.a) {
                    cn.ninegame.library.i.i.c(new e("NineGameClientJSBridge[setGameDetailPageScroll]", cn.ninegame.library.i.a.b.j.UI, webView, jSONObject.optBoolean("isDisable")));
                }
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.b(e);
            }
        }
    }

    public static void setNativeDefaultActionState(WebView webView, JSONObject jSONObject) {
    }

    public static void hackDestroyWebView(WebView webView) {
        if (webView instanceof cn.ninegame.library.b.a) {
            cn.ninegame.library.i.i.a(1000L, (cn.ninegame.library.i.a.b.i) new f("NineGameClientJSBridge[hackDestroyWebView]", cn.ninegame.library.i.a.b.j.UI, webView));
        }
    }

    public static void getSubscribeInfos(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new g(cn.ninegame.library.i.a.b.j.NETWORK, cn.ninegame.library.i.a.b.k.HIGHER, jSONObject, webView));
    }

    public static void getMyGiftInfos(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new h(cn.ninegame.library.i.a.b.j.NETWORK, webView, jSONObject));
    }

    public static void getFollowApps(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new i(cn.ninegame.library.i.a.b.j.IO, jSONObject, webView));
    }

    public static void getInstalledApp(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new j(cn.ninegame.library.i.a.b.j.IO, jSONObject, webView));
    }

    public static JSONObject handleSubscriResult(JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) {
        JSONObject jSONObject4;
        JSONObject jSONObject5;
        String string;
        String string2;
        boolean z;
        boolean z2 = true;
        JSONObject jSONObject6 = null;
        String str = "";
        try {
            jSONObject4 = jSONObject2.getJSONObject("giftInfo");
            if (jSONObject3.has("data")) {
                jSONObject6 = jSONObject3.getJSONObject("data");
                jSONObject.put("data", jSONObject6);
            }
            jSONObject5 = jSONObject3.getJSONObject("state");
            string = jSONObject5.getString("code");
            jSONObject.put("code", string);
        } catch (Exception e) {
            str = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
            z2 = false;
        }
        if (string.startsWith("200") && jSONObject4 != null) {
            if (jSONObject6 == null || !jSONObject6.has("getStartTime")) {
                string2 = "";
                z = true;
            } else {
                cn.ninegame.library.stat.b.b.a("%s resultjSON has getStartTime, begin to insert data to database", "JSBridge#");
                cn.ninegame.gamemanager.game.a.a.a a2 = cn.ninegame.gamemanager.game.gift.c.a(jSONObject4, jSONObject6);
                if (a2 != null) {
                    cn.ninegame.modules.account.f.a();
                    if (!cn.ninegame.modules.account.f.c() && a2 != null) {
                        ((cn.ninegame.gamemanager.game.a.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.a.a.class)).a(a2);
                    }
                    cn.ninegame.library.stat.n.a(jSONObject2, "bookgiftsuccess", (String) null, (String) null, (String) null);
                }
                return genCallbackJson(z2, str, jSONObject);
            }
        } else {
            string2 = jSONObject5.has("msg") ? jSONObject5.getString("msg") : "";
            z = false;
        }
        z2 = z;
        str = string2;
        return genCallbackJson(z2, str, jSONObject);
    }

    public static void subscribeGift(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.stat.b.b.a("%s subscribeGift webView: %d, jsonObject: %s", "JSBridge#", Integer.valueOf(webView.hashCode()), jSONObject);
        cn.ninegame.hybird.api.bridge.data.k kVar = new cn.ninegame.hybird.api.bridge.data.k((cn.ninegame.library.b.a) webView);
        try {
            kVar.e = new JSONObject();
            kVar.f1756a = jSONObject;
            if (jSONObject.has("callbackId")) {
                kVar.d = jSONObject.getString("callbackId");
            }
            JSONObject jSONObject2 = jSONObject.getJSONObject("giftInfo");
            kVar.e.put("sceneId", jSONObject2.getString("sceneId"));
            String string = jSONObject2.getString("sceneId");
            String d = be.d(NineGameClientApplication.a().getApplicationContext());
            if (d == null) {
                d = "";
            }
            cn.ninegame.library.network.net.d.c a2 = cn.ninegame.library.network.net.d.c.a();
            Request request = new Request(4001);
            request.setRequestPath("/api/op.ka.activity.subscribe");
            request.put("sceneId", string);
            request.put("imei", d);
            a2.a(request, kVar);
        } catch (JSONException e) {
            kVar.c = false;
            kVar.b = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static JSONObject handleUnsubscriResult(JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) {
        String message;
        boolean z;
        try {
            JSONObject jSONObject4 = jSONObject2.getJSONObject("giftInfo");
            JSONObject jSONObject5 = jSONObject3.getJSONObject("state");
            long a2 = cc.a(jSONObject4, "sceneId");
            jSONObject.put("sceneId", jSONObject4.getString("sceneId"));
            if (jSONObject5 != null && jSONObject5.has("code")) {
                jSONObject.put("code", jSONObject5.getString("code"));
                cn.ninegame.gamemanager.game.a.a aVar = (cn.ninegame.gamemanager.game.a.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.a.a.class);
                if (aVar.a("gift_id=?", new String[]{String.valueOf(a2)}) != null && aVar != null) {
                    aVar.a(a2);
                    cn.ninegame.gamemanager.game.netgame.a.b a3 = cn.ninegame.gamemanager.game.netgame.a.d.a();
                    if (a3 != null) {
                        a3.a(a2);
                    }
                }
                cn.ninegame.library.stat.n.a(jSONObject2, "btn_unbookgift", (String) null, (String) null, (String) null);
            }
            message = "";
            z = true;
        } catch (Exception e) {
            message = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
            z = false;
        }
        return genCallbackJson(z, message, jSONObject);
    }

    public static void notifyGiftChange(JSONObject jSONObject) {
        if (jSONObject != null) {
            JSONObject jSONObject2 = jSONObject.getJSONObject("data");
            String jSONObject3 = jSONObject2 == null ? "{}" : jSONObject2.toString();
            Bundle bundle = new Bundle();
            bundle.putString("json_value", jSONObject3);
            cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_gift_state_change", bundle));
        }
    }

    public static JSONObject handleGetGiftResult(JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) {
        JSONObject jSONObject4;
        JSONObject jSONObject5;
        JSONObject jSONObject6;
        String str;
        boolean z;
        cn.ninegame.gamemanager.game.gift.a aVar;
        boolean z2 = false;
        String str2 = "";
        try {
            jSONObject4 = jSONObject2.getJSONObject("giftInfo");
            if (jSONObject3.has("data")) {
                jSONObject5 = jSONObject3.getJSONObject("data");
                jSONObject.put("data", jSONObject5);
            } else {
                jSONObject5 = null;
            }
            jSONObject6 = jSONObject3.getJSONObject("state");
        } catch (Exception e) {
            str2 = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
        }
        if (jSONObject6 == null) {
            str = "";
            z = true;
        } else {
            String string = jSONObject6.getString("code");
            jSONObject.put("code", string);
            if (string.startsWith("200")) {
                MyGiftInfo a2 = cn.ninegame.gamemanager.game.gift.c.a(jSONObject4, false);
                if (a2 != null) {
                    a2.giftCode = jSONObject5 != null ? jSONObject5.toString() : null;
                    cn.ninegame.modules.account.f.a();
                    if (!cn.ninegame.modules.account.f.c() && (aVar = (cn.ninegame.gamemanager.game.gift.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.gift.a.class)) != null) {
                        aVar.a(a2);
                    }
                    cn.ninegame.library.stat.n.a(jSONObject2, "getgiftsuccess", (String) null, (String) null, (String) null);
                }
                z2 = true;
            } else if (string.equals("5000370") || string.equals("5000371")) {
                cn.ninegame.gamemanager.game.gift.getgift.controller.f.a(jSONObject2);
            } else {
                str = jSONObject6.has("msg") ? jSONObject6.getString("msg") : "";
                z = false;
            }
            return genCallbackJson(z2, str2, jSONObject);
        }
        z2 = z;
        str2 = str;
        return genCallbackJson(z2, str2, jSONObject);
    }

    public static void getGift(final WebView webView, final JSONObject jSONObject) {
        cn.ninegame.library.stat.b.b.a("%s getGift webView: %d, jsonObject: %s", "JSBridge#", Integer.valueOf(webView.hashCode()), jSONObject);
        cn.ninegame.gamemanager.game.gift.getgift.controller.f a2 = cn.ninegame.gamemanager.game.gift.getgift.controller.f.a();
        IResultListener iResultListener = new IResultListener() {
            @Override
            public final void onResult(Bundle bundle) {
                try {
                    jSONObject.put("bundle_install_state", bundle.getInt("bundle_install_state"));
                } catch (JSONException e) {
                }
                new cn.ninegame.hybird.api.bridge.data.g((cn.ninegame.library.b.a) webView, jSONObject).a();
                cn.ninegame.library.stat.a.b.b().a("游戏领取礼包", new String[0]);
            }
        };
        if (jSONObject != null) {
            a2.f881a.add(iResultListener);
            JSONObject optJSONObject = jSONObject.optJSONObject("giftInfo");
            if (!optJSONObject.optBoolean("needGame", true)) {
                Bundle bundle = new Bundle();
                bundle.putBoolean("result", true);
                bundle.putInt("bundle_install_state", 2);
                iResultListener.onResult(bundle);
                a2.f881a.remove(iResultListener);
                return;
            }
            int optInt = optJSONObject.optInt("gameId");
            ConcurrentHashMap<String, InstalledGameInfo> c2 = cn.ninegame.gamemanager.game.packagemanager.helper.a.a().c();
            if (c2 == null || c2.size() == 0) {
                Bundle bundle2 = new Bundle();
                bundle2.putInt("cmd", 6);
                if (!cn.ninegame.framework.ipc.g.a().a(GameInfoExecutor.class, new cn.ninegame.gamemanager.game.gift.getgift.controller.h(a2, optInt, iResultListener), bundle2)) {
                    a2.a(2, iResultListener);
                    cn.ninegame.library.stat.b.b.b("gift getInstall: ipc start fail", new Object[0]);
                    return;
                }
                Message obtain = Message.obtain();
                obtain.what = 0;
                obtain.obj = iResultListener;
                a2.b.sendMessageDelayed(obtain, DynamicConfig.DELAY_TIME);
                return;
            }
            a2.a(cn.ninegame.gamemanager.game.gift.getgift.controller.f.a(optInt, c2), iResultListener);
            cn.ninegame.library.stat.b.b.b("gift getInstall: do not need ipc", new Object[0]);
        }
    }

    public static void selectGameArea(final WebView webView, JSONObject jSONObject) {
        if (jSONObject == null || !jSONObject.has("gameInfo") || !jSONObject.has("giftInfo")) {
            cn.ninegame.genericframework.basic.g.a().b().a("msg_show_error_dialog", new Bundle());
            cn.ninegame.gamemanager.game.gift.a.a.a(0, "", null, "jsonError");
            return;
        }
        JSONObject optJSONObject = jSONObject.optJSONObject("gameInfo");
        JSONObject optJSONObject2 = jSONObject.optJSONObject("giftInfo");
        JSONObject optJSONObject3 = jSONObject.optJSONObject("statInfo");
        if (optJSONObject == null || optJSONObject2 == null) {
            cn.ninegame.genericframework.basic.g.a().b().a("msg_show_error_dialog", new Bundle());
            cn.ninegame.gamemanager.game.gift.a.a.a(0, "", null, "gameInfo");
            return;
        }
        Game parse = Game.parse(optJSONObject);
        int optInt = optJSONObject2.optInt("needLogin", 1);
        boolean optBoolean = optJSONObject2.optBoolean("needGame", true);
        int optInt2 = optJSONObject2.optInt("checkType", -1);
        String optString = optJSONObject2.optString("sceneId");
        if (parse == null || TextUtils.isEmpty(optString)) {
            cn.ninegame.genericframework.basic.g.a().b().a("msg_show_error_dialog", new Bundle());
            cn.ninegame.gamemanager.game.gift.a.a.a(0, "", null, "game");
            return;
        }
        String optString2 = optJSONObject3 != null ? optJSONObject3.optString("a1") : null;
        Bundle bundle = new Bundle();
        bundle.putParcelable("game", parse);
        bundle.putInt("needLogin", optInt);
        bundle.putBoolean("needGame", optBoolean);
        bundle.putInt("checkType", optInt2);
        bundle.putString("sceneId", optString);
        bundle.putString("a1", optString2);
        cn.ninegame.genericframework.basic.g.a().b().a("msg_select_game_area", bundle, new IResultListener() {
            @Override
            public final void onResult(Bundle bundle2) {
                if (bundle2 != null) {
                    cn.ninegame.hybird.api.bridge.a.b((cn.ninegame.library.b.a) WebView.this, "gift_get_notify", bundle2.getString("result"));
                }
            }
        });
    }

    private static MyGiftInfo d(JSONObject jSONObject) {
        try {
            MyGiftInfo myGiftInfo = new MyGiftInfo();
            cn.ninegame.gamemanager.game.gift.c.a(myGiftInfo, jSONObject);
            myGiftInfo.isTransfer = 1;
            myGiftInfo.pickupType = 0;
            return myGiftInfo;
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
            return null;
        }
    }

    public static JSONObject handleRegisterGiftResult(JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) {
        JSONObject jSONObject4;
        JSONObject jSONObject5;
        JSONObject jSONObject6;
        String str;
        boolean z;
        cn.ninegame.gamemanager.game.gift.a aVar;
        boolean z2 = true;
        String str2 = "";
        try {
            jSONObject4 = jSONObject2.getJSONObject("giftInfo");
            if (jSONObject3.has("data")) {
                jSONObject5 = jSONObject3.getJSONObject("data");
                jSONObject.put("data", jSONObject5);
            } else {
                jSONObject5 = null;
            }
            jSONObject6 = jSONObject3.getJSONObject("state");
        } catch (Exception e) {
            str2 = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
            z2 = false;
        }
        if (jSONObject6 == null) {
            str = "";
            z = true;
        } else {
            String string = jSONObject6.getString("code");
            jSONObject.put("code", string);
            if (string.startsWith("200")) {
                MyGiftInfo d = d(jSONObject4);
                if (d != null) {
                    d.giftCode = jSONObject5 != null ? jSONObject5.toString() : null;
                    cn.ninegame.modules.account.f.a();
                    if (!cn.ninegame.modules.account.f.c() && (aVar = (cn.ninegame.gamemanager.game.gift.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.gift.a.class)) != null) {
                        aVar.a(d);
                    }
                    cn.ninegame.library.stat.n.a(jSONObject2, "getgiftsuccess", (String) null, (String) null, (String) null);
                }
                return genCallbackJson(z2, str2, jSONObject);
            }
            str = jSONObject6.has("msg") ? jSONObject6.getString("msg") : "";
            z = false;
        }
        z2 = z;
        str2 = str;
        return genCallbackJson(z2, str2, jSONObject);
    }

    public static void openAccountCheckDialog(WebView webView, JSONObject jSONObject) {
        cn.ninegame.gamemanager.activity.a.a().a((String) null);
    }

    private static MyGiftInfo e(JSONObject jSONObject) {
        try {
            MyGiftInfo myGiftInfo = new MyGiftInfo();
            cn.ninegame.gamemanager.game.gift.c.a(myGiftInfo, jSONObject);
            myGiftInfo.pickupType = 1;
            return myGiftInfo;
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
            return null;
        }
    }

    public static JSONObject handledredgeGiftResult(JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) {
        String message;
        boolean z;
        JSONObject jSONObject4;
        try {
            JSONObject jSONObject5 = jSONObject2.getJSONObject("giftInfo");
            if (jSONObject3.has("data")) {
                jSONObject4 = jSONObject3.getJSONObject("data");
                jSONObject.put("data", jSONObject4);
            } else {
                jSONObject4 = null;
            }
            JSONObject jSONObject6 = jSONObject3.getJSONObject("state");
            String string = jSONObject6.getString("code");
            jSONObject.put("code", string);
            if (string.startsWith("200")) {
                jSONObject.put("giftName", "");
                MyGiftInfo e = e(jSONObject5);
                if (e != null) {
                    e.giftCode = jSONObject4 != null ? jSONObject4.toString() : null;
                    cn.ninegame.gamemanager.game.gift.a aVar = (cn.ninegame.gamemanager.game.gift.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.gift.a.class);
                    if (aVar != null) {
                        aVar.a(e.giftId);
                    }
                    if (aVar != null) {
                        aVar.a(e);
                    }
                    cn.ninegame.library.stat.n.a(jSONObject2, "btn_diggift", (String) null, (String) null, (String) null);
                }
                message = "";
                z = true;
            } else {
                message = jSONObject6.has("msg") ? jSONObject6.getString("msg") : "";
                z = false;
            }
        } catch (Exception e2) {
            message = e2.getMessage();
            cn.ninegame.library.stat.b.b.a(e2);
            z = false;
        }
        return genCallbackJson(z, message, jSONObject);
    }

    public static String readGiftInfo(WebView webView, JSONObject jSONObject) {
        MyGiftInfo a2;
        try {
            cn.ninegame.library.stat.b.b.a("%s call readGiftInfo", "JSBridge#");
            if (jSONObject != null) {
                long a3 = cc.a(jSONObject, "sceneId");
                int i = jSONObject.has("storeId") ? jSONObject.getInt("storeId") : 0;
                cn.ninegame.gamemanager.game.gift.a aVar = (cn.ninegame.gamemanager.game.gift.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.gamemanager.game.gift.a.class);
                if (i != 0) {
                    a2 = aVar.a("_id=?", new String[]{String.valueOf(i)}, null);
                } else {
                    a2 = aVar.a("gift_id=?", new String[]{String.valueOf(a3)}, "expired DESC, _id DESC");
                }
                if (a2 == null || a2.giftCode == null) {
                    return "";
                }
                return a2.giftCode;
            }
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        return "";
    }

    public static void openWindow(WebView webView, JSONObject jSONObject) {
        BaseTabFragment baseTabFragment;
        JSONObject jSONObject2 = null;
        boolean z = true;
        cn.ninegame.library.stat.b.b.a("%s openWindow jsonObject: %s", "JSBridge#", jSONObject);
        try {
            String optString = jSONObject.has("url") ? jSONObject.optString("url") : null;
            String optString2 = jSONObject.optString("default_url");
            JSONObject a2 = cn.ninegame.library.util.l.a(optString, false);
            JSONObject optJSONObject = jSONObject.has(WebFavoriteParameterInfo.PARAMS) ? jSONObject.optJSONObject(WebFavoriteParameterInfo.PARAMS) : new JSONObject();
            JSONObject optJSONObject2 = jSONObject.has("options") ? jSONObject.optJSONObject("options") : null;
            String originalUrl = webView != null ? webView.getOriginalUrl() : "";
            if (!TextUtils.isEmpty(originalUrl)) {
                jSONObject2 = new JSONObject();
                jSONObject2.put("Referer", originalUrl);
            }
            if (optJSONObject2 == null || !optJSONObject2.has("replace") || !optJSONObject2.getBoolean("replace")) {
                z = false;
            }
            if (z && (webView instanceof cn.ninegame.library.b.a) && (baseTabFragment = ((cn.ninegame.library.b.a) webView).f1846a) != null) {
                baseTabFragment.d_();
            }
            String a3 = cn.ninegame.library.util.l.a(optString, a2, jSONObject);
            cn.ninegame.library.stat.b.b.a("%s openWindow target: %s", "JSBridge#", a3);
            String lookupUrlWithParams = lookupUrlWithParams(optString, a2, optJSONObject);
            cn.ninegame.library.stat.b.b.a("%s openWindow url: %s", "JSBridge#", lookupUrlWithParams);
            if (!((lookupUrlWithParams == null || !lookupUrlWithParams.startsWith("http")) ? false : cn.ninegame.hybird.link.a.d.a(lookupUrlWithParams, "ref", webView.getUrl()))) {
                if (ShareParameter.FROM_CLIENT.equals(a3)) {
                    HashMap hashMap = new HashMap();
                    if (!TextUtils.isEmpty(originalUrl)) {
                        hashMap.put("Referer", originalUrl);
                    }
                    webView.loadUrl(lookupUrlWithParams, hashMap);
                    return;
                }
                Context context = webView.getContext();
                if ((context instanceof MainActivity) && (((MainActivity) context).a() instanceof RemoteSplashFragment)) {
                    if (!cn.ninegame.gamemanager.startup.b.b.z.a().f1517a) {
                        cc.i("初始化未完成,请稍后再试");
                        return;
                    }
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setAction("android.intent.action.MAIN");
                    intent.addFlags(335544320);
                    intent.putExtra("request", "request_jump_to_fragment");
                    intent.putExtra("page_type", a3);
                    intent.putExtra("destUrl", lookupUrlWithParams);
                    if (optJSONObject != null) {
                        intent.putExtra(WebFavoriteParameterInfo.PARAMS, optJSONObject.toString());
                    }
                    context.startActivity(intent);
                } else if ("blank".equals(a3)) {
                    Bundle bundle = new Bundle();
                    bundle.putString("url", lookupUrlWithParams);
                    bundle.putString("options", optJSONObject2.toString());
                    if (jSONObject.has("callbackId")) {
                        bundle.putString("callbackId", jSONObject.getString("callbackId"));
                    }
                    final BaseWebPageFragment baseWebPageFragment = (BaseWebPageFragment) ((cn.ninegame.library.b.a) webView).f1846a;
                    if (baseWebPageFragment == null) {
                        return;
                    }
                    baseWebPageFragment.a(WebDialogPage.class, bundle, new IResultListener() {
                        @Override
                        public void onResult(Bundle bundle2) {
                            if (bundle2 != null) {
                                String string = bundle2.getString("callbackId");
                                cn.ninegame.library.stat.b.b.b("AbstractWebPage# onActivityResult callbackId " + string, new Object[0]);
                                if (baseWebPageFragment.C != null && string != null) {
                                    Iterator it = baseWebPageFragment.C.iterator();
                                    while (it.hasNext()) {
                                        h hVar = (h) it.next();
                                        String string2 = bundle2.getString("callbackParam");
                                        cn.ninegame.library.stat.b.b.b("AbstractWebPage# onActivityResult param " + string2, new Object[0]);
                                        if (hVar != null && (hVar instanceof cn.ninegame.library.b.a)) {
                                            StringBuilder sb = new StringBuilder("if(window.JSBridge && JSBridge.onCallback) JSBridge.onCallback(");
                                            sb.append(string).append(',').append(string2).append(')');
                                            ((cn.ninegame.library.b.a) hVar).callJS(sb.toString());
                                        }
                                    }
                                }
                            }
                        }
                    });
                } else if ("system".equals(a3)) {
                    cn.ninegame.library.util.l.e(lookupUrlWithParams);
                } else if ("forum_timeline".equals(a3)) {
                    cn.ninegame.library.util.l.a(cn.ninegame.framework.a.b.PAGE_TYPE_FORUM_MSG_LIST, optJSONObject, lookupUrlWithParams);
                } else if ("account_switch".equals(a3)) {
                    webView.getContext();
                    cn.ninegame.library.util.l.e(optJSONObject);
                } else if ("video".equals(a3)) {
                    if (!TextUtils.isEmpty(lookupUrlWithParams)) {
                        if (lookupUrlWithParams.endsWith("mp4")) {
                            cn.ninegame.library.util.g.a(lookupUrlWithParams, cn.ninegame.library.util.g.c(lookupUrlWithParams));
                        } else {
                            cn.ninegame.library.util.g.b(lookupUrlWithParams);
                        }
                    }
                } else {
                    cn.ninegame.library.util.l.a(a3, optJSONObject, lookupUrlWithParams, optString2, jSONObject2);
                }
            }
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
    }

    public static void openShopDetail(WebView webView, JSONObject jSONObject) {
        JSONObject e = cc.e(jSONObject, "paramHome");
        JSONObject e2 = cc.e(jSONObject, "paramDetail");
        Bundle f = f(e);
        Bundle f2 = f(e2);
        cn.ninegame.genericframework.basic.g.a().b().a(new String[]{SpecialPage.class.getName(), SpecialDownloadPage.class.getName()}, new Bundle[]{f, f2});
    }

    private static Bundle f(JSONObject jSONObject) {
        String b2 = cc.b(jSONObject, "url");
        JSONObject e = cc.e(jSONObject, WebFavoriteParameterInfo.PARAMS);
        JSONObject a2 = cn.ninegame.library.util.l.a(b2, false);
        Bundle bundle = new Bundle();
        if (e != null) {
            b2 = lookupUrlWithParams(b2, a2, e);
            bundle.putString("h5Params", e.toString());
        }
        bundle.putString("url", b2);
        return bundle;
    }

    public static void shareOpenPage(WebView webView, JSONObject jSONObject) {
        JSONObject e = cc.e(jSONObject, "shareInfo");
        if (e != null) {
            String optString = e.optString(cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL);
            if (!TextUtils.isEmpty(optString)) {
                JSONObject jSONObject2 = new JSONObject();
                JSONObject jSONObject3 = new JSONObject();
                cc.a(jSONObject3, "default_url", (Object) e.optString("defaultRomoteUrl"));
                cc.a(jSONObject3, "share_type", (Object) e.optString(cn.ninegame.share.core.g.SHARE_TYPE));
                cc.a(jSONObject2, WebFavoriteParameterInfo.PARAMS, (Object) jSONObject3);
                cc.a(jSONObject2, "url", (Object) optString);
                if (optString.startsWith("http")) {
                    cc.a(jSONObject2, cn.ninegame.framework.a.b.KEY_TARGET, (Object) cn.ninegame.library.util.l.a(optString, (JSONObject) null, (JSONObject) null, cn.ninegame.framework.a.b.PAGE_TYPE_BROWSER));
                }
                openWindow(webView, jSONObject2);
            }
        }
    }

    public static String lookupUrlWithParams(String str, JSONObject jSONObject, JSONObject jSONObject2) {
        cn.ninegame.b.a.a unused;
        if (str != null) {
            cn.ninegame.b.a.g a2 = cn.ninegame.b.a.g.a();
            if (jSONObject != null) {
                try {
                    JSONArray names = jSONObject.names();
                    if (names != null) {
                        int length = names.length();
                        for (int i = 0; i < length; i++) {
                            String string = names.getString(i);
                            jSONObject2.put(string, jSONObject.getString(string));
                        }
                    }
                } catch (JSONException e) {
                    cn.ninegame.library.stat.b.b.a(e);
                }
            }
            if (str.startsWith("/")) {
                StringBuilder sb = new StringBuilder();
                unused = a.C0021a.f309a;
                str = sb.append(cn.ninegame.b.a.a.b()).append(str).toString();
            }
            int indexOf = str.indexOf("?");
            if (indexOf != -1) {
                str = str.substring(0, indexOf);
            }
            String str2 = str + cn.ninegame.library.util.l.a(jSONObject2);
            if (str2.startsWith("/")) {
                str2 = "file://" + str2;
            }
            return a2.a(str2);
        }
        return str;
    }

    public static void closeWindow(WebView webView, JSONObject jSONObject) {
        if (webView instanceof cn.ninegame.library.b.a) {
            BaseWebPageFragment baseWebPageFragment = (BaseWebPageFragment) ((cn.ninegame.library.b.a) webView).f1846a;
            Bundle c_ = baseWebPageFragment.c_();
            if (c_ != null) {
                c_.putString("callbackParam", jSONObject.toString());
            }
            baseWebPageFragment.w();
        }
    }

    public static void finishWindow(WebView webView) {
        Activity a2 = cn.ninegame.genericframework.basic.g.a().b().a();
        if (a2 != null && !a2.isFinishing()) {
            a2.finish();
        }
    }

    public static void callMessageFunction(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            try {
                String optString = jSONObject.optString("num");
                String optString2 = jSONObject.optString("message");
                Intent intent = new Intent("android.intent.action.SENDTO", Uri.parse("smsto:" + optString));
                intent.putExtra("sms_body", optString2);
                webView.getContext().startActivity(intent);
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.d("%s could not get data from webview :%s , %s", "JSBridge#", jSONObject, e);
            }
        }
    }

    @SuppressLint({"NewApi"})
    public static void setClipboard(WebView webView, JSONObject jSONObject) {
        try {
            String string = jSONObject.has(TaskRewardInfo.KEY_CONTRIBUTION_VALUE) ? jSONObject.getString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE) : null;
            if (string != null) {
                if (Build.VERSION.SDK_INT >= 11) {
                    ((ClipboardManager) webView.getContext().getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText(null, string.trim()));
                } else {
                    ((android.text.ClipboardManager) webView.getContext().getSystemService("clipboard")).setText(string.trim());
                }
            }
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.d("%s could not get data from webview :%s , %s", "JSBridge#", jSONObject, e);
        }
    }

    @SuppressLint({"NewApi"})
    public static String getClipboard(WebView webView) {
        CharSequence text;
        if (Build.VERSION.SDK_INT >= 11) {
            ClipboardManager clipboardManager = (ClipboardManager) webView.getContext().getSystemService("clipboard");
            if (!clipboardManager.hasPrimaryClip()) {
                return "";
            }
            ClipData primaryClip = clipboardManager.getPrimaryClip();
            ClipData.Item itemAt = primaryClip.getItemAt(0);
            if (primaryClip.getDescription().hasMimeType("text/plain") && (text = itemAt.getText()) != null) {
                text.toString();
            }
            return itemAt.coerceToText(webView.getContext()).toString();
        }
        return ((android.text.ClipboardManager) webView.getContext().getSystemService("clipboard")).getText().toString().trim();
    }

    public static void followUser(final WebView webView, final JSONObject jSONObject) {
        final String optString = jSONObject.optString("callbackId");
        Bundle bundle = new Bundle();
        bundle.putLong("targetUcid", jSONObject.optLong("targetUcid"));
        cn.ninegame.genericframework.basic.g.a().b().a("sns_relationship_follow_user_add", bundle, new IResultListener() {
            @Override
            public final void onResult(Bundle bundle2) {
                boolean z = bundle2.getBoolean("result");
                FollowUserResult followUserResult = (FollowUserResult) bundle2.getParcelable("key_bundle_relationship_result");
                JSONObject jSONObject2 = new JSONObject();
                try {
                    jSONObject2.put("ucid", jSONObject.optLong("targetUcid"));
                    jSONObject2.put("status", followUserResult.getFollowStatus());
                    jSONObject2.put("statusCode", followUserResult.code);
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) webView, optString, z, followUserResult == null ? "" : followUserResult.msg, jSONObject2);
                } catch (JSONException e) {
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) webView, optString, z, followUserResult == null ? "" : followUserResult.msg, jSONObject2);
                } catch (Throwable th) {
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) webView, optString, z, followUserResult == null ? "" : followUserResult.msg, jSONObject2);
                    throw th;
                }
            }
        });
    }

    public static void followApp(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new l(cn.ninegame.library.i.a.b.j.OTHER, jSONObject, webView));
    }

    public static void searchPopularSuggestion(WebView webView, JSONObject jSONObject) {
        String optString = jSONObject.optString("keyword");
        if (!TextUtils.isEmpty(optString)) {
            Bundle bundle = new Bundle();
            bundle.putString("keyword", optString);
            cn.ninegame.genericframework.basic.g.a().b().a(new cn.ninegame.genericframework.basic.r("search_action_popular_suggestion", bundle));
        }
    }

    public static void unfollowApp(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new n(cn.ninegame.library.i.a.b.j.OTHER, cn.ninegame.library.i.a.b.k.HIGHER, jSONObject, webView));
    }

    public static String isFollowApp(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            return cn.ninegame.gamemanager.game.mygame.c.a().a(Game.getGameId(jSONObject)) ? "true" : "";
        }
        return "";
    }

    public static void sendRequest(WebView webView, JSONObject jSONObject) {
        DataApi(webView, jSONObject);
    }

    public static void setCache(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new p(cn.ninegame.library.i.a.b.j.OTHER, jSONObject));
        }
    }

    public static String getCache(WebView webView, JSONObject jSONObject) {
        String str = "";
        if (jSONObject != null) {
            cn.ninegame.library.storage.cache.c a2 = cn.ninegame.library.storage.cache.c.a();
            String str2 = null;
            try {
                if (jSONObject.has("key")) {
                    str2 = jSONObject.getString("key");
                }
                if (str2 != null) {
                    str = a2.c(str2);
                    if (jSONObject.has("clearCache") && jSONObject.getBoolean("clearCache")) {
                        a2.d(str2);
                    }
                }
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
        }
        return str;
    }

    public static void setPageActionStat(WebView webView, JSONObject jSONObject) {
        if (jSONObject.has(TaskRewardInfo.KEY_CONTRIBUTION_VALUE)) {
            try {
                cn.ninegame.library.stat.b.b.a("%s setPageActionStat: %s", "JSBridge#", jSONObject.getString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE));
                cn.ninegame.gamemanager.startup.b.b.m.a().d().b("open_game_detail_page_from_which_page", jSONObject.getString(TaskRewardInfo.KEY_CONTRIBUTION_VALUE));
            } catch (JSONException e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
        }
    }

    public static JSONObject genCallbackJsonForSocketService(boolean z, String str, Object obj) {
        JSONObject jSONObject = new JSONObject();
        try {
            String c2 = cn.ninegame.library.util.l.c(NineGameClientApplication.a());
            if (obj != null && (obj instanceof JSONObject)) {
                ((JSONObject) obj).put("versionName", c2);
            } else {
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("versionName", c2);
                obj = jSONObject2;
            }
            return genCallbackJson(z, str, obj);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.b(e);
            return jSONObject;
        }
    }

    public static JSONObject genCallbackJson(boolean z, String str, Object obj) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("data", obj);
            jSONObject.put("result", z);
            jSONObject.put("msg", str);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.b(e);
        }
        return jSONObject;
    }

    public static void callbackJS(cn.ninegame.library.b.a aVar, String str, boolean z, String str2, Object obj) {
        if (str != null) {
            JSONObject genCallbackJson = genCallbackJson(z, str2, obj);
            cn.ninegame.library.stat.b.b.a("%s callbackJS callbackId %s %s ", "JSBridge#", str, genCallbackJson);
            cn.ninegame.hybird.api.bridge.a.a(aVar, str, genCallbackJson);
        }
    }

    public static void callbackJS(cn.ninegame.library.b.a aVar, JSONObject jSONObject, boolean z, String str, Object obj) {
        callbackJS(aVar, cc.b(jSONObject, "callbackId"), z, str, obj);
    }

    public static int getPlayType(JSONObject jSONObject) {
        if (jSONObject != null) {
            return Game.getGameType(jSONObject);
        }
        return -1;
    }

    public static void registerEvent(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            try {
                String string = jSONObject.has("type") ? jSONObject.getString("type") : null;
                Object obj = jSONObject.has(WebFavoriteParameterInfo.PARAMS) ? jSONObject.get(WebFavoriteParameterInfo.PARAMS) : null;
                if (string == null || string.length() <= 0) {
                    return;
                }
                ((cn.ninegame.b.h.a) ((cn.ninegame.library.b.a) webView)).e.put(string, obj);
            } catch (JSONException e) {
            }
        }
    }

    public static void unregisterEvent(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            try {
                ((cn.ninegame.b.h.a) ((cn.ninegame.library.b.a) webView)).e.remove(jSONObject.getString("type"));
            } catch (JSONException e) {
            }
        }
    }

    public static void triggerEvent(WebView webView, JSONObject jSONObject) {
        String b2 = cc.b(jSONObject, "type");
        String b3 = cc.b(jSONObject, "data");
        Bundle bundle = new Bundle();
        bundle.putString("event_type", b2);
        if (b3 != null) {
            bundle.putString("event_data", b3.toString());
        }
        cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_webview_event_triggered", bundle));
        if (!TextUtils.isEmpty(b2)) {
            if ("guild_quit".equals(b2) || "guild_join".equals(b2)) {
                if ("guild_quit".equals(b2)) {
                    cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("guild_state_quit"));
                }
                Bundle bundle2 = new Bundle();
                bundle2.putInt("state", "guild_quit".equals(b2) ? 0 : 1);
                cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("guild_state_change", bundle2));
            } else if ("dismiss_pay_loading".equals(b2)) {
                cn.ninegame.genericframework.basic.g.a().b().a("pay_complete_dismiss_loading");
            }
        }
    }

    public static void downloadImage(WebView webView, JSONObject jSONObject) {
        String str;
        String str2;
        Uri uri;
        Exception e;
        try {
            str2 = jSONObject.getString("callbackId");
            try {
                str = jSONObject.getString("url");
                try {
                    uri = Uri.parse(str);
                } catch (Exception e2) {
                    uri = null;
                    e = e2;
                }
            } catch (Exception e3) {
                str = null;
                e = e3;
                uri = null;
            }
        } catch (Exception e4) {
            str = null;
            str2 = null;
            uri = null;
            e = e4;
        }
        try {
            cn.ninegame.library.stat.b.b.a("%s downloadImage url: %s", "JSBridge#", str);
        } catch (Exception e5) {
            e = e5;
            cn.ninegame.library.stat.b.b.a(e);
            if (!(webView instanceof cn.ninegame.library.b.a)) {
            }
        }
        if (!(webView instanceof cn.ninegame.library.b.a)) {
            String scheme = uri == null ? "" : uri.getScheme();
            if (uri != null && "http".equalsIgnoreCase(scheme)) {
                cn.ninegame.library.imageloader.g.d().a(str, new a(str2, str, (cn.ninegame.library.b.a) webView));
            } else if (str2 != null) {
                cn.ninegame.hybird.api.bridge.a.a((cn.ninegame.library.b.a) webView, str2, genCallbackJson(false, "url error:" + str, ""));
            }
        }
    }

    static class a implements a.InterfaceC0063a {
        final String f1736a;
        final String b;
        final WeakReference<cn.ninegame.library.b.a> c;

        public a(String str, String str2, cn.ninegame.library.b.a aVar) {
            this.f1736a = str;
            this.b = str2;
            this.c = new WeakReference<>(aVar);
        }

        @Override
        public final void a(String str, String str2) {
            if (this.f1736a != null) {
                try {
                    JSONObject jSONObject = new JSONObject();
                    if (TextUtils.isEmpty(str2)) {
                        jSONObject.put("path", str);
                    } else {
                        jSONObject.put("path", str2);
                    }
                    JSONObject genCallbackJson = NineGameClientJSBridge.genCallbackJson(true, "", jSONObject);
                    cn.ninegame.library.b.a aVar = this.c.get();
                    if (aVar != null) {
                        cn.ninegame.hybird.api.bridge.a.a(aVar, this.f1736a, genCallbackJson);
                    }
                } catch (JSONException e) {
                }
            }
        }

        @Override
        public final void a() {
            if (this.f1736a != null) {
                JSONObject genCallbackJson = NineGameClientJSBridge.genCallbackJson(false, "url error:" + this.b, "");
                cn.ninegame.library.b.a aVar = this.c.get();
                if (aVar != null) {
                    cn.ninegame.hybird.api.bridge.a.a(aVar, this.f1736a, genCallbackJson);
                }
            }
        }
    }

    public static void checkClientUpdate(WebView webView) {
        new cn.ninegame.gamemanager.upgrade.i(webView.getContext()).a(false);
    }

    public static void checkClientUpdate(WebView webView, JSONObject jSONObject) {
        boolean z = false;
        if (jSONObject != null) {
            if (jSONObject != null && jSONObject.has("showDialog")) {
                z = jSONObject.optBoolean("showDialog", false);
            }
            new cn.ninegame.gamemanager.upgrade.i(webView.getContext()).a(z);
        }
    }

    public static void login(final WebView webView, JSONObject jSONObject) {
        boolean z = false;
        if (jSONObject != null) {
            final String optString = jSONObject.optString("callbackId");
            Bundle bundle = new Bundle();
            try {
                JSONObject optJSONObject = jSONObject.optJSONObject("loginInfo");
                JSONObject optJSONObject2 = jSONObject.optJSONObject("statInfo");
                bundle.putInt("login_from", 2);
                bundle.putString("title", optJSONObject.optString("title"));
                bundle.putString("type", optJSONObject.optString("type"));
                bundle.putString("content", optJSONObject.optString("content"));
                bundle.putString("account_type", optJSONObject.optString("accountType"));
                bundle.putString("account", optJSONObject.optString("account"));
                bundle.putString("tag", optJSONObject.optString("tag"));
                z = optJSONObject.optBoolean("auto_login", false);
                bundle.putBoolean("auto_login", z);
                bundle.putString("service_ticket", optJSONObject.optString("serviceTicket"));
                bundle.putString("cluster_code", optJSONObject.optString("clusterCode"));
                bundle.putInt("login_callback_style", 2);
                StatInfo statInfo = new StatInfo();
                statInfo.a1 = optJSONObject2.optString("a1");
                bundle.putParcelable("stat_info", statInfo);
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
            final cn.ninegame.library.uilib.generic.u uVar = null;
            if (z) {
                uVar = cc.f(cn.ninegame.genericframework.basic.g.a().b().a(), NineGameClientApplication.a().getResources().getString(R.string.account_logining));
            }
            cn.ninegame.genericframework.basic.g.a().b().a("msg_account_login", bundle, new IResultListener() {
                @Override
                public final void onResult(Bundle bundle2) {
                    if (cn.ninegame.library.uilib.generic.u.this != null && bundle2.containsKey("call_back")) {
                        if ("will_request_method".equals(bundle2.get("call_back"))) {
                            cc.b(cn.ninegame.library.uilib.generic.u.this);
                        } else if ("will_callback_method".equals(bundle2.get("call_back"))) {
                            cc.a(cn.ninegame.library.uilib.generic.u.this);
                        }
                    }
                    boolean z2 = bundle2.getBoolean("result");
                    String string = bundle2.getString("message");
                    JSONObject jSONObject2 = null;
                    try {
                        jSONObject2 = new JSONObject(bundle2.getString("json_data"));
                    } catch (Exception e2) {
                        cn.ninegame.library.stat.b.b.b(e2);
                    }
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) webView, optString, z2, string, jSONObject2);
                }
            });
        }
    }

    public static void switchAccount(final WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            final String optString = jSONObject.optString("callbackId");
            Bundle bundle = new Bundle();
            try {
                JSONObject optJSONObject = jSONObject.optJSONObject("loginInfo");
                JSONObject optJSONObject2 = jSONObject.optJSONObject("statInfo");
                bundle.putInt("login_from", 2);
                bundle.putString("title", optJSONObject.optString("title"));
                bundle.putString("switchinfo_title", optJSONObject.optString("title"));
                bundle.putString("type", optJSONObject.optString("type"));
                bundle.putString("content", optJSONObject.optString("content"));
                bundle.putString("account_type", optJSONObject.optString("accountType"));
                bundle.putString("account", optJSONObject.optString("account"));
                bundle.putString("tag", optJSONObject.optString("tag"));
                String optString2 = optJSONObject.optString("content");
                if (!TextUtils.isEmpty(optString2)) {
                    bundle.putCharSequence("switchinfo_message", Html.fromHtml(optString2));
                } else {
                    String optString3 = optJSONObject.optString("nickName");
                    bundle.putString("switchinfo_nick_name", optString3);
                    String str = "";
                    UserCenterInfo b2 = cn.ninegame.modules.account.f.a().b();
                    if (b2 != null && b2.userInfo != null && !TextUtils.isEmpty(b2.userInfo.userName)) {
                        str = b2.userInfo.userName;
                    }
                    bundle.putCharSequence("switchinfo_message", cn.ninegame.library.util.l.c(str, optString3));
                }
                bundle.putString("service_ticket", optJSONObject.optString("serviceTicket"));
                bundle.putString("cluster_code", optJSONObject.optString("clusterCode"));
                bundle.putInt("login_callback_style", 2);
                StatInfo statInfo = new StatInfo();
                statInfo.a1 = optJSONObject2.optString("a1");
                bundle.putParcelable("stat_info", statInfo);
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
            cn.ninegame.genericframework.basic.g.a().b().a("msg_account_switch_account_from_switch_account_info", bundle, new IResultListener() {
                @Override
                public final void onResult(Bundle bundle2) {
                    boolean z = bundle2.getBoolean("result");
                    String string = bundle2.getString("message");
                    JSONObject jSONObject2 = null;
                    try {
                        jSONObject2 = new JSONObject(bundle2.getString("json_data"));
                    } catch (Exception e2) {
                        cn.ninegame.library.stat.b.b.b(e2);
                    }
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) WebView.this, optString, z, string, jSONObject2);
                }
            });
        }
    }

    public static String getAccountInfo(WebView webView) {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        try {
            cn.ninegame.modules.account.f.a();
            if (cn.ninegame.modules.account.f.c()) {
                cn.ninegame.modules.account.f.a();
                jSONObject2.put(Body.CONST_CLIENT_SID, cn.ninegame.modules.account.f.f());
                cn.ninegame.modules.account.f.a();
                jSONObject2.put("ucid", cn.ninegame.modules.account.f.d());
                jSONObject2.put("nickName", cn.ninegame.modules.account.f.a().l());
                cn.ninegame.modules.account.f.a();
                jSONObject2.put("serviceTicket", cn.ninegame.modules.account.f.h());
            }
            jSONObject.put("data", jSONObject2);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        cn.ninegame.library.stat.b.b.a("%s body: %s", "JSBridge#", jSONObject);
        return jSONObject.toString();
    }

    public static void popCommentDialog(cn.ninegame.library.b.a aVar, JSONObject jSONObject) {
        CommentParameter commentParameter = null;
        if (jSONObject == null) {
            return;
        }
        if (jSONObject != null) {
            CommentParameter commentParameter2 = new CommentParameter();
            JSONObject optJSONObject = jSONObject.optJSONObject("gameInfo");
            if (optJSONObject != null) {
                commentParameter2.gameId = optJSONObject.optString("gameId", WeiboAuthException.DEFAULT_AUTH_ERROR_CODE);
                commentParameter2.gameVersion = optJSONObject.optString("gameVersion", "");
                JSONObject optJSONObject2 = jSONObject.optJSONObject("statInfo");
                if (optJSONObject2 != null) {
                    commentParameter2.statInfo = new StatInfo();
                    commentParameter2.statInfo.action = optJSONObject2.optString("action", "");
                    commentParameter2.statInfo.a1 = optJSONObject2.optString("a1", "");
                    commentParameter2.statInfo.a2 = optJSONObject2.optString("a2", "");
                    commentParameter2.statInfo.a3 = optJSONObject2.optString("a3", "");
                }
                commentParameter = commentParameter2;
            }
        }
        if (commentParameter != null) {
            commentParameter.type = CommentParameter.a.SCORE_COMMENT.ordinal();
            cn.ninegame.library.stat.a.j.b().a(commentParameter.statInfo.action, commentParameter.statInfo.a1, commentParameter.gameId, "");
            cn.ninegame.library.util.v.a(aVar, commentParameter);
        }
    }

    public static void popCommentReplyDialog(WebView webView, JSONObject jSONObject) {
        CommentParameter commentParameter;
        if (jSONObject == null) {
            return;
        }
        if (jSONObject == null) {
            commentParameter = null;
        } else {
            commentParameter = new CommentParameter();
            commentParameter.gameId = jSONObject.optString("gameId", WeiboAuthException.DEFAULT_AUTH_ERROR_CODE);
            commentParameter.rootId = jSONObject.optString("commentId", "");
            commentParameter.nickName = jSONObject.optString("nickName", "");
            JSONObject optJSONObject = jSONObject.optJSONObject("statInfo");
            if (optJSONObject != null) {
                commentParameter.statInfo = new StatInfo();
                commentParameter.statInfo.action = optJSONObject.optString("action", "");
                commentParameter.statInfo.a1 = optJSONObject.optString("a1", "");
                commentParameter.statInfo.a2 = optJSONObject.optString("a2", "");
                commentParameter.statInfo.a3 = optJSONObject.optString("a3", "");
            }
        }
        if (commentParameter != null) {
            commentParameter.type = CommentParameter.a.REPLY_COMMENT.ordinal();
            if (commentParameter.statInfo != null) {
                cn.ninegame.library.stat.a.j.b().a(commentParameter.statInfo.action, commentParameter.statInfo.a1, commentParameter.gameId, "");
            }
            if (webView instanceof cn.ninegame.library.b.a) {
                cn.ninegame.library.util.v.a((cn.ninegame.library.b.a) webView, commentParameter);
            }
        }
    }

    public static void share(WebView webView, JSONObject jSONObject) {
        ShareParameter g = g(jSONObject);
        if (g != null && g.getStatInfo() != null && TextUtils.isEmpty(g.getStatInfo().action)) {
            StatInfo statInfo = g.getStatInfo();
            statInfo.action = "btn_share";
            g.setStatInfo(statInfo);
            g.setStatAction(cn.ninegame.share.core.g.SHARE_STAT_IM, "btn_myfrishare`qt_fxtc``");
        }
        cn.ninegame.share.core.o.a((Activity) webView.getContext(), g);
    }

    public static void setShareInfo(WebView webView, JSONObject jSONObject) {
        ShareParameter g = g(jSONObject);
        if (g != null) {
            if (g.getStatInfo() != null && TextUtils.isEmpty(g.getStatInfo().action)) {
                StatInfo statInfo = g.getStatInfo();
                statInfo.action = "btn_share";
                g.setStatInfo(statInfo);
            }
            if (webView instanceof cn.ninegame.library.b.a) {
                BaseTabFragment baseTabFragment = ((cn.ninegame.library.b.a) webView).f1846a;
                baseTabFragment.v();
                baseTabFragment.q = g;
                baseTabFragment.q.put(cn.ninegame.share.core.g.SHARE_INFO_INNER_URL, g.get(cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL));
                if (baseTabFragment.q.isDisabled()) {
                    baseTabFragment.l.g = null;
                    au.a().a(baseTabFragment.l);
                    return;
                }
                baseTabFragment.l.g = baseTabFragment;
            }
        }
    }

    public static void setH5TimeLine(WebView webView, JSONObject jSONObject) {
    }

    private static ShareParameter g(JSONObject jSONObject) {
        JSONObject optJSONObject;
        JSONObject e = cc.e(jSONObject, "shareInfo");
        if (e == null) {
            e = cc.e(jSONObject, "shareText");
        }
        if (e == null) {
            return null;
        }
        String b2 = cc.b(e, "title");
        String b3 = cc.b(e, "content");
        String b4 = cc.b(e, cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL);
        String b5 = cc.b(e, cn.ninegame.share.core.g.SHARE_INFO_IMG_URL);
        String b6 = cc.b(e, "iconUrl");
        String b7 = cc.b(e, cn.ninegame.share.core.g.SHARE_INFO_AD_WORD);
        String b8 = cc.b(e, cn.ninegame.share.core.g.SHARE_INFO_AD_URL);
        String b9 = cc.b(e, cn.ninegame.share.core.g.SHARE_INFO_PLATFORM);
        String b10 = cc.b(e, "from");
        ShareParameter shareParameter = new ShareParameter();
        shareParameter.put("title", b2);
        shareParameter.put("content", b3);
        shareParameter.put(cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL, b4);
        shareParameter.put(cn.ninegame.share.core.g.SHARE_INFO_IMG_URL, b5);
        shareParameter.put("iconUrl", b6);
        shareParameter.put(cn.ninegame.share.core.g.SHARE_INFO_AD_WORD, b7);
        shareParameter.put(cn.ninegame.share.core.g.SHARE_INFO_AD_URL, b8);
        shareParameter.put(cn.ninegame.share.core.g.SHARE_INFO_PLATFORM, b9);
        shareParameter.put("from", b10);
        Object f = cc.f(jSONObject, "statInfo");
        if (f != null) {
            if (f instanceof JSONObject) {
                optJSONObject = (JSONObject) f;
            } else {
                optJSONObject = f instanceof JSONArray ? ((JSONArray) f).optJSONObject(0) : null;
            }
            if (optJSONObject != null) {
                StatInfo statInfo = new StatInfo();
                statInfo.action = optJSONObject.optString("action");
                statInfo.a1 = optJSONObject.optString("a1");
                statInfo.a2 = optJSONObject.optString("a2");
                statInfo.a3 = optJSONObject.optString("a3");
                if (statInfo.action == null) {
                    statInfo.action = "";
                }
                if (statInfo.a1 == null) {
                    statInfo.a1 = "";
                }
                if (statInfo.a2 == null) {
                    statInfo.a2 = "";
                }
                if (statInfo.a3 == null) {
                    statInfo.a3 = "";
                }
                shareParameter.setStatInfo(statInfo);
            }
            shareParameter.setDisabled(cc.c(jSONObject, "disabled"));
            return shareParameter;
        }
        return shareParameter;
    }

    public static void setFavoriteInfo(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            Bundle bundle = new Bundle();
            bundle.putString("json_value", jSONObject.toString());
            cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_webview_event_set_favorite_info", bundle));
        }
    }

    public static cn.ninegame.gamemanager.game.a.f getFavoriteParameter(JSONObject jSONObject) {
        JSONObject optJSONObject;
        JSONObject e = cc.e(jSONObject, "favoriteInfo");
        if (e == null) {
            return null;
        }
        Object f = cc.f(jSONObject, "statInfo");
        cn.ninegame.gamemanager.game.a.f fVar = new cn.ninegame.gamemanager.game.a.f(cc.b(e, "title"), cc.b(e, "gameId"), cc.b(e, "gameName"), cc.b(e, "url"), cc.b(e, "logo"));
        if (f != null) {
            if (f instanceof JSONObject) {
                optJSONObject = (JSONObject) f;
            } else {
                optJSONObject = f instanceof JSONArray ? ((JSONArray) f).optJSONObject(0) : null;
            }
            if (optJSONObject != null) {
                StatInfo statInfo = new StatInfo();
                statInfo.action = optJSONObject.optString("action");
                statInfo.a1 = optJSONObject.optString("a1");
                statInfo.a2 = optJSONObject.optString("a2");
                statInfo.a3 = optJSONObject.optString("a3");
                if (statInfo.action == null) {
                    statInfo.action = "";
                }
                if (statInfo.a1 == null) {
                    statInfo.a1 = "";
                }
                if (statInfo.a2 == null) {
                    statInfo.a2 = "";
                }
                if (statInfo.a3 == null) {
                    statInfo.a3 = "";
                }
                fVar.i = statInfo;
                return fVar;
            }
            return fVar;
        }
        return fVar;
    }

    public static void downloadBySystem(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            ao.a(NineGameClientApplication.a(), cc.b(jSONObject, "url"));
            cn.ninegame.library.stat.a.j.b().a("btn_downapk", cc.b(cc.e(jSONObject, "statInfo"), "a1"), null, null);
        }
    }

    public static String getActivityId() {
        int a2 = cn.ninegame.gamemanager.startup.b.b.m.a().d().a(cn.ninegame.framework.a.c.b, -1);
        if (a2 == -1) {
            return NineGameClientApplication.a().getResources().getString(R.string.activity_id);
        }
        return String.valueOf(a2);
    }

    public static void notifyPrivilegeChanged(WebView webView, JSONObject jSONObject) {
        boolean z = true;
        if (jSONObject != null) {
            switch (cc.a(jSONObject, "type", -1)) {
                case 1:
                    UserMemberInfo parseMemberJSON = UserCenterInfo.parseMemberJSON(cc.e(jSONObject, UserCenterInfo.KEY_PRIVILEGE_MEMBER));
                    if (parseMemberJSON != null) {
                        parseMemberJSON.status = 1;
                        break;
                    }
                default:
                    z = false;
                    break;
            }
            if (z) {
                ArrayList<CombineRequest> arrayList = new ArrayList<>();
                arrayList.add(cn.ninegame.library.util.u.a(u.a.GET_USER_MEMBER_INFO, (String) null, (String) null));
                arrayList.add(cn.ninegame.library.util.u.a(u.a.GET_USER_PRIVILEGE_INFO, (String) null, (String) null));
                CombineRequestInfo combineRequestInfo = new CombineRequestInfo();
                combineRequestInfo.combineRequestInfos = arrayList;
                combineRequestInfo.combineMode = "parallel";
                Request request = new Request(10012);
                request.setRequestPath("/combine");
                request.put("server_request_info", combineRequestInfo);
                cn.ninegame.library.network.net.d.c.a().a(request, (RequestManager.b) null);
            }
        }
    }

    public static void verifyMobile(final WebView webView, JSONObject jSONObject) {
        String str;
        final JSONObject jSONObject2;
        String str2 = null;
        if (webView instanceof cn.ninegame.library.b.a) {
            final String b2 = cc.b(jSONObject, "callbackId");
            if (jSONObject != null) {
                jSONObject2 = jSONObject.optJSONObject("statInfo");
                str = jSONObject.optString("title");
                str2 = jSONObject.optString("content");
            } else {
                str = null;
                jSONObject2 = null;
            }
            Bundle bundle = new Bundle();
            bundle.putString("title", str);
            bundle.putString("content", str2);
            cn.ninegame.genericframework.basic.g.a().b().a("sns_verify_mobile", bundle, new IResultListener() {
                @Override
                public final void onResult(Bundle bundle2) {
                    int i = bundle2.getInt("callback_type");
                    Bundle bundle3 = (Bundle) bundle2.getParcelable("data");
                    switch (i) {
                        case 1:
                            cn.ninegame.library.stat.a.j.b().a("dlg_checkphone", "gh_all");
                            cn.ninegame.genericframework.basic.g.a().b().a("guild_info_get_id", (Bundle) null, new IResultListener() {
                                @Override
                                public void onResult(Bundle bundle4) {
                                    cn.ninegame.library.stat.n.a(jSONObject2, "dialog_bindshow", (String) null, String.valueOf(bundle4.getLong("guildId")), (String) null);
                                }
                            });
                            return;
                        case 2:
                            boolean z = bundle3.getBoolean("result");
                            String string = bundle3.getString("msg");
                            JSONObject jSONObject3 = new JSONObject();
                            cc.b(jSONObject3, LoginInfo.ACCOUNT_TYPE_MOBILE, bundle3.getString(LoginInfo.ACCOUNT_TYPE_MOBILE));
                            cc.b(jSONObject3, Body.CONST_CLIENT_SID, bundle3.getString(Body.CONST_CLIENT_SID));
                            cc.b(jSONObject3, "ucid", bundle3.getInt("ucid"));
                            cc.b(jSONObject3, cn.ninegame.share.core.g.SHARE_INFO_NICKNAME, bundle3.getString(cn.ninegame.share.core.g.SHARE_INFO_NICKNAME));
                            NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) WebView.this, b2, z, string, jSONObject3);
                            return;
                        default:
                            return;
                    }
                }
            });
        }
    }

    public static void bindMobile(final WebView webView, final JSONObject jSONObject) {
        final String b2 = cc.b(jSONObject, "callbackId");
        cn.ninegame.genericframework.basic.g.a().b().a("msg_account_check_if_need_authentication", (Bundle) null, new IResultListener() {
            @Override
            public final void onResult(Bundle bundle) {
                if (bundle.getBoolean("is_need_auth")) {
                    JSONObject jSONObject2 = new JSONObject();
                    try {
                        jSONObject2.put("needAuthentication", true);
                    } catch (JSONException e) {
                        cn.ninegame.library.stat.b.b.b(e);
                    }
                    NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) WebView.this, b2, false, "", (Object) jSONObject2);
                    return;
                }
                JSONObject e2 = cc.e(jSONObject, "statInfo");
                String optString = e2 != null ? e2.optString("a1") : "";
                Bundle bundle2 = new Bundle();
                bundle2.putString("a1_prefix", optString);
                cn.ninegame.genericframework.basic.g.a().b().a("msg_account_bind_mobile", bundle2, new IResultListener() {
                    @Override
                    public void onResult(Bundle bundle3) {
                        JSONObject jSONObject3;
                        boolean z = bundle3.getBoolean("result");
                        String string = bundle3.getString("message");
                        String string2 = bundle3.getString("json_data");
                        try {
                            jSONObject3 = new JSONObject(string2);
                        } catch (JSONException e3) {
                            cn.ninegame.library.stat.b.b.b(e3);
                            jSONObject3 = null;
                        }
                        if (string2 != null) {
                            cc.b(jSONObject3, "needAuthentication", false);
                        }
                        NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) WebView.this, b2, z, string, string2);
                    }
                });
            }
        });
    }

    @TargetApi(17)
    public static void bookGiftForSettle(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            FragmentActivity activity = ((cn.ninegame.library.b.a) webView).f1846a.getActivity();
            if (Build.VERSION.SDK_INT < 17 || !activity.isDestroyed()) {
                JSONObject optJSONObject = jSONObject.optJSONObject("giftInfo");
                if (optJSONObject == null) {
                    optJSONObject = new JSONObject();
                }
                int optInt = optJSONObject.optInt("gameId", -1);
                int optInt2 = jSONObject.optInt("guildId");
                int optInt3 = jSONObject.optInt("type");
                String string = NineGameClientApplication.a().getString(R.string.guild_gift_no_settled_game_book);
                Bundle bundle = new Bundle();
                switch (optInt3) {
                    case 1:
                        bundle.putString("content", string);
                        cn.ninegame.genericframework.basic.g.a().b().a("guild_gift_show_settle_game_dialog", bundle);
                        return;
                    case 2:
                        bundle.putInt("guildId", optInt2);
                        bundle.putInt("game_id", optInt);
                        bundle.putString("content", string);
                        cn.ninegame.genericframework.basic.g.a().b().a("guild_gift_show_contract_manager_dialog", bundle);
                        return;
                    default:
                        return;
                }
            }
        }
    }

    public static void applyGift(WebView webView, JSONObject jSONObject) {
        BaseTabFragment baseTabFragment;
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a) && (baseTabFragment = ((cn.ninegame.library.b.a) webView).f1846a) != null && baseTabFragment.getActivity() != null) {
            FragmentActivity activity = baseTabFragment.getActivity();
            cn.ninegame.library.b.a aVar = (cn.ninegame.library.b.a) webView;
            cn.ninegame.library.stat.a.b.b().a("公会申请礼包", new String[0]);
            JSONObject optJSONObject = jSONObject.optJSONObject("giftInfo");
            cn.ninegame.library.stat.b.b.a("NineGameClientJSBridge#applyGift#giftInfo:\t%s", optJSONObject);
            if (optJSONObject == null) {
                optJSONObject = new JSONObject();
            }
            int optInt = optJSONObject.optInt("gameId", -1);
            String optString = optJSONObject.optString("sceneId");
            int optInt2 = optJSONObject.optInt("consumePrice");
            int optInt3 = optJSONObject.optInt("surplusAmount");
            String b2 = cc.b(jSONObject, "callbackId");
            int optInt4 = optJSONObject.optInt("recycleDiscount");
            long optLong = optJSONObject.optLong("recycleTime");
            cn.ninegame.library.uilib.generic.u a2 = cn.ninegame.library.util.d.a(activity, NineGameClientApplication.a().getString(R.string.wait_check_post));
            cn.ninegame.library.util.d.a(a2);
            cn.ninegame.library.network.net.d.c.a().a(cn.ninegame.library.network.net.d.b.a(optString, 1), new q(a2, activity, aVar, optString, optInt, optInt2, optInt3, b2, optLong, optInt4));
        }
    }

    public static void checkBuyValid(WebView webView, JSONObject jSONObject) {
        BaseTabFragment baseTabFragment;
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a) && (baseTabFragment = ((cn.ninegame.library.b.a) webView).f1846a) != null && baseTabFragment.getActivity() != null) {
            FragmentActivity activity = baseTabFragment.getActivity();
            if (!(activity instanceof BaseActivityWrapper)) {
                return;
            }
            String optString = jSONObject.optJSONObject("giftInfo").optString("sceneId");
            String b2 = cc.b(jSONObject, "callbackId");
            cn.ninegame.library.uilib.generic.u a2 = cn.ninegame.library.util.d.a(activity, NineGameClientApplication.a().getString(R.string.wait_check_post));
            cn.ninegame.library.util.d.a(a2);
            cn.ninegame.library.network.net.d.c.a().a(cn.ninegame.library.network.net.d.b.a(optString, 2), new u(a2, activity, (cn.ninegame.library.b.a) webView, optString, b2));
        }
    }

    public static String getRecentVisitForums(WebView webView, JSONObject jSONObject) {
        List<cn.ninegame.modules.forum.model.pojo.l> a2 = ((cn.ninegame.modules.forum.model.b.a) cn.ninegame.library.storage.db.e.a(cn.ninegame.modules.forum.model.b.a.class)).a();
        JSONArray jSONArray = new JSONArray();
        int i = 0;
        while (true) {
            try {
                int i2 = i;
                if (i2 >= a2.size()) {
                    break;
                }
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("fid", a2.get(i2).b);
                jSONObject2.put("gameId", a2.get(i2).c);
                jSONObject2.put(UserGuest.KEY_PROPERTY_GUEST_VISITTIME, a2.get(i2).d);
                jSONArray.put(jSONObject2);
                i = i2 + 1;
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
        }
        return jSONArray.toString();
    }

    public static void openPostDetaiPage(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            int[] iArr = {jSONObject.optInt("topicId"), 0};
            String optString = jSONObject.optString("url");
            Bundle bundle = new Bundle();
            bundle.putIntArray("open_thread_params", iArr);
            bundle.putString("forum_url", optString);
            bundle.putBoolean("new_window", true);
            cn.ninegame.genericframework.basic.g.a().b().a("forum_open_post_detail", bundle);
        }
    }

    public static void setLocalBundle(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            try {
                cn.ninegame.library.util.c.a.a(jSONObject, ((BaseWebPageFragment) ((cn.ninegame.library.b.a) webView).f1846a).t());
            } catch (Exception e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
        }
    }

    public static void setMenu(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            try {
                JSONArray jSONArray = jSONObject.has("menuList") ? jSONObject.getJSONArray("menuList") : null;
                jSONObject.optString("callbackId");
                if (jSONArray != null && jSONArray.length() > 0) {
                    BaseWebPageFragment baseWebPageFragment = (BaseWebPageFragment) ((cn.ninegame.library.b.a) webView).f1846a;
                    cn.ninegame.library.uilib.adapter.title.a.w j = baseWebPageFragment.j();
                    cn.ninegame.library.uilib.adapter.title.e a2 = cn.ninegame.library.uilib.adapter.title.e.a();
                    cn.ninegame.library.b.a aVar = (cn.ninegame.library.b.a) webView;
                    cn.ninegame.library.uilib.adapter.title.a.w wVar = j == null ? new cn.ninegame.library.uilib.adapter.title.a.w() : j;
                    cn.ninegame.library.uilib.adapter.title.a.w wVar2 = new cn.ninegame.library.uilib.adapter.title.a.w();
                    ArrayList<cn.ninegame.library.uilib.adapter.title.d> arrayList = new ArrayList<>();
                    Map<cn.ninegame.library.uilib.adapter.title.a.x, cn.ninegame.library.uilib.adapter.title.d> a3 = cn.ninegame.library.uilib.adapter.title.e.a(baseWebPageFragment.u());
                    for (int i = 0; i < jSONArray.length(); i++) {
                        try {
                            cn.ninegame.library.uilib.adapter.title.d a4 = cn.ninegame.library.uilib.adapter.title.d.a(jSONArray.getJSONObject(i));
                            int i2 = a4.g;
                            int i3 = a4.b;
                            String str = a4.c;
                            cn.ninegame.library.uilib.adapter.title.d dVar = (a4.f2508a.equals(cn.ninegame.library.uilib.adapter.title.a.x.CUSTOM) || !a3.containsKey(a4.f2508a)) ? a4 : a3.get(a4.f2508a);
                            dVar.g = i2 == -1 ? dVar.f2508a.ordinal() : i2;
                            dVar.b = i3 == 0 ? cn.ninegame.library.uilib.adapter.title.e.a(dVar.f2508a, false) : i3;
                            if (!TextUtils.isEmpty(str)) {
                                dVar.c = str;
                            }
                            dVar.l = aVar;
                            switch (dVar.f2508a) {
                                case SHARE:
                                    if (wVar.g != null) {
                                        wVar2.g = wVar.g;
                                        break;
                                    } else {
                                        wVar2.g = a2;
                                        break;
                                    }
                                case DOWNLOAD_MANAGER:
                                    wVar2.y = true;
                                    break;
                                case FOLLOW:
                                    if (wVar.c != null) {
                                        wVar2.c = wVar.c;
                                        break;
                                    } else {
                                        wVar2.c = a2;
                                        break;
                                    }
                                case FOLLOW_FEED:
                                    if (wVar.d != null) {
                                        wVar2.d = wVar.d;
                                        break;
                                    } else {
                                        wVar2.d = a2;
                                        break;
                                    }
                                case FAVORITE:
                                    if (wVar.f2500a != null) {
                                        wVar2.f2500a = wVar.f2500a;
                                        break;
                                    } else {
                                        wVar2.f2500a = a2;
                                        break;
                                    }
                                case FAVORITE_FEED:
                                    if (wVar.b != null) {
                                        wVar2.b = wVar.b;
                                        break;
                                    } else {
                                        wVar2.b = a2;
                                        break;
                                    }
                                case GAME_UPGRATE:
                                    wVar2.z = true;
                                    break;
                                case FEEDBACK:
                                    wVar2.B = true;
                                    break;
                                case OPEN_BY_BROWSER:
                                    if (wVar.e != null) {
                                        wVar2.e = wVar.e;
                                        break;
                                    } else {
                                        wVar2.e = a2;
                                        break;
                                    }
                                case REFRESH:
                                    if (wVar.f != null) {
                                        wVar2.f = wVar.f;
                                        break;
                                    } else {
                                        wVar2.f = a2;
                                        break;
                                    }
                                case SETTING:
                                    wVar2.A = true;
                                    break;
                                case DELETE_POSTS:
                                    if (wVar.h != null) {
                                        wVar2.h = wVar.h;
                                        break;
                                    } else {
                                        wVar2.h = a2;
                                        break;
                                    }
                                case JUMP_PAGE:
                                    if (wVar.l != null) {
                                        wVar2.l = wVar.l;
                                        break;
                                    } else {
                                        wVar2.l = a2;
                                        break;
                                    }
                                case JUMP_SORT:
                                    if (wVar.m != null) {
                                        wVar2.m = wVar.m;
                                        break;
                                    } else {
                                        wVar2.m = a2;
                                        break;
                                    }
                                case MESSAGE:
                                    if (wVar.i != null) {
                                        wVar2.i = wVar.i;
                                        break;
                                    } else {
                                        wVar2.i = a2;
                                        break;
                                    }
                                case REPORT:
                                    if (wVar.v != null) {
                                        wVar2.v = wVar.v;
                                        break;
                                    } else {
                                        wVar2.v = a2;
                                        break;
                                    }
                                case DELETE_FRIEND:
                                    if (wVar.u != null) {
                                        wVar2.u = wVar.u;
                                        break;
                                    } else {
                                        wVar2.u = a2;
                                        break;
                                    }
                                case CUSTOM:
                                    wVar2.n = a2;
                                    break;
                                case EDIT_POSTS:
                                    if (wVar.k != null) {
                                        wVar2.k = wVar.k;
                                        break;
                                    } else {
                                        wVar2.k = a2;
                                        break;
                                    }
                                case PIN:
                                    if (wVar.w != null) {
                                        wVar2.w = wVar.w;
                                        break;
                                    } else {
                                        wVar2.w = a2;
                                        break;
                                    }
                                case COIN_NOTIFICATION:
                                    if (wVar.x != null) {
                                        wVar2.x = wVar.x;
                                    } else {
                                        wVar2.x = a2;
                                    }
                                    if (wVar2.x.q()) {
                                        dVar.c = a2.f2509a.getString(R.string.close_coin_notification);
                                        dVar.b = R.drawable.ng_get_coin_page_menu_notification_off;
                                        break;
                                    } else {
                                        dVar.c = a2.f2509a.getString(R.string.open_coin_notification);
                                        dVar.b = R.drawable.ng_get_coin_page_menu_notification_on;
                                        break;
                                    }
                            }
                            if (!dVar.f2508a.equals(cn.ninegame.library.uilib.adapter.title.a.x.DOWNLOAD_MANAGER)) {
                                if (dVar.f2508a.equals(cn.ninegame.library.uilib.adapter.title.a.x.GAME_UPGRATE)) {
                                    cn.ninegame.library.uilib.adapter.title.e.c(dVar);
                                } else if (dVar.f2508a.equals(cn.ninegame.library.uilib.adapter.title.a.x.SETTING)) {
                                    cn.ninegame.library.uilib.adapter.title.e.b(dVar);
                                }
                            }
                            arrayList.add(dVar);
                        } catch (JSONException e) {
                            cn.ninegame.library.stat.b.b.a(e);
                        }
                    }
                    baseWebPageFragment.l = wVar2;
                    baseWebPageFragment.c(arrayList);
                    baseWebPageFragment.a(WebFavoriteParameterInfo.parse(jSONArray));
                }
            } catch (Exception e2) {
                cn.ninegame.library.stat.b.b.a(e2);
            }
        }
    }

    public static void setScrollVisible(WebView webView, JSONObject jSONObject) {
        ((cn.ninegame.library.b.a) webView).setVerticalScrollBarEnabled(jSONObject.optBoolean("visible", false));
    }

    public static void notifyInterceptKeyBack(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            boolean optBoolean = jSONObject.optBoolean("isIntercept", false);
            jSONObject.optString("callbackId");
            ((cn.ninegame.b.h.a) ((cn.ninegame.library.b.a) webView)).d = optBoolean;
        }
    }

    public static void chat(WebView webView, JSONObject jSONObject) {
        JSONObject optJSONObject;
        if (jSONObject != null && (optJSONObject = jSONObject.optJSONObject("msgInfo")) != null) {
            int optInt = optJSONObject.optInt("type");
            long j = 0;
            try {
                j = Long.parseLong(optJSONObject.optString("targetId"));
            } catch (NumberFormatException e) {
                cn.ninegame.library.stat.b.b.a(e);
            }
            int optInt2 = optJSONObject.optInt("contentType", 1);
            String optString = optJSONObject.optString("content");
            Bundle bundle = new Bundle();
            bundle.putInt("biz_type", optInt);
            bundle.putLong("target_id", j);
            bundle.putInt("content_type", optInt2);
            bundle.putString("content", optString);
            bundle.putString("refer", "gh_all");
            cn.ninegame.genericframework.basic.g.a().b().a("im_chat_enter_chat", bundle);
        }
    }

    public static void showCaptchaDialog(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            cn.ninegame.modules.forum.view.widget.j jVar = new cn.ninegame.modules.forum.view.widget.j(webView.getContext());
            String optString = jSONObject.optString("captchaKey");
            if (!TextUtils.isEmpty(optString)) {
                String optString2 = jSONObject.optString("title");
                String b2 = cc.b(jSONObject, "callbackId");
                String optString3 = jSONObject.optString("server", "client_server");
                x xVar = new x(webView, b2);
                if ("guild_server".equals(optString3)) {
                    jVar.b(optString, optString2, xVar);
                } else {
                    jVar.a(optString, optString2, xVar);
                }
                jVar.show();
            }
        }
    }

    public static void chooseImage(final WebView webView, final JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            int optInt = jSONObject.optInt("maxSize", 1);
            Bundle bundle = new Bundle();
            bundle.putInt(LocalAlbumFragment.f2959a, optInt);
            cn.ninegame.genericframework.basic.g.a().b().b(LocalAlbumFragment.class.getName(), bundle, new IResultListener() {
                @Override
                public final void onResult(Bundle bundle2) {
                    if (bundle2 != null) {
                        NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) WebView.this, jSONObject, true, "", (Object) NineGameClientJSBridge.a(WebView.this, bundle2.getParcelableArrayList("select_album_pictures")));
                    }
                }
            });
        }
    }

    public static void isReceiveGetCoinsNotification(WebView webView, JSONObject jSONObject) {
        cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new y(cn.ninegame.library.i.a.b.j.OTHER, cn.ninegame.library.i.a.b.k.HIGHER, webView, jSONObject));
    }

    public static void setReceiveGetCoinsNotification(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            cn.ninegame.library.i.i.a((cn.ninegame.library.i.a.b.i) new z(cn.ninegame.library.i.a.b.j.IPC, cn.ninegame.library.i.a.b.k.HIGHER, jSONObject, webView));
        }
    }

    public static void playVideo(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            String optString = jSONObject.optString(IProxyHandler.KEY_VIDEO_URL);
            jSONObject.optString("videoRemoteUrl");
            if (optString != null && !"".equals(optString)) {
                if (optString.endsWith("mp4")) {
                    cn.ninegame.library.util.g.a(optString, cn.ninegame.library.util.g.c(optString));
                } else {
                    cn.ninegame.library.util.g.b(optString);
                }
            }
        }
    }

    public static void finishChangePassword(WebView webView) {
        cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("change_password_success"));
    }

    public static void finishResetPassword(WebView webView) {
        cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("reset_password_success"));
    }

    public static void checkSuportWebFloatLogin(WebView webView, JSONObject jSONObject) {
        JSONObject jSONObject2 = new JSONObject();
        try {
            jSONObject2.put("supportFloatLogin", true);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
        }
        callbackJS((cn.ninegame.library.b.a) webView, jSONObject, true, "", (Object) jSONObject2);
    }

    public static String enableDebug(WebView webView, JSONObject jSONObject) {
        jSONObject.optString("key");
        jSONObject.optString("sign");
        jSONObject.optString("url");
        cn.ninegame.b.f.i iVar = cn.ninegame.b.f.j.e().e;
        cn.ninegame.b.f.i.a("打开u3debug,请重启客户端");
        cn.ninegame.b.b.e.q().b("u3_debug", true);
        return "";
    }

    public static void disableDebug(WebView webView, JSONObject jSONObject) {
        cn.ninegame.b.f.i iVar = cn.ninegame.b.f.j.e().e;
        cn.ninegame.b.f.i.a("关闭u3debug,请重启客户端");
        cn.ninegame.b.b.e.q().b("u3_debug", false);
    }

    public static String openGame(WebView webView, JSONObject jSONObject) {
        String string;
        boolean z;
        String str;
        boolean z2 = false;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        a2.getString(R.string.msg_execute_success);
        JSONObject jSONObject2 = new JSONObject();
        if (jSONObject == null || jSONObject.optInt("gameId") == 0) {
            string = a2.getString(R.string.msg_illegal_argument_exception);
        } else {
            int optInt = jSONObject.optInt("gameId");
            String optString = jSONObject.optString(InterestedGame.PKG_NAME);
            Iterator<InstalledGameInfo> it = cn.ninegame.gamemanager.game.packagemanager.helper.a.a().b().iterator();
            boolean z3 = false;
            String str2 = optString;
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                InstalledGameInfo next = it.next();
                if (next.gameId != optInt) {
                    z = z3;
                    str = str2;
                } else if (!TextUtils.isEmpty(str2) && next.packageName.contentEquals(str2)) {
                    z3 = true;
                    break;
                } else {
                    str = next.packageName;
                    z = true;
                }
                str2 = str;
                z3 = z;
            }
            if (z3) {
                Bundle bundle = new Bundle();
                bundle.putString(InstalledGamesManager.KEY_PKG_NAME, str2);
                cn.ninegame.genericframework.basic.g.a().b().a("base_biz_launch_app", bundle);
                string = a2.getString(R.string.msg_execute_success);
                z2 = true;
            } else {
                string = a2.getString(R.string.msg_not_install_game);
            }
        }
        return genCallbackJson(z2, string, jSONObject2).toString();
    }

    public static String getInstallGameList(WebView webView, JSONObject jSONObject) {
        String string;
        boolean z = false;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        String string2 = a2.getString(R.string.msg_execute_success);
        JSONObject jSONObject2 = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        JSONArray optJSONArray = jSONObject.optJSONArray("filter");
        List<InstalledGameInfo> b2 = cn.ninegame.gamemanager.game.packagemanager.helper.a.a().b();
        ArrayList<InstalledGameInfo> arrayList = new ArrayList();
        if (optJSONArray != null && optJSONArray.length() > 0) {
            for (int i = 0; i < optJSONArray.length(); i++) {
                String optString = optJSONArray.optString(i);
                if (!TextUtils.isEmpty(optString)) {
                    for (InstalledGameInfo installedGameInfo : b2) {
                        if (installedGameInfo.packageName.endsWith(optString)) {
                            arrayList.add(installedGameInfo);
                        }
                    }
                }
            }
        } else {
            arrayList.addAll(b2);
        }
        try {
            for (InstalledGameInfo installedGameInfo2 : arrayList) {
                JSONObject jSONObject3 = new JSONObject();
                jSONObject3.put("gameId", installedGameInfo2.gameId);
                jSONObject3.put("gameName", installedGameInfo2.gameName);
                jSONObject3.put(InterestedGame.PKG_NAME, installedGameInfo2.packageName);
                jSONObject3.put("versionName", installedGameInfo2.versionName);
                jSONObject3.put("versionCode", installedGameInfo2.versionCode);
                jSONArray.put(jSONObject3);
            }
            jSONObject2.put("gameList", jSONArray);
            string = string2;
            z = true;
        } catch (JSONException e) {
            string = a2.getString(R.string.msg_build_data_fail);
        }
        return genCallbackJson(z, string, jSONObject2).toString();
    }

    public static String getStarRankCache(WebView webView, JSONObject jSONObject) {
        boolean z;
        JSONObject jSONObject2;
        String string;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        String string2 = a2.getString(R.string.msg_execute_success);
        if (jSONObject == null || jSONObject.optLong("starUcid") == 0) {
            z = false;
            jSONObject2 = null;
            string = a2.getString(R.string.msg_illegal_argument_exception);
        } else {
            long optLong = jSONObject.optLong("starUcid");
            String optString = jSONObject.optString("tab");
            Bundle bundle = new Bundle();
            bundle.putLong("star_ucid", optLong);
            bundle.putString("type_index", optString);
            Bundle b2 = cn.ninegame.genericframework.basic.g.a().b().b("get_star_rank_cache_data", bundle);
            z = b2.getBoolean("result");
            String string3 = b2.getString("bundle_data");
            if (TextUtils.isEmpty(string3)) {
                string = string2;
                jSONObject2 = null;
            } else {
                try {
                    jSONObject2 = new JSONObject(string3);
                    try {
                        string = b2.getString("msgs");
                    } catch (JSONException e) {
                        string = a2.getString(R.string.msg_build_data_fail);
                        z = false;
                        return genCallbackJson(z, string, jSONObject2).toString();
                    }
                } catch (JSONException e2) {
                    jSONObject2 = null;
                }
            }
        }
        return genCallbackJson(z, string, jSONObject2).toString();
    }

    public static void showGameDetailHeader(WebView webView, JSONObject jSONObject) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("bundle_show_or_hide_header", jSONObject.optBoolean("show_game_detail_header"));
        cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("game_detail_header_event", bundle));
    }

    public static String fetchLocation(WebView webView, JSONObject jSONObject) {
        final JSONObject jSONObject2 = new JSONObject();
        Bundle bundle = new Bundle();
        bundle.putString("location_source", "from_h5");
        cn.ninegame.genericframework.basic.g.a().b().a("initiative_fetch_location_msg", bundle, new IResultListener() {
            @Override
            public final void onResult(Bundle bundle2) {
                NGLocationInfo nGLocationInfo = (NGLocationInfo) bundle2.getParcelable("location_info");
                try {
                    jSONObject2.put("latitude", nGLocationInfo.latitude);
                    jSONObject2.put("longitude", nGLocationInfo.longitude);
                    jSONObject2.put("province", nGLocationInfo.province);
                    jSONObject2.put("city_name", nGLocationInfo.cityName);
                    jSONObject2.put("district", nGLocationInfo.district);
                } catch (JSONException e) {
                }
            }
        });
        return jSONObject2.toString();
    }

    public static String jumpTmallDetail(WebView webView, JSONObject jSONObject) {
        String string;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        boolean z = false;
        Activity a3 = cn.ninegame.genericframework.basic.g.a().b().a();
        if (a3 == null || a3.isFinishing()) {
            string = a2.getString(R.string.msg_open_tmall_fail);
        } else if (jSONObject == null || !jSONObject.has("detailId")) {
            string = a2.getString(R.string.msg_illegal_argument_exception);
        } else {
            TBDetailParam tBDetailParam = new TBDetailParam(jSONObject.optString("detailId"));
            tBDetailParam.setBackUrl(cb.a());
            try {
                z = TMAppLinkSDK.getInstance().jumpDetail(a3, tBDetailParam);
                if (!TBAppLinkUtil.isSupportAppLinkSDK(a3)) {
                    string = a2.getString(R.string.msg_tmall_not_install);
                } else {
                    string = a2.getString(R.string.msg_execute_success);
                }
            } catch (TBAppLinkException e) {
                string = e.getMessage();
            }
        }
        return genCallbackJson(z, string, null).toString();
    }

    public static String jumpTmallURI(WebView webView, JSONObject jSONObject) {
        String string;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        boolean z = false;
        Activity a3 = cn.ninegame.genericframework.basic.g.a().b().a();
        if (a3 == null || a3.isFinishing()) {
            string = a2.getString(R.string.msg_open_tmall_fail);
        } else if (jSONObject == null || !jSONObject.has("h5Url")) {
            string = a2.getString(R.string.msg_illegal_argument_exception);
        } else {
            TBURIParam tBURIParam = new TBURIParam(jSONObject.optString("h5Url"));
            tBURIParam.setBackUrl(cb.a());
            try {
                z = TMAppLinkSDK.getInstance().jumpTBURI(a3, tBURIParam);
                if (!TBAppLinkUtil.isSupportAppLinkSDK(a3)) {
                    string = a2.getString(R.string.msg_tmall_not_install);
                } else {
                    string = a2.getString(R.string.msg_execute_success);
                }
            } catch (TBAppLinkException e) {
                string = e.getMessage();
            }
        }
        return genCallbackJson(z, string, null).toString();
    }

    public static String jumpTmallShop(WebView webView, JSONObject jSONObject) {
        String string;
        NineGameClientApplication a2 = NineGameClientApplication.a();
        boolean z = false;
        Activity a3 = cn.ninegame.genericframework.basic.g.a().b().a();
        if (a3 == null || a3.isFinishing()) {
            string = a2.getString(R.string.msg_open_tmall_fail);
        } else if (jSONObject == null || !jSONObject.has("shopId")) {
            string = a2.getString(R.string.msg_illegal_argument_exception);
        } else {
            TBShopParam tBShopParam = new TBShopParam(jSONObject.optString("shopId"));
            tBShopParam.setBackUrl(cb.a());
            try {
                z = TMAppLinkSDK.getInstance().jumpShop(a3, tBShopParam);
                if (!TBAppLinkUtil.isSupportAppLinkSDK(a3)) {
                    string = a2.getString(R.string.msg_tmall_not_install);
                } else {
                    string = a2.getString(R.string.msg_execute_success);
                }
            } catch (TBAppLinkException e) {
                string = e.getMessage();
            }
        }
        return genCallbackJson(z, string, null).toString();
    }

    public static void sendMsgByModal(final WebView webView, final JSONObject jSONObject) {
        long optLong = jSONObject.optLong("targetId");
        int optInt = jSONObject.optInt("type");
        int optInt2 = jSONObject.optInt("contentType");
        JSONObject optJSONObject = jSONObject.optJSONObject("shareInfo");
        if (9 != optInt2 || optJSONObject == null) {
            callbackJS((cn.ninegame.library.b.a) webView, jSONObject.optString("callbackId"), false, "", (Object) jSONObject);
            return;
        }
        String optString = optJSONObject.optString("iconUrl");
        String optString2 = optJSONObject.optString("title");
        cn.ninegame.genericframework.basic.g.a().b().a("im_share_url_base_object_target", new cn.ninegame.genericframework.c.a().a("biz_type", optInt).a("target_id", optLong).a("title", optString2).a("summary", optJSONObject.optString("content")).a("thumb_url", (optString == null || optString.length() <= 0) ? "http://image.game.uc.cn/2015/12/10/11595252.png" : "http://image.game.uc.cn/2015/12/10/11595252.png").a("url", optJSONObject.optString(cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL)).a("redirect_chat", true).f1706a, new IResultListener() {
            @Override
            public final void onResult(Bundle bundle) {
                boolean z = bundle.getBoolean("result", false);
                NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) webView, jSONObject.optString("callbackId"), z, "", jSONObject);
            }
        });
    }

    public static void pullRefresh(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null && (webView instanceof cn.ninegame.library.b.a)) {
            cn.ninegame.library.b.a aVar = (cn.ninegame.library.b.a) webView;
            cn.ninegame.library.i.i.a(new ab((BaseWebPageFragment) aVar.f1846a, aVar, jSONObject.optString("state", ""), jSONObject.optInt("progress", 0)));
        }
    }

    public static void markInteractionTime(WebView webView, JSONObject jSONObject) {
        cn.ninegame.b.e.a a2 = cn.ninegame.b.e.a.a();
        a2.k = System.currentTimeMillis();
        Log.i("H5TimeInfo", String.format("markFirstInteraction: %s", Long.valueOf(a2.k)));
    }

    public static String isUCProxyEnabled(WebView webView, JSONObject jSONObject) {
        return (!((cn.ninegame.library.b.a) webView).m || NetworkUtils.isWifi(webView.getContext())) ? "0" : "1";
    }

    public static void pay(WebView webView, JSONObject jSONObject) {
        String optString = jSONObject.optString("callbackId");
        String optString2 = jSONObject.optString("type");
        String optString3 = jSONObject.optString("productName");
        double optDouble = jSONObject.optDouble("amount");
        String optString4 = jSONObject.optString("notifyUrl");
        JSONObject optJSONObject = jSONObject.optJSONObject("attachInfo");
        cn.ninegame.library.stat.h.a().a("Pay", "Member", jSONObject.toString());
        b(webView, optString, optString2, optString3, optDouble, optJSONObject.toString(), optString4);
    }

    public static void b(WebView webView, String str, String str2, String str3, double d, String str4, String str5) {
        Bundle bundle = new Bundle();
        StringBuilder sb = new StringBuilder();
        cn.ninegame.modules.account.f.a();
        bundle.putString("order_id", sb.append(cn.ninegame.modules.account.f.d()).append(cn.ninegame.library.util.l.h(NineGameClientApplication.a())).append(System.currentTimeMillis()).toString());
        bundle.putString("product_name", str3);
        bundle.putString("game_id", str2);
        bundle.putDouble("pay_amount", d);
        bundle.putString("attach_info", str4);
        bundle.putString("notify_url", str5);
        cn.ninegame.genericframework.basic.g.a().b().a(H5NcScene.PAY, bundle, new AnonymousClass41(webView, str, str2, str5, str3, d, str4));
    }

    public final class AnonymousClass41 extends IResultListener {
        final String val$attachInfo;
        final String val$callbackId;
        final String val$notifyUri;
        final double val$payAmount;
        final String val$productName;
        final String val$type;
        final WebView val$webView;

        AnonymousClass41(WebView webView, String str, String str2, String str3, String str4, double d, String str5) {
            this.val$webView = webView;
            this.val$callbackId = str;
            this.val$type = str2;
            this.val$notifyUri = str3;
            this.val$productName = str4;
            this.val$payAmount = d;
            this.val$attachInfo = str5;
        }

        @Override
        public final void onResult(Bundle bundle) {
            if (bundle.getBoolean("pay_result")) {
                String string = bundle.getString("order_id");
                String string2 = bundle.getString("trade_id");
                JSONObject jSONObject = new JSONObject();
                cc.b(jSONObject, "orderId", string);
                cc.b(jSONObject, "tradeId", string2);
                NineGameClientJSBridge.callbackJS((cn.ninegame.library.b.a) this.val$webView, this.val$callbackId, true, "", (Object) jSONObject);
                return;
            }
            cn.ninegame.library.i.i.c(new ac(this, cn.ninegame.library.i.a.b.j.OTHER, cn.ninegame.library.i.a.b.k.HIGHER, bundle));
        }
    }

    public static void resumeDownloadApp(WebView webView, JSONObject jSONObject) {
        if (jSONObject != null) {
            Bundle bundle = new Bundle();
            bundle.putInt("game_id", Game.getGameId(jSONObject));
            bundle.putString("bundle_package_name", Game.getPkgName(jSONObject));
            cn.ninegame.genericframework.basic.g.a().b().a("download_resume_download_app", bundle);
            if (jSONObject.has("callbackId")) {
                try {
                    callbackJS((cn.ninegame.library.b.a) webView, jSONObject.getString("callbackId"), true, "", (Object) null);
                    return;
                } catch (JSONException e) {
                    cn.ninegame.library.stat.b.b.a(e);
                    return;
                }
            }
            return;
        }
        cc.i("启动下载任务失败.");
    }

    public static void unsubscribeGift(WebView webView, JSONObject jSONObject) {
        cn.ninegame.hybird.api.bridge.data.r rVar = new cn.ninegame.hybird.api.bridge.data.r((cn.ninegame.library.b.a) webView);
        try {
            rVar.e = new JSONObject();
            rVar.f1763a = jSONObject;
            if (jSONObject.has("callbackId")) {
                rVar.d = jSONObject.getString("callbackId");
            }
            JSONObject jSONObject2 = jSONObject.getJSONObject("giftInfo");
            rVar.e.put("sceneId", jSONObject2.getString("sceneId"));
            String string = jSONObject2.getString("sceneId");
            String d = be.d(NineGameClientApplication.a().getApplicationContext());
            if (d == null) {
                d = "";
            }
            cn.ninegame.library.network.net.d.c a2 = cn.ninegame.library.network.net.d.c.a();
            Request request = new Request(4201);
            request.setRequestPath("/api/op.ka.activity.cancel");
            request.put("sceneIds", string);
            request.put("imei", d);
            a2.a(request, rVar);
        } catch (JSONException e) {
            rVar.c = false;
            rVar.b = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
            rVar.a(null);
        }
    }

    public static void registerGift(WebView webView, JSONObject jSONObject) {
        new cn.ninegame.hybird.api.bridge.data.i((cn.ninegame.library.b.a) webView, jSONObject).a();
        cn.ninegame.library.stat.a.b.b().a("游戏领取礼包", new String[0]);
    }

    public static void dredgeGift(WebView webView, JSONObject jSONObject) {
        cn.ninegame.hybird.api.bridge.data.e eVar = new cn.ninegame.hybird.api.bridge.data.e((cn.ninegame.library.b.a) webView);
        try {
            eVar.e = new JSONObject();
            eVar.f1752a = jSONObject;
            if (jSONObject.has("callbackId")) {
                eVar.d = jSONObject.getString("callbackId");
            }
            JSONObject jSONObject2 = jSONObject.getJSONObject("giftInfo");
            eVar.e.put("sceneId", jSONObject2.getString("sceneId"));
            String string = jSONObject2.getString("sceneId");
            cn.ninegame.library.network.net.d.c a2 = cn.ninegame.library.network.net.d.c.a();
            Request request = new Request(3801);
            request.setRequestPath("/api/op.ka.activity.dredge");
            request.put("sceneId", string);
            a2.a(request, eVar);
        } catch (JSONException e) {
            eVar.c = false;
            eVar.b = e.getMessage();
            cn.ninegame.library.stat.b.b.a(e);
            eVar.a(null);
        }
    }

    public static void DataApi(WebView webView, JSONObject jSONObject) {
        String str;
        String str2;
        String str3;
        String str4;
        cn.ninegame.hybird.api.bridge.data.d dVar = new cn.ninegame.hybird.api.bridge.data.d((cn.ninegame.library.b.a) webView);
        try {
            if (jSONObject.has("callbackId")) {
                dVar.b = jSONObject.getString("callbackId");
            }
            if (!jSONObject.has("url")) {
                str = "";
            } else {
                str = jSONObject.getString("url");
            }
            if (!jSONObject.has("data")) {
                str2 = "{}";
            } else {
                str2 = jSONObject.getString("data");
            }
            if (!jSONObject.has("page")) {
                str3 = "{}";
            } else {
                str3 = jSONObject.getString("page");
            }
            if (!jSONObject.has("service")) {
                str4 = "";
            } else {
                str4 = jSONObject.getString("service");
            }
            String optString = jSONObject.optString(Body.CONST_OPTION, "");
            int i = jSONObject.has("cache") ? jSONObject.getInt("cache") : 0;
            boolean z = jSONObject.has("persistence") ? jSONObject.getBoolean("persistence") : true;
            boolean z2 = jSONObject.has("force") ? jSONObject.getBoolean("force") : false;
            JSONObject e = cc.e(jSONObject, "options");
            String b2 = cc.b(e, "reqId");
            String b3 = cc.b(e, "groupId");
            Request request = new Request(3101);
            cn.ninegame.library.stat.b.b.a("URL: " + str, new Object[0]);
            cn.ninegame.library.stat.b.b.a("CACHE_TIME: " + i, new Object[0]);
            if (i > 0) {
                request.setCacheTime(i);
                request.setMemoryCacheEnabled(true);
                request.setDataCacheEnabled(z);
            }
            request.setForceRequestEnabled(z2);
            request.put("url", str);
            request.put("data", str2);
            request.put(Body.CONST_OPTION, optString);
            request.put("page", str3);
            request.put("service", str4);
            request.put("cache", i);
            request.setRequestId(b2);
            request.setGroupId(b3);
            request.setCallerId("NGWebView" + dVar.f1751a.hashCode());
            cn.ninegame.library.network.net.d.c.a().a(request, dVar);
        } catch (JSONException e2) {
            cn.ninegame.library.stat.b.b.a(e2);
        }
    }

    public static void enableUCProxy(WebView webView, JSONObject jSONObject) {
        b.a.a();
        cn.ninegame.library.b.b.a();
    }

    public static void a(boolean z, Object obj, int i, String str, boolean z2, WebView webView, String str2, int i2) {
        String str3;
        JSONObject jSONObject;
        JSONObject jSONObject2;
        JSONArray a2 = cn.ninegame.gamemanager.game.mygame.c.a(i, str, z2, i2);
        if (z) {
            str3 = "";
        } else {
            str3 = (z2 ? "add" : "delete") + " interested game failed! gameId:" + i;
        }
        if (z2 && z) {
            if (obj instanceof JSONObject) {
                jSONObject2 = (JSONObject) obj;
            } else {
                if (obj instanceof JSONArray) {
                    JSONArray jSONArray = (JSONArray) obj;
                    if ((jSONArray == null ? 0 : jSONArray.length()) > 0) {
                        jSONObject2 = cc.b(jSONArray, 0);
                    }
                }
                jSONObject2 = null;
            }
            cn.ninegame.library.stat.a.j.b().a("bookonlinegamesuccess", cc.b(jSONObject2, "a1"), String.valueOf(i), "");
        }
        JSONObject jSONObject3 = new JSONObject();
        try {
            jSONObject = (JSONObject) a2.get(0);
        } catch (JSONException e) {
            cn.ninegame.library.stat.b.b.a(e);
            jSONObject = jSONObject3;
        }
        callbackJS((cn.ninegame.library.b.a) webView, str2, z, str3, jSONObject);
        String jSONArray2 = a2.toString();
        Bundle bundle = new Bundle();
        bundle.putString("follow_game_array", jSONArray2);
        cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_follow_state_change", bundle));
    }

    public static void a(String str, Activity activity, cn.ninegame.library.b.a aVar, String str2, int i, int i2, int i3, String str3, long j, int i4) {
        cn.ninegame.modules.forum.view.widget.j jVar = new cn.ninegame.modules.forum.view.widget.j(activity);
        jVar.b(str, null, new r(activity, aVar, str2, i, i2, i3, str3, j, i4));
        jVar.show();
    }

    static void a(Integer num, final String str, int i, int i2, int i3, final cn.ninegame.library.b.a aVar, final String str2, long j, int i4) {
        Bundle bundle = new Bundle();
        bundle.putString("gift_id", str);
        bundle.putInt("game_id", i);
        bundle.putInt("consume_price", i2);
        bundle.putInt(TaskRewardInfo.KEY_CONTRIBUTION, num.intValue());
        bundle.putInt("surplusAmount", i3);
        bundle.putLong("recycleTime", j);
        bundle.putInt("recycleDiscount", i4);
        bundle.putParcelable("callback", new IResultListener() {
            @Override
            public final void onResult(Bundle bundle2) {
                if (bundle2 == null && cn.ninegame.library.network.b.a(NineGameClientApplication.a()) == cn.ninegame.library.network.a.UNAVAILABLE) {
                    cc.b((int) R.string.network_fail);
                } else {
                    NineGameClientJSBridge.callbackJS(cn.ninegame.library.b.a.this, str2, true, "", (Object) str);
                }
            }
        });
        cn.ninegame.genericframework.basic.g.a().b().a("guild_apply_gift", bundle);
    }

    public static void a(String str, Activity activity, cn.ninegame.library.b.a aVar, String str2) {
        cn.ninegame.modules.forum.view.widget.j jVar = new cn.ninegame.modules.forum.view.widget.j(activity);
        jVar.b(str, null, new v(activity, aVar, str2));
        jVar.show();
    }

    static JSONArray a(WebView webView, List list) {
        Uri parse;
        int size = list != null ? list.size() : 0;
        if (size == 0) {
            return null;
        }
        JSONArray jSONArray = new JSONArray();
        String str = parse.getScheme() + "://" + parse.getHost() + (Uri.parse(webView.getUrl()).getPort() == -1 ? "" : ":" + parse.getPort()) + "/9game.cn/api/webresp/fromUri";
        for (int i = 0; i < size; i++) {
            String encode = Uri.encode(((Uri) list.get(i)).toString());
            JSONObject jSONObject = new JSONObject();
            cc.b(jSONObject, DownloadCfgFile.COLUMN_URI, encode);
            cc.a(jSONArray, i, cn.ninegame.library.util.l.a(jSONObject, str, false, false));
        }
        return jSONArray;
    }
}