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

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


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

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Keep;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.webkit.JavascriptInterface;
import com.coremedia.iso.boxes.TrackReferenceTypeBox;
import com.dialog.DialogResult;
import com.dialog.c;
import com.dialog.e;
import com.dialog.theme.DialogTwoButtonTheme;
import com.framework.EnvironmentMode;
import com.framework.config.Config;
import com.framework.config.SysConfigKey;
import com.framework.database.tables.CachesTable;
import com.framework.helpers.ApkInstallHelper;
import com.framework.manager.network.NetworkStatusManager;
import com.framework.manager.udid.UdidManager;
import com.framework.rxbus.RxBus;
import com.framework.utils.ActivityStateUtils;
import com.framework.utils.JSONUtils;
import com.framework.utils.UMengEventUtils;
import com.huawei.hms.framework.common.hianalytics.CrashHianalyticsData;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.m4399.framework.BaseApplication;
import com.m4399.gamecenter.plugin.main.R;
import com.m4399.gamecenter.plugin.main.config.GameCenterConfigKey;
import com.m4399.gamecenter.plugin.main.controllers.comment.CommentDetailActivity;
import com.m4399.gamecenter.plugin.main.controllers.gamedetail.GameDetailActivity;
import com.m4399.gamecenter.plugin.main.controllers.gamedetail.GameDetailCommentAllFragment;
import com.m4399.gamecenter.plugin.main.controllers.gamedetail.GameDetailIntroFragment;
import com.m4399.gamecenter.plugin.main.database.tables.m;
import com.m4399.gamecenter.plugin.main.database.tables.u;
import com.m4399.gamecenter.plugin.main.fastplay.helper.FastPlayAuthHelper;
import com.m4399.gamecenter.plugin.main.helpers.BundleCreateHelper;
import com.m4399.gamecenter.plugin.main.helpers.k;
import com.m4399.gamecenter.plugin.main.helpers.l;
import com.m4399.gamecenter.plugin.main.manager.config.RemoteConfigManager;
import com.m4399.gamecenter.plugin.main.manager.router.GameCenterRouterManager;
import com.m4399.gamecenter.plugin.main.manager.user.UserCenterManager;
import com.m4399.gamecenter.plugin.main.models.gamedetail.GameDetailModel;
import com.m4399.gamecenter.plugin.main.models.gamedetail.GamePlayerVideoModel;
import com.m4399.gamecenter.plugin.main.models.user.UserHomePageTabType;
import com.m4399.gamecenter.plugin.main.utils.bc;
import com.m4399.gamecenter.plugin.main.widget.web.BaseWebViewLayout;
import com.m4399.stat.StatisticsAgent;
import com.m4399.support.controllers.BaseActivity;
import com.m4399.support.utils.ToastUtils;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.xiaomi.mipush.sdk.Constants;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.json.JSONObject;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import timber.log.Timber;

public class CommentJsInterface extends AndroidJsInterface {
    public static final int ACTION_ADD = 1;
    public static final int ACTION_MODIFY = 3;
    public static final int ACTION_REPLY = 2;
    public static final int ENV_LOCAL_DEV = 1;
    public static final int ENV_LOCAL_TEST = 2;
    public static final int ENV_ONLINE = 4;
    public static final int ENV_ONLINE_TEST = 3;
    public static final String INJECTED_ANDROID = "android";
    public static final int POSITION_ALL_COMMENT = 4;
    public static final int POSITION_CUSTOMTAB_COMMENT = 5;
    public static final int POSITION_GAME_DETAIL_TAB_ALL = 2;
    public static final int POSITION_GAME_DETAIL_TAB_INFO = 1;
    public static final int POSITION_MY_COMMENT = 3;
    private int aoI;
    private String aoK;
    private String aoX;
    private int aoY;
    private int apb;
    private int apc;
    private String apq;
    private int cgn;
    private ArrayMap<String, Object> cgo;
    private String cgp;
    private Boolean cgq;
    private Boolean cgr;
    private GameDetailIntroFragment cgs;
    private GameDetailCommentAllFragment cgt;
    private boolean cgu;
    private a cgv;
    private int mActivityId;
    private int mForumID;
    private int mGameHubId;
    private int mGameID;
    private String mGameIconUrl;
    private String mGameName;
    private String mGamePackage;
    private int mGameState;
    private int mNewsId;

    public interface a {
        void enableEditor(boolean z, String str);
    }

    public String getPagePosition() {
        return "";
    }

    @Keep
    @JavascriptInterface
    @Deprecated
    public boolean isScrollOverComment() {
        return false;
    }

    public void setShowed(boolean z) {
        this.cgu = z;
    }

    public CommentJsInterface(BaseWebViewLayout baseWebViewLayout, Context context) {
        super(baseWebViewLayout, context);
        this.cgq = false;
        this.cgr = false;
        this.cgu = false;
    }

    public void setWeeklyReportId(int i) {
        this.aoI = i;
    }

    public void setGameDetailIntroFragment(GameDetailIntroFragment gameDetailIntroFragment) {
        this.cgs = gameDetailIntroFragment;
    }

    public void setGameDetailCommentAllFragment(GameDetailCommentAllFragment gameDetailCommentAllFragment) {
        this.cgt = gameDetailCommentAllFragment;
    }

    public void setSpecialId(int i) {
        this.apb = i;
    }

    public void setSpecialName(String str) {
        this.apq = str;
    }

    public void setNewsId(int i) {
        this.mNewsId = i;
    }

    public void setVideoInfoId(int i) {
        this.apc = i;
    }

    public void setVideoInfoName(String str) {
        this.cgp = str;
    }

    public void setActivityId(int i) {
        this.mActivityId = i;
    }

    public void setGameID(int i) {
        this.mGameID = i;
    }

    public void setCommentID(String str) {
        this.aoK = str;
    }

    public void setGameState(int i) {
        this.mGameState = i;
    }

    public int getGameId() {
        return this.mGameID;
    }

    public void setGameHubId(int i) {
        this.mGameHubId = i;
    }

    public void setForumID(int i) {
        this.mForumID = i;
    }

    public void setGamePackage(String str) {
        this.mGamePackage = str;
    }

    public void setLatestVersionCode(int i) {
        this.aoY = i;
    }

    public void setGameCommentPosition(int i) {
        this.cgn = i;
    }

    public void setParamsArrayMap(ArrayMap<String, Object> arrayMap) {
        this.cgo = arrayMap;
    }

    public void setGameIconUrl(String str) {
        this.mGameIconUrl = str;
    }

    public void setGameImgUrl(String str) {
        this.aoX = str;
    }

    public void setGameName(String str) {
        this.mGameName = str;
    }

    @Keep
    @JavascriptInterface
    public void openCommonCommentDetail(String str) {
        if (!NetworkStatusManager.checkIsAvalible()) {
            ToastUtils.showToast(this.mContext, this.mContext.getResources().getString(R.string.str_check_your_network));
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        Bundle bundle = new Bundle();
        String string = JSONUtils.getString("commentId", parseJSONObjectFromString);
        int i = JSONUtils.getInt(CachesTable.COLUMN_KEY, parseJSONObjectFromString);
        String string2 = JSONUtils.getString(TrackReferenceTypeBox.TYPE1, parseJSONObjectFromString);
        String string3 = JSONUtils.getString(RemoteMessageConst.DATA, parseJSONObjectFromString);
        int i2 = JSONUtils.getInt("common_type", parseJSONObjectFromString, 1);
        if (i2 == 1) {
            bundle.putInt("intent.extra.weekly.report.id", i);
        } else if (i2 == 2) {
            bundle.putInt("intent.extra.special.id", i);
            bundle.putString("intent.extra.special.name", this.apq);
        } else if (i2 == 3) {
            bundle.putInt("intent.extra.information.news.id", this.mNewsId);
        } else if (i2 == 4) {
            bundle.putInt("intent.extra.video.info.id", this.apc);
        }
        if (!TextUtils.isEmpty(string)) {
            bundle.putString("intent.extra.comment.detail.relate.id", string);
        }
        if (!TextUtils.isEmpty(string2)) {
            bundle.putString("intent.extra.comment.reply.hint", string2);
        }
        if (!TextUtils.isEmpty(string3)) {
            bundle.putString("intent.extra.comment.reply.json", string3);
        }
        bundle.putInt("extra.comment.type", i2);
        GameCenterRouterManager.getInstance().openCommentDetail(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public void openCommonCommentList(String str) {
        if (!NetworkStatusManager.checkIsAvalible()) {
            ToastUtils.showToast(this.mContext, this.mContext.getResources().getString(R.string.str_check_your_network));
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        int i = JSONUtils.getInt(CachesTable.COLUMN_KEY, parseJSONObjectFromString);
        int i2 = JSONUtils.getInt("common_type", parseJSONObjectFromString, 6);
        String string = JSONUtils.getString(RemoteMessageConst.DATA, parseJSONObjectFromString);
        Bundle bundle = new Bundle();
        if (i2 == 1) {
            bundle.putInt("intent.extra.weekly.report.id", i);
            bundle.putInt("extra.comment.type", 6);
        } else if (i2 == 2) {
            bundle.putInt("intent.extra.special.id", i);
            bundle.putString("intent.extra.special.name", this.apq);
            bundle.putInt("extra.comment.type", 2);
        } else if (i2 == 3) {
            bundle.putInt("intent.extra.information.news.id", i);
            bundle.putInt("extra.comment.type", 3);
        } else if (i2 == 4) {
            bundle.putInt("intent.extra.video.info.id", this.apc);
            bundle.putInt("extra.comment.type", 4);
        }
        if (!TextUtils.isEmpty(string)) {
            bundle.putString("intent.extra.comment.reply.json", string);
        }
        GameCenterRouterManager.getInstance().openCommentList(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public void onJsPostCommentDetailData(String str) {
        Activity activity = com.m4399.gamecenter.plugin.main.utils.a.getActivity(this.mContext);
        if (activity != null && (activity instanceof CommentDetailActivity)) {
            ((CommentDetailActivity) activity).receiveGameCommentData(str);
        }
    }

    @Keep
    @JavascriptInterface
    public void updateAlbumCommentNum(int i) {
        Bundle bundle = new Bundle();
        if (this.apb != 0) {
            bundle.putInt("extra.comment.type", 2);
            bundle.putInt("intent.extra.special.id", this.apb);
        } else if (this.apc != 0) {
            bundle.putInt("extra.comment.type", 4);
            bundle.putInt("intent.extra.video.info.id", this.apc);
        }
        bundle.putInt("zone.detail.comment.num", i);
        RxBus.get().post("extra.comment.num", bundle);
    }

    @Keep
    @JavascriptInterface
    public void onExpandComment() {
        if (this.cgs != null) {
            Observable.timer(200L, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {
                @Override
                public void call(Long l) {
                    CommentJsInterface.this.cgs.reSizePageHeight();
                }
            });
        }
    }

    @Keep
    @JavascriptInterface
    public boolean isHasShowed() {
        return this.cgu;
    }

    @Keep
    @JavascriptInterface
    public String getParamJsonString() {
        JSONObject jSONObject = new JSONObject();
        JSONUtils.putObject("env", Integer.valueOf(getEnvironment()), jSONObject);
        JSONUtils.putObject("position", Integer.valueOf(this.cgn), jSONObject);
        ArrayMap<String, Object> arrayMap = this.cgo;
        if (arrayMap != null && arrayMap.size() != 0) {
            for (Map.Entry<String, Object> entry : this.cgo.entrySet()) {
                JSONUtils.putObject(entry.getKey(), entry.getValue(), jSONObject);
            }
        }
        return jSONObject.toString();
    }

    protected final int getEnvironment() {
        char c;
        String str = (String) Config.getValue(SysConfigKey.HTTP_ENVIRONMENT);
        int hashCode = str.hashCode();
        if (hashCode == -1012222381) {
            if (str.equals(EnvironmentMode.ONLINE)) {
                c = 3;
            }
            c = 65535;
        } else if (hashCode == 3557) {
            if (str.equals(EnvironmentMode.OT)) {
                c = 2;
            }
            c = 65535;
        } else if (hashCode != 3646) {
            if (hashCode == 3556498 && str.equals(EnvironmentMode.TESTER)) {
                c = 1;
            }
            c = 65535;
        } else {
            if (str.equals(EnvironmentMode.T2)) {
                c = 0;
            }
            c = 65535;
        }
        if (c == 0) {
            return 1;
        }
        if (c == 1) {
            return 2;
        }
        if (c == 2) {
            return 3;
        }
        if (c != 3) {
        }
        return 4;
    }

    @Keep
    @JavascriptInterface
    public void openModifyGameCmt(String str) {
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        com.m4399.gamecenter.plugin.main.manager.w.a.getInstance().openGameCommentPage(this.mContext, BundleCreateHelper.createModifyGameCmt(this.mGameID, this.mGamePackage, bc.toInt(JSONUtils.getString("id", parseJSONObjectFromString)), JSONUtils.getString("content", parseJSONObjectFromString), bc.toInt(JSONUtils.getString("score", parseJSONObjectFromString)), this.mGameState, bc.toInt(JSONUtils.getString("contribute", parseJSONObjectFromString))));
    }

    @Override
    @Keep
    @JavascriptInterface
    public void onClickReplyComment(String str) {
        dN(bc.toInt(str));
        Bundle bundle = new Bundle();
        bundle.putInt("intent.extra.comment.id", bc.toInt(str));
        bundle.putInt("intent.extra.comment.action.type", 2);
        int i = this.mGameID;
        if (i != 0) {
            bundle.putInt("intent.extra.game.id", i);
            bundle.putInt("extra.comment.type", 1);
        }
        int i2 = this.mNewsId;
        if (i2 != 0) {
            bundle.putInt("intent.extra.information.news.id", i2);
            bundle.putInt("extra.comment.type", 3);
        }
        int i3 = this.mActivityId;
        if (i3 != 0) {
            bundle.putInt("intent.extra.activity.id", i3);
            bundle.putInt("extra.comment.type", 7);
        }
        int i4 = this.apb;
        if (i4 != 0) {
            bundle.putInt("intent.extra.special.id", i4);
            bundle.putInt("extra.comment.type", 2);
        }
        if (this.apc != 0) {
            UMengEventUtils.onEvent("ad_game_news_video_comment", "回复");
        }
        if (this.mNewsId != 0 || this.apc != 0) {
            c(bundle, true);
        } else {
            GameCenterRouterManager.getInstance().openWriteComment(this.mContext, bundle);
        }
    }

    @Override
    @Keep
    @JavascriptInterface
    public void onClickAddComment() {
        int i;
        GameDetailModel gameDetailModel;
        Bundle bundle = new Bundle();
        bundle.putInt("intent.extra.comment.action.type", 1);
        if (this.apc == 0 && (i = this.mGameID) != 0) {
            bundle.putInt("intent.extra.game.id", i);
            bundle.putInt("intent.extra.game.version.code", ApkInstallHelper.getVersionCodeByPackageName(this.mGamePackage));
            bundle.putString("intent.extra.game.package.name", this.mGamePackage);
            if ((this.mContext instanceof GameDetailActivity) && (gameDetailModel = ((GameDetailActivity) this.mContext).getGameDetailModel()) != null) {
                bundle.putBoolean("intent.extra.game.support.download", gameDetailModel.getSupportDownload());
            }
            com.m4399.gamecenter.plugin.main.manager.w.a.getInstance().openGameCommentPage(this.mContext, bundle);
            return;
        }
        int i2 = this.aoI;
        if (i2 != 0) {
            bundle.putInt("intent.extra.weekly.report.id", i2);
            bundle.putInt("extra.comment.type", 6);
            c(bundle, false);
            return;
        }
        int i3 = this.apb;
        if (i3 != 0) {
            bundle.putInt("intent.extra.special.id", i3);
            bundle.putInt("extra.comment.type", 2);
            c(bundle, false);
            return;
        }
        int i4 = this.mNewsId;
        if (i4 != 0) {
            bundle.putInt("intent.extra.information.news.id", i4);
            bundle.putInt("extra.comment.type", 3);
        }
        int i5 = this.mActivityId;
        if (i5 != 0) {
            bundle.putInt("intent.extra.activity.id", i5);
            bundle.putInt("extra.comment.type", 7);
        }
        if (this.apc != 0) {
            bundle.putInt("intent.extra.game.id", this.mGameID);
            bundle.putInt("extra.comment.type", 4);
            bundle.putInt("intent.extra.video.info.id", this.apc);
            UMengEventUtils.onEvent("ad_game_news_video_comment", "写评论");
        }
        if (this.mNewsId != 0 || this.apc != 0) {
            c(bundle, false);
        } else {
            GameCenterRouterManager.getInstance().openWriteComment(this.mContext, bundle);
        }
    }

    private void c(Bundle bundle, boolean z) {
        String str = z ? "common_comment_reply" : "common_comment_comment";
        if (bundle == null) {
            bundle = new Bundle();
        }
        bundle.putString("extra.auth.buss.key", str);
        GameCenterRouterManager.getInstance().openWriteComment(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public void onClickAddComment(String str) {
        onClickAddComment(str, true);
    }

    public void onClickAddComment(String str, boolean z) {
        q(str, z);
        Observable.timer(200L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {
            @Override
            public void call(Long l) {
                if (CommentJsInterface.this.mContext != null) {
                    k.executeJs(CommentJsInterface.this.mWebView, CommentJsInterface.this.mContext.getString(R.string.js_prefix, "window.startEffect.clearHigh()"));
                }
            }
        });
    }

    private void q(String str, boolean z) {
        GameDetailModel gameDetailModel;
        if (TextUtils.isEmpty(str) || this.apc != 0 || this.mGameID == 0) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        int i = JSONUtils.getInt("rating", parseJSONObjectFromString);
        boolean z2 = JSONUtils.getBoolean("from_game_detail", parseJSONObjectFromString);
        JSONUtils.getBoolean("is_comment_additional", parseJSONObjectFromString, false);
        if (this.mContext instanceof GameDetailActivity) {
            ((GameDetailActivity) this.mContext).setCommentFromGamedetail(z2);
        }
        Bundle bundle = new Bundle();
        bundle.putInt("intent.extra.comment.rating", i);
        bundle.putInt("intent.extra.comment.action.type", 1);
        bundle.putInt("intent.extra.game.id", this.mGameID);
        bundle.putBoolean("intent.extra.comment.is.draft", false);
        bundle.putInt("intent.extra.game.state", this.mGameState);
        bundle.putString("intent.extra.game.package.name", this.mGamePackage);
        bundle.putInt("intent.extra.game.version.code", ApkInstallHelper.getVersionCodeByPackageName(this.mGamePackage));
        bundle.putBoolean("intent.extra.game.app", z);
        if ((this.mContext instanceof GameDetailActivity) && (gameDetailModel = ((GameDetailActivity) this.mContext).getGameDetailModel()) != null) {
            bundle.putBoolean("intent.extra.game.support.download", gameDetailModel.getSupportDownload());
        }
        com.m4399.gamecenter.plugin.main.manager.w.a.getInstance().openGameCommentPage(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public void onClickShareComment(String str) {
        if (TextUtils.isEmpty(str) || this.mGameID == 0) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        int i = JSONUtils.getInt("rating", parseJSONObjectFromString);
        String string = JSONUtils.getString("avatar", parseJSONObjectFromString);
        String string2 = JSONUtils.getString(u.COLUMN_NICK, parseJSONObjectFromString);
        String string3 = JSONUtils.getString("content", parseJSONObjectFromString);
        String string4 = JSONUtils.getString("link", parseJSONObjectFromString);
        int i2 = JSONUtils.getInt("userMedal", parseJSONObjectFromString, 0);
        int i3 = JSONUtils.getInt("quality_type", parseJSONObjectFromString);
        Bundle bundle = new Bundle();
        bundle.putInt("intent.extra.game.id", this.mGameID);
        bundle.putInt("extra.comment.quality.type", i3);
        bundle.putString("extra.comment.tid", this.aoK);
        bundle.putString("intent.extra.comment.share.game.img", this.aoX);
        bundle.putString("intent.extra.comment.share.game.icon", this.mGameIconUrl);
        bundle.putString("intent.extra.comment.share.game.name", this.mGameName);
        bundle.putString("intent.extra.comment.share.user.icon", string);
        bundle.putString("intent.extra.comment.share.user.nick", string2);
        bundle.putFloat("intent.extra.comment.rating", i);
        bundle.putString("intent.extra.comment.content", string3);
        bundle.putString("intent.extra.comment.share.game.link", string4);
        bundle.putInt("intent.extra.comment.share.user.medal", i2);
        bundle.putBoolean("intent.extra.comment.share.from.js", true);
        GameCenterRouterManager.getInstance().openGenerateImgShare(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public boolean isShowCommentShareBtn() {
        return !"00000".equalsIgnoreCase(RemoteConfigManager.getInstance().getCommentShareChannels());
    }

    @Keep
    @JavascriptInterface
    public void onClickLoadMoreComments() {
        Bundle bundle = new Bundle();
        int i = this.mNewsId;
        if (i > 0) {
            bundle.putInt("intent.extra.information.news.id", i);
            bundle.putInt("extra.comment.type", 3);
        } else {
            int i2 = this.apc;
            if (i2 > 0) {
                bundle.putInt("intent.extra.video.info.id", i2);
                bundle.putString("intent.extra.video.info.name", this.cgp);
                bundle.putInt("extra.comment.type", 4);
                UMengEventUtils.onEvent("ad_game_news_video_comment", "查看全部评论");
            } else {
                int i3 = this.apb;
                if (i3 > 0) {
                    bundle.putInt("intent.extra.special.id", i3);
                    bundle.putString("intent.extra.special.name", this.apq);
                    bundle.putInt("extra.comment.type", 2);
                } else {
                    if (this.mGameID == 0) {
                        return;
                    }
                    bundle.putString("intent.extra.game.name", this.mGameName);
                    bundle.putInt("intent.extra.game.id", this.mGameID);
                    bundle.putString("intent.extra.comment.share.game.img", this.aoX);
                    bundle.putString("intent.extra.comment.share.game.icon", this.mGameIconUrl);
                    bundle.putInt("intent.extra.game.forums.id", this.mForumID);
                    bundle.putInt("intent.extra.gamehub.id", this.mGameHubId);
                    int i4 = this.mNewsId;
                    if (i4 != 0) {
                        bundle.putInt("intent.extra.information.news.id", i4);
                    }
                    bundle.putInt("extra.comment.type", 1);
                }
            }
        }
        GameCenterRouterManager.getInstance().openCommentList(this.mContext, bundle);
    }

    @Override
    @Keep
    @JavascriptInterface
    public void onClickUserPortraitByComment(String str) {
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        String string = JSONUtils.getString("uid", parseJSONObjectFromString);
        String string2 = JSONUtils.getString("nickName", parseJSONObjectFromString);
        String string3 = JSONUtils.getString(PushConstants.CLICK_TYPE, parseJSONObjectFromString);
        if (!TextUtils.isEmpty(string)) {
            Bundle bundle = new Bundle();
            bundle.putString("intent.extra.goto.user.homepage.username", string2);
            bundle.putString("intent.extra.goto.user.homepage.user.ptuid", string);
            GameCenterRouterManager.getInstance().openUserHomePage(this.mContext, bundle);
        }
        if ("1".equals(string3)) {
            UMengEventUtils.onEvent("game_comment_user_icon");
        } else if ("2".equals(string3)) {
            UMengEventUtils.onEvent("news_comment_user_icon");
        } else if ("3".equals(string3)) {
            UMengEventUtils.onEvent("game_comment_user_icon");
        }
    }

    private void dN(int i) {
        if (i <= 0) {
            throw new IllegalArgumentException("the comment id is invalid");
        }
    }

    @JavascriptInterface
    public void setReplay(String str, String str2) {
        Bundle bundle = new Bundle();
        bundle.putString("intent.extra.comment.reply.hint", str);
        bundle.putString("intent.extra.comment.reply.json", str2);
        RxBus.get().post("tag.comment.reply", bundle);
    }

    public void setEditorInterface(a aVar) {
        this.cgv = aVar;
    }

    @Keep
    @JavascriptInterface
    public void enableEditor(final String str) {
        com.m4399.gamecenter.plugin.main.utils.e.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
                if (parseJSONObjectFromString.length() > 0 && CommentJsInterface.this.cgv != null) {
                    CommentJsInterface.this.cgv.enableEditor(JSONUtils.getBoolean("enable", parseJSONObjectFromString), JSONUtils.getString("disableTip", parseJSONObjectFromString));
                }
            }
        });
    }

    @JavascriptInterface
    public void onJsCloseComment() {
        RxBus.get().post("tag.close.comment", "");
    }

    @Keep
    @JavascriptInterface
    public void replyRequest(String str) {
        l.replyRequest(this.mContext, this.mWebView, str);
    }

    @Keep
    @JavascriptInterface
    public void resizeWebViewContentHeight() {
        if (this.apb != 0) {
            RxBus.get().post("tag.comment.resize.height", 2);
        }
        if (this.apc != 0) {
            RxBus.get().post("tag.comment.resize.height", 4);
        }
    }

    @Keep
    @JavascriptInterface
    public void openCommentDetail(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        JSONUtils.getString("gameID", parseJSONObjectFromString);
        String string = JSONUtils.getString("relateID", parseJSONObjectFromString);
        String string2 = JSONUtils.getString(TrackReferenceTypeBox.TYPE1, parseJSONObjectFromString);
        String string3 = JSONUtils.getString(RemoteMessageConst.DATA, parseJSONObjectFromString);
        boolean z = JSONUtils.getBoolean("like", parseJSONObjectFromString);
        String string4 = JSONUtils.getString(GamePlayerVideoModel.LIKE_NUM, parseJSONObjectFromString);
        String string5 = JSONUtils.getString("reply_num", parseJSONObjectFromString);
        String string6 = JSONUtils.getString("ext", parseJSONObjectFromString);
        String string7 = JSONUtils.getString("tagId", parseJSONObjectFromString);
        if (TextUtils.isEmpty(string)) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putString("intent.extra.game.id", String.valueOf(this.mGameID));
        bundle.putString("intent.extra.comment.share.game.img", this.aoX);
        bundle.putString("intent.extra.comment.share.game.icon", this.mGameIconUrl);
        bundle.putString("intent.extra.comment.share.game.name", this.mGameName);
        bundle.putString("intent.extra.comment.detail.relate.id", string);
        bundle.putString("intent.extra.comment.detail.tag.id", string7);
        bundle.putString("intent.extra.comment.reply.hint", string2);
        bundle.putString("intent.extra.comment.reply.json", string3);
        bundle.putBoolean("intent.extra.comment.like.state", z);
        bundle.putString("intent.extra.comment.like.num", string4);
        bundle.putString("intent.extra.comment.reply.num", string5);
        bundle.putString("intent.extra.game.package.name", this.mGamePackage);
        bundle.putInt("intent.extra.game.version.code", this.aoY);
        bundle.putString("intent.extra.comment.ext", string6);
        bundle.putInt("extra.comment.type", 0);
        GameCenterRouterManager.getInstance().openCommentDetail(this.mContext, bundle);
    }

    @Keep
    @JavascriptInterface
    public void openCommentMyList() {
        Bundle bundle = new Bundle();
        int i = this.mGameID;
        if (i != 0) {
            bundle.putString("intent.extra.game.id", String.valueOf(i));
            bundle.putString("intent.extra.comment.share.game.img", this.aoX);
            bundle.putString("intent.extra.comment.share.game.icon", this.mGameIconUrl);
            bundle.putString("intent.extra.comment.share.game.name", this.mGameName);
            bundle.putString("intent.extra.game.package.name", this.mGamePackage);
            bundle.putInt("intent.extra.game.version.code", this.aoY);
            if (this.mContext instanceof GameDetailActivity) {
                bundle.putString("intent.extra.game.name", ((GameDetailActivity) this.mContext).getGameDetailModel().getName());
            }
            GameCenterRouterManager.getInstance().openCommentMyListActivity(this.mContext, bundle);
        }
    }

    @JavascriptInterface
    public void jumpToAllCommentByIndex(final String str, final String str2) {
        Observable.just("").observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<String>() {
            @Override
            public void call(String str3) {
                Activity activity = com.m4399.gamecenter.plugin.main.utils.a.getActivity(CommentJsInterface.this.mContext);
                if (activity instanceof GameDetailActivity) {
                    ((GameDetailActivity) activity).switchToAllCommentByIndex(str, str2);
                }
            }
        });
    }

    @JavascriptInterface
    public void jumpToGameDetailTab(String str) {
        if (!(this.mContext instanceof GameDetailActivity) || ActivityStateUtils.isDestroy(this.mContext)) {
            return;
        }
        ((GameDetailActivity) this.mContext).switchToTab(Integer.valueOf(bc.toInt(str)));
    }

    @JavascriptInterface
    public void dialog(String str) {
        RxBus.get().post("tag.comment.detail.dialog", str);
    }

    @JavascriptInterface
    public String getNick() {
        return UserCenterManager.getNick();
    }

    @JavascriptInterface
    public void commentHeaderHeight(String str) {
        RxBus.get().post("tag.comment.detail.header.height", str);
    }

    @JavascriptInterface
    public void onLoadSuccess(int i) {
        RxBus.get().post("tag.comment.page.load.success", Boolean.valueOf(i != 0));
    }

    @JavascriptInterface
    public void onLoadError(int i) {
        RxBus.get().post("tag.comment.page.load.error", Integer.valueOf(i));
    }

    @JavascriptInterface
    public int getInstalledVersionCode() {
        return ApkInstallHelper.getVersionCodeByPackageName(this.mGamePackage);
    }

    @JavascriptInterface
    public int getLatestVersionCode() {
        return this.aoY;
    }

    @JavascriptInterface
    public void onMyCommentCountChange(String str) {
        if (this.cgt != null) {
            this.cgt.setMyCommentCount(bc.toInt(str));
        }
    }

    @JavascriptInterface
    public void setViewPagerCanScroll(String str) {
        if (this.mContext instanceof GameDetailActivity) {
            ((GameDetailActivity) this.mContext).setViewPagerCanScroll(Boolean.parseBoolean(str));
        }
    }

    @JavascriptInterface
    public void report(String str) {
        Timber.i("web返回数据:" + str, new Object[0]);
        if (this.mContext == null || TextUtils.isEmpty(str)) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        String string = JSONUtils.getString("comment_id", parseJSONObjectFromString);
        String string2 = JSONUtils.getString("report_nick", parseJSONObjectFromString);
        String string3 = JSONUtils.getString("report_template", parseJSONObjectFromString);
        String string4 = JSONUtils.getString("game_id", parseJSONObjectFromString);
        int i = JSONUtils.getInt("tid", parseJSONObjectFromString);
        int i2 = JSONUtils.getInt(m.COLUMN_MSG_FORUMS_ID, parseJSONObjectFromString);
        int i3 = JSONUtils.getInt("star", parseJSONObjectFromString, 0);
        int i4 = JSONUtils.getInt("type", parseJSONObjectFromString);
        Bundle bundle = new Bundle();
        if (i4 != 0 && i4 < 24) {
            bundle.putInt("intent.extra.report.content.type", i4);
        } else {
            bundle.putInt("intent.extra.report.content.type", 11);
        }
        if (i4 == 9) {
            bundle.putInt("intent.extra.weekly.report.id", this.aoI);
        } else if (i4 == 12) {
            bundle.putInt("intent.extra.special.id", this.apb);
        } else if (i4 == 16) {
            bundle.putInt("intent.extra.information.news.id", this.mNewsId);
        } else if (i4 == 17) {
            bundle.putInt("intent.extra.video.info.id", this.apc);
        } else if (i4 == 7) {
            bundle.putInt("intent.extra.report.extra.post.id", i);
            bundle.putInt("intent.extra.report.extra.forums.id", i2);
        }
        bundle.putString("intent.extra.report.extra.game.id", string4);
        bundle.putString("intent.extra.report.id", string);
        bundle.putString("intent.extra.report.nick", string2);
        bundle.putSerializable("intent.extra.report.extra", string3);
        bundle.putInt("intent.extra.report.extra.star", i3);
        bundle.putSerializable("intent.extra.report.extra", string3);
        GameCenterRouterManager.getInstance().openReport(this.mContext, bundle);
    }

    @JavascriptInterface
    public void onIsAtWebviewBottm(int i) {
        this.cgq = Boolean.valueOf(i == 1);
    }

    @JavascriptInterface
    public void onCheckIsAtWebviewBottm(int i) {
        this.cgr = Boolean.valueOf(i == 1);
    }

    @Keep
    @JavascriptInterface
    public void onCommonCmtReplySuccess(String str) {
        RxBus.get().post("tag.common.comment.reply", str);
    }

    @Keep
    @JavascriptInterface
    public void onDeleteCommonCmt(String str) {
        RxBus.get().post("tag.common.comment.del", str);
    }

    @Keep
    @JavascriptInterface
    public void hideKeyboard() {
        if (this.mContext == null || ActivityStateUtils.isDestroy(this.mContext) || !(this.mContext instanceof CommentDetailActivity)) {
            return;
        }
        ((CommentDetailActivity) this.mContext).hideKeyboardOnly();
    }

    @Keep
    @JavascriptInterface
    public void scrollSpecialDetailPage2Top() {
        RxBus.get().post("tag.scroll.special.detail.top", "");
    }

    @JavascriptInterface
    public void reportReply(String str) {
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        String string = JSONUtils.getString("reply_id", parseJSONObjectFromString);
        String string2 = JSONUtils.getString("uid", parseJSONObjectFromString);
        String string3 = JSONUtils.getString("audit", parseJSONObjectFromString);
        String string4 = JSONUtils.getString("report_nick", parseJSONObjectFromString);
        String string5 = JSONUtils.getString("report_content", parseJSONObjectFromString);
        String string6 = JSONUtils.getString("game_id", parseJSONObjectFromString);
        Observable.timer(200L, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()).subscribe(new AnonymousClass5(string5, string4, JSONUtils.getInt("type", parseJSONObjectFromString), string, string6, string3, str, string2));
    }

    class AnonymousClass5 implements Action1<Long> {
        final String aNA;
        final String aNM;
        final String aNN;
        final String aNQ;
        final String cgA;
        final String cgB;
        final String cgC;
        final int cgz;

        AnonymousClass5(String str, String str2, int i, String str3, String str4, String str5, String str6, String str7) {
            this.aNM = str;
            this.aNN = str2;
            this.cgz = i;
            this.cgA = str3;
            this.cgB = str4;
            this.cgC = str5;
            this.aNQ = str6;
            this.aNA = str7;
        }

        @Override
        public void call(Long l) {
            String str;
            if (ActivityStateUtils.isDestroy(CommentJsInterface.this.mContext) || CommentJsInterface.this.mContext == null) {
                return;
            }
            if (!(CommentJsInterface.this.mContext instanceof GameDetailActivity) || ((GameDetailActivity) CommentJsInterface.this.mContext).isSelectedCommentAll()) {
                if (!TextUtils.isEmpty(this.aNM) && (this.aNM.contains(Constants.COLON_SEPARATOR) || this.aNM.contains(":"))) {
                    str = this.aNN + " " + this.aNM;
                } else {
                    str = this.aNN + ":" + this.aNM;
                }
                new com.m4399.gamecenter.plugin.main.views.l.b(CommentJsInterface.this.mContext, new e.InterfaceC0056e() {
                    @Override
                    public void onItemClick(int i) {
                        if (i == R.id.pop_option_menu_report) {
                            Bundle bundle = new Bundle();
                            if (AnonymousClass5.this.cgz != 0 && AnonymousClass5.this.cgz < 24) {
                                bundle.putInt("intent.extra.report.content.type", AnonymousClass5.this.cgz);
                            } else {
                                bundle.putInt("intent.extra.report.content.type", 11);
                            }
                            bundle.putString("intent.extra.report.id", AnonymousClass5.this.cgA);
                            bundle.putString("intent.extra.report.nick", AnonymousClass5.this.aNN);
                            bundle.putString("intent.extra.report.extra.game.id", AnonymousClass5.this.cgB);
                            bundle.putSerializable("intent.extra.report.extra", AnonymousClass5.this.aNM);
                            GameCenterRouterManager.getInstance().openReport(CommentJsInterface.this.mContext, bundle);
                            return;
                        }
                        if (i == R.id.pop_option_menu_delete) {
                            com.dialog.c cVar = new com.dialog.c(CommentJsInterface.this.mContext);
                            cVar.setDialogTwoButtomTheme(DialogTwoButtonTheme.Horizontal_Red);
                            cVar.setCancelable(true);
                            cVar.setCanceledOnTouchOutside(true);
                            cVar.setOnDialogTwoHorizontalBtnsClickListener(new c.b() {
                                @Override
                                public DialogResult onLeftBtnClick() {
                                    if (!AnonymousClass5.this.cgC.equalsIgnoreCase("1")) {
                                        ToastUtils.showToast(CommentJsInterface.this.mContext, "回复审核中,无法删除");
                                        return DialogResult.OK;
                                    }
                                    RxBus.get().post("tag.comment.delete.action", "javascript:window.m_comment.deleteReply(" + AnonymousClass5.this.aNQ + ")");
                                    return DialogResult.OK;
                                }

                                @Override
                                public DialogResult onRightBtnClick() {
                                    return DialogResult.Cancel;
                                }
                            });
                            cVar.show(CommentJsInterface.this.mContext.getString(R.string.dialog_comment_delete_title), "", CommentJsInterface.this.mContext.getString(R.string.delete), CommentJsInterface.this.mContext.getString(R.string.cancel));
                        }
                    }
                }, str) {
                    @Override
                    protected void initDefaultOption() {
                        Resources resources = getContext().getResources();
                        if (UserCenterManager.isLogin().booleanValue() && UserCenterManager.getInstance().getUser().getPtUid().equalsIgnoreCase(AnonymousClass5.this.aNA)) {
                            this.menuOptions.add(new e.f(0, R.id.pop_option_menu_delete, R.mipmap.m4399_png_option_item_del, resources.getString(R.string.delete)));
                        } else {
                            this.menuOptions.add(new e.f(0, R.id.pop_option_menu_report, R.mipmap.m4399_png_option_item_report, resources.getString(R.string.report)));
                        }
                    }
                }.show();
            }
        }
    }

    @JavascriptInterface
    public boolean showGoToHubTips() {
        if (this.mContext == null || !(this.mContext instanceof GameDetailActivity)) {
            return false;
        }
        return ((GameDetailActivity) this.mContext).isShowComment();
    }

    @JavascriptInterface
    public String getHarmmonyVersion() {
        return com.m4399.gamecenter.utils.e.getOhosVersion();
    }

    @Keep
    @JavascriptInterface
    public void changeCommentBtnStyle(final int i) {
        Observable.timer(0L, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {
            @Override
            public void call(Long l) {
                if (CommentJsInterface.this.mContext instanceof GameDetailActivity) {
                    ((GameDetailActivity) CommentJsInterface.this.mContext).changeCommentBtnStyle(i);
                }
            }
        });
    }

    @Keep
    @JavascriptInterface
    public int getQuanId() {
        if (this.mContext instanceof GameDetailActivity) {
            return ((GameDetailActivity) this.mContext).getQuanId();
        }
        return 0;
    }

    public boolean getIsAtBottom() {
        return this.cgq.booleanValue();
    }

    @Keep
    @JavascriptInterface
    public void hideBottomBar(String str) {
        if (this.mNewsId == 0 || this.mWebView == null || ActivityStateUtils.isDestroy(this.mContext)) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        JSONUtils.putObject("id", Integer.valueOf(this.mNewsId), parseJSONObjectFromString);
        JSONUtils.putObject("web_ctrl_cmt_bar_show", false, parseJSONObjectFromString);
        RxBus.get().post("tag.info.detail.comment", parseJSONObjectFromString);
    }

    @Keep
    @JavascriptInterface
    public void showInfoDetailComment(String str) {
        if (this.mNewsId == 0 || this.mWebView == null || ActivityStateUtils.isDestroy(this.mContext)) {
            return;
        }
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        JSONUtils.putObject("id", Integer.valueOf(this.mNewsId), parseJSONObjectFromString);
        JSONUtils.putObject("web_ctrl_cmt_bar_show", true, parseJSONObjectFromString);
        RxBus.get().post("tag.info.detail.comment", parseJSONObjectFromString);
    }

    @Keep
    @JavascriptInterface
    public void onJsCommentViewEventByJSON(String str) {
        JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(str);
        ah(JSONUtils.getString("id", parseJSONObjectFromString), JSONUtils.getString("uid", parseJSONObjectFromString));
    }

    @Keep
    @JavascriptInterface
    public String getEnableConfig() {
        return (String) Config.getValue(GameCenterConfigKey.CENSOR_ENABLE_CONFIG);
    }

    private void ah(String str, String str2) {
        HashMap hashMap = new HashMap();
        hashMap.put("uid", UserCenterManager.getPtUid());
        hashMap.put(FastPlayAuthHelper.KEY_UDID, UdidManager.getInstance().getUdid());
        hashMap.put(CrashHianalyticsData.TIME, Long.valueOf(System.currentTimeMillis() / 1000));
        hashMap.put("channel", UserHomePageTabType.TAB_GAME_COMMENT);
        hashMap.put("action", "view");
        hashMap.put("position", "comment_list");
        hashMap.put("comment_id", str);
        hashMap.put("entity_id", Integer.valueOf(this.mGameID));
        hashMap.put("comment_uid", str2);
        StatisticsAgent.onEvent((Context) BaseApplication.getApplication(), "yxh_comment_action", (Map<String, Object>) hashMap, true);
    }

    @Override
    @JavascriptInterface
    public void onJsToProfileDetailsByPtUid(final String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        Observable.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
            @Override
            public void call(Object obj) {
                if (CommentJsInterface.this.mContext instanceof BaseActivity) {
                    ((BaseActivity) CommentJsInterface.this.mContext).getWindow().clearFlags(1024);
                } else if (CommentJsInterface.this.mContext instanceof ContextThemeWrapper) {
                    Context baseContext = ((ContextThemeWrapper) CommentJsInterface.this.mContext).getBaseContext();
                    if (baseContext instanceof Activity) {
                        ((Activity) baseContext).getWindow().clearFlags(1024);
                    }
                }
                Bundle bundle = new Bundle();
                bundle.putString("intent.extra.goto.user.homepage.user.ptuid", str);
                bundle.putString("intent.extra.tab.index", UserHomePageTabType.TAB_GAME_COMMENT);
                GameCenterRouterManager.getInstance().openUserHomePage(CommentJsInterface.this.mContext, bundle);
            }
        });
    }
}