4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 InfoDetailActivity.java 源代码,内容仅作参考
package com.m4399.gamecenter.plugin.main.controllers.information;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Keep;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.framework.database.tables.CachesTable;
import com.framework.helpers.IntentHelper;
import com.framework.providers.IHaveResponseDataListener;
import com.framework.rxbus.RxBus;
import com.framework.rxbus.annotation.Subscribe;
import com.framework.rxbus.annotation.Tag;
import com.framework.rxbus.thread.EventThread;
import com.framework.utils.AppUtils;
import com.framework.utils.DensityUtils;
import com.framework.utils.JSONUtils;
import com.framework.utils.UMengEventUtils;
import com.m4399.gamecenter.plugin.main.R;
import com.m4399.gamecenter.plugin.main.controllers.web.BaseWebViewActivity;
import com.m4399.gamecenter.plugin.main.controllers.web.GameCommentJsInterface;
import com.m4399.gamecenter.plugin.main.helpers.bq;
import com.m4399.gamecenter.plugin.main.helpers.k;
import com.m4399.gamecenter.plugin.main.manager.favorites.b;
import com.m4399.gamecenter.plugin.main.manager.router.GameCenterRouterManager;
import com.m4399.gamecenter.plugin.main.manager.share.ShareItemKind;
import com.m4399.gamecenter.plugin.main.manager.share.d;
import com.m4399.gamecenter.plugin.main.manager.stat.StatManager;
import com.m4399.gamecenter.plugin.main.manager.task.TaskManager;
import com.m4399.gamecenter.plugin.main.manager.task.c;
import com.m4399.gamecenter.plugin.main.manager.user.UserCenterManager;
import com.m4399.gamecenter.plugin.main.manager.user.UserGradeManager;
import com.m4399.gamecenter.plugin.main.manager.v;
import com.m4399.gamecenter.plugin.main.models.gamedetail.GamePlayerVideoModel;
import com.m4399.gamecenter.plugin.main.models.mycenter.BrowseRecordNewModel;
import com.m4399.gamecenter.plugin.main.models.picture.PicDetailModel;
import com.m4399.gamecenter.plugin.main.models.share.ShareDataModel;
import com.m4399.gamecenter.plugin.main.models.task.TaskActions;
import com.m4399.gamecenter.plugin.main.utils.SdkUtils;
import com.m4399.gamecenter.plugin.main.utils.ap;
import com.m4399.gamecenter.plugin.main.utils.bc;
import com.m4399.gamecenter.plugin.main.utils.e;
import com.m4399.gamecenter.plugin.main.views.information.InfoDetailBottomView;
import com.m4399.gamecenter.plugin.main.views.mycenter.FavoriteGuidingBar;
import com.m4399.gamecenter.plugin.main.widget.web.BaseWebViewLayout;
import com.m4399.gamecenter.plugin.main.widget.web.WebViewLayout;
import com.m4399.gamecenter.plugin.main.widget.web.i;
import com.m4399.support.utils.HttpResultTipUtils;
import com.m4399.support.utils.ToastUtils;
import java.util.ArrayList;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
public class InfoDetailActivity extends BaseWebViewActivity implements Toolbar.OnMenuItemClickListener, b, i {
private boolean aKG;
private Runnable aLZ;
private boolean aMz;
private GameCommentJsInterface apa;
private LinearLayout biN;
private View biO;
private com.m4399.gamecenter.plugin.main.providers.x.a biP;
private InfoDetailBottomView biQ;
private FavoriteGuidingBar biS;
private int mCommentId;
private int mGameId;
private int mNewsId;
private String mPassthrough;
private int mReplyId;
private long mViewStart;
private String mFrom = "";
private boolean biR = false;
private boolean aRc = false;
private boolean aMA = false;
@Override
public String getUmengPageTitle() {
return "资讯详情";
}
@Override
protected String getWebUrl() {
return "";
}
@Override
public boolean isEnableGesture() {
return false;
}
@Override
protected boolean isRefreshTitleWithWeb() {
return false;
}
@Override
public void onPageEnd(int i, int i2, int i3, int i4) {
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
com.m4399.gamecenter.plugin.main.manager.permission.a.getInstance().onRequestPermissionsResult(this, i, strArr, iArr);
}
@Override
public void onWebViewPageFinished(BaseWebViewLayout baseWebViewLayout, String str) {
super.onWebViewPageFinished(baseWebViewLayout, str);
this.aLZ = new Runnable() {
@Override
public void run() {
TaskManager.getInstance().checkViewNewsV2Task(TaskActions.VIEW_NEWS_V2, c.createViewNewsParams(InfoDetailActivity.this.mFrom), com.m4399.gamecenter.plugin.main.providers.g.a.NEWS + InfoDetailActivity.this.mNewsId);
}
};
e.postDelayed(this, this.aLZ, 3000L);
}
public void xg() {
com.m4399.gamecenter.plugin.main.manager.favorites.c.getInstance().checkIsFavorites(2, this.mNewsId, new Object[]{20}, this);
}
@Override
public void initJavascriptInterface(WebViewLayout webViewLayout) {
super.initJavascriptInterface(webViewLayout);
this.mLoginJsInterface.bindEvent("login", "");
}
@Override
public void onCreate(Bundle bundle) {
this.aMA = bundle == null;
super.onCreate(bundle);
this.biP = new com.m4399.gamecenter.plugin.main.providers.x.a();
xh();
RxBus.register(this);
UserGradeManager.getInstance().doExpTask(32);
if (SdkUtils.isStartBySdk((Activity) this)) {
UMengEventUtils.onEvent("sdk_jump_to_box", "SDK跳转到攻略");
}
}
@Override
protected WebViewLayout onCreateWebViewLayout(Context context) {
return new WebViewLayout(context) {
@Override
protected boolean enableProgressBar() {
return false;
}
};
}
@Override
public void onDestroy() {
super.onDestroy();
GameCommentJsInterface gameCommentJsInterface = this.apa;
if (gameCommentJsInterface != null) {
gameCommentJsInterface.onDestroy();
}
RxBus.unregister(this);
this.aLZ = null;
}
@Override
public void onStart() {
super.onStart();
if (this.biP.isDataLoaded()) {
return;
}
loadData();
}
@Override
public void initData(Intent intent) {
super.initData(intent);
this.mNewsId = intent.getIntExtra("intent.extra.information.news.id", 0);
this.mGameId = intent.getIntExtra("intent.extra.game.id", 0);
this.mFrom = intent.getStringExtra("intent.extra.from.key");
this.mPassthrough = intent.getStringExtra("intent.extra.passthrough");
this.aMz = intent.getBooleanExtra("intent.extra.favorite.show.guiding.bar", false);
this.mCommentId = intent.getIntExtra("intent.extra.comment.id", 0);
this.mReplyId = intent.getIntExtra("intent.extra.reply.id", 0);
if (IntentHelper.isStartByWeb(intent)) {
Map<String, String> uriParams = IntentHelper.getUriParams(intent);
if (uriParams.containsKey("id")) {
this.mNewsId = bc.toInt(uriParams.get("id"));
}
if (this.mNewsId == 0 && uriParams.containsKey("newsId")) {
this.mNewsId = bc.toInt(uriParams.get("newsId"));
}
if (uriParams.containsKey("gameId")) {
this.mGameId = bc.toInt(uriParams.get("gameId"));
}
}
StatManager.getInstance().onUserActionTraceEvent("goto_info_detail", StatManager.filterTrace(getPageTracer().getFullTrace()));
if (this.aMA) {
com.m4399.gamecenter.plugin.main.manager.stat.e.openInfoDetail(this.mNewsId, this.mGameId, 0, this.mPassthrough);
}
}
private void xh() {
this.biP.setGameID(this.mGameId);
this.biP.setNewsID(this.mNewsId);
}
@Override
protected int getLayoutID() {
return R.layout.m4399_activity_info_detail;
}
@Override
public void initView(Bundle bundle) {
super.initView(bundle);
xl();
this.biN = (LinearLayout) findViewById(com.m4399.support.R.id.root_layout);
this.biQ = (InfoDetailBottomView) findViewById(R.id.bottom_view);
this.biO = new View(this);
this.biO.setBackgroundColor(getResources().getColor(R.color.hei_000000));
((FrameLayout) getWindow().getDecorView()).addView(this.biO, 0);
xj();
}
private void xj() {
registerSubscriber(UserCenterManager.getInstance().asLoginStatusObservable().observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean bool) {
if (bool.booleanValue()) {
InfoDetailActivity.this.xg();
}
}
}));
}
private void loadData() {
this.biP.loadData(new IHaveResponseDataListener() {
@Override
public void onSubBefore() {
InfoDetailActivity.this.mWebView.progressStart();
InfoDetailActivity.this.isShowProgress = true;
}
@Override
public void onSubSuccess(JSONObject jSONObject) {
if (InfoDetailActivity.this.mWebView == null) {
return;
}
InfoDetailActivity.this.apa.setServerResponseData(jSONObject.toString());
v vVar = v.getInstance();
WebViewLayout webViewLayout = InfoDetailActivity.this.mWebView;
InfoDetailActivity infoDetailActivity = InfoDetailActivity.this;
vVar.loadTemplate(3, webViewLayout, null, new v.b(infoDetailActivity, infoDetailActivity.mWebView, 3));
InfoDetailActivity.this.xg();
InfoDetailActivity.this.xk();
BrowseRecordNewModel browseRecordNewModel = new BrowseRecordNewModel(2, InfoDetailActivity.this.biP.getInformationDetailModel().getNewsId(), "", InfoDetailActivity.this.biP.getInformationDetailModel().getTitle(), InfoDetailActivity.this.biP.getGameModel().getName());
browseRecordNewModel.setExtGameId(String.valueOf(InfoDetailActivity.this.biP.getGameModel().getId()));
com.m4399.gamecenter.plugin.main.providers.ad.a.record(browseRecordNewModel, 1, 2, 3);
InfoDetailActivity.this.xo();
}
@Override
public void onSubFailure(Throwable th, int i, String str, int i2, JSONObject jSONObject) {
if (InfoDetailActivity.this.biP.isEmpty()) {
InfoDetailActivity infoDetailActivity = InfoDetailActivity.this;
infoDetailActivity.onReceivedError(infoDetailActivity.mWebView, i, str, null);
} else {
InfoDetailActivity infoDetailActivity2 = InfoDetailActivity.this;
ToastUtils.showToast(infoDetailActivity2, HttpResultTipUtils.getFailureTip(infoDetailActivity2, th, i, str));
}
}
});
}
@Override
public void onNetErrorViewClick() {
this.mNetWorkErrorView.dismiss(this.mWebView);
loadData();
}
public void xk() {
this.biQ.setNewsId(this.mNewsId);
this.biQ.bindView(this.biP.getGameModel());
aY(!xn());
}
public void aY(boolean z) {
this.mWebView.setPadding(this.mWebView.getPaddingLeft(), this.mWebView.getPaddingTop(), this.mWebView.getPaddingRight(), z ? DensityUtils.dip2px(this, 48.67f) : 0);
}
private void xl() {
if (this.mWebView == null) {
return;
}
this.apa = new GameCommentJsInterface(this.mWebView, this) {
@Override
@JavascriptInterface
public void gallery(String str) {
JSONObject parseJSONObjectFromString = ap.parseJSONObjectFromString(str);
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
try {
if (parseJSONObjectFromString.has("list")) {
JSONArray jSONArray = parseJSONObjectFromString.getJSONArray("list");
int length = jSONArray.length();
for (int i = 0; i < length; i++) {
PicDetailModel picDetailModel = new PicDetailModel();
picDetailModel.parse(ap.getJSONObject(i, jSONArray));
picDetailModel.setPicReportModel(com.m4399.gamecenter.plugin.main.manager.chat.a.getInfoDetailReport(InfoDetailActivity.this.biP.getInformationDetailModel(), String.valueOf(InfoDetailActivity.this.mGameId), picDetailModel.getPicUrl()));
arrayList.add(picDetailModel);
}
int i2 = parseJSONObjectFromString.has("index") ? parseJSONObjectFromString.getInt("index") : 0;
Bundle bundle = new Bundle();
bundle.putInt("intent.extra.picture.detail.position", i2);
bundle.putParcelableArrayList("intent.extra.picture.url.list", arrayList);
GameCenterRouterManager.getInstance().openPictureDetail(this.mContext, bundle);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
this.apa.setNewsId(this.mNewsId);
int i = this.mCommentId;
if (i != 0) {
this.apa.addWebRequestParam("commentId", Integer.valueOf(i));
}
int i2 = this.mReplyId;
if (i2 != 0) {
this.apa.addWebRequestParam("replyId", Integer.valueOf(i2));
}
this.apa.setFrom("info_detail");
this.apa.addWebRequestParam("positionPage", 10);
this.apa.addWebRequestParam(CachesTable.COLUMN_KEY, Integer.valueOf(this.mNewsId));
this.mWebView.addJavascriptInterface(this.apa, "android");
this.mWebView.addWebViewClient();
if (this.mWebView.getWebView() != null) {
this.mWebView.getWebView().addOnScrollChangeListener(this);
}
}
@Override
public void initToolBar() {
super.initToolBar();
setTitle(R.string.info_detail);
getToolBar().setOnMenuItemClickListener(this);
xm();
getToolBar().setOverflowIcon(getResources().getDrawable(R.drawable.m4399_xml_selector_toolbar_item_more_black));
bq.trySetShowMenuIcon(getToolBar().getMenu());
}
@Override
public int getMenuID() {
return R.menu.m4399_menu_info_detail;
}
@Override
public void onChecked(boolean z) {
this.aKG = z;
this.biR = true;
if (getToolBar() != null) {
xm();
}
xo();
}
private void xm() {
if (getToolBar() == null || getToolBar().getMenu() == null) {
return;
}
MenuItem findItem = getToolBar().getMenu().findItem(R.id.m4399_menu_favorite);
findItem.setIcon(this.aKG ? R.mipmap.m4399_png_game_detail_tooltip_icon_collect_pressed : R.mipmap.m4399_png_game_detail_tooltip_icon_collect_nor);
findItem.setTitle(this.aKG ? R.string.menu_un_favorite : R.string.menu_favorite);
}
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == R.id.m4399_menu_favorite) {
com.m4399.gamecenter.plugin.main.manager.favorites.c.getInstance().setFavorite(this, 2, this.aKG, this.mNewsId, true, true, 20);
UMengEventUtils.onEvent("add_game_news", this.aKG ? "收藏" : "取消收藏");
} else if (itemId == R.id.m4399_menu_share) {
UMengEventUtils.onEvent("ad_game_news_share");
final ShareDataModel shareDataModel = this.biP.getShareDataModel();
d.openShareDialog(this, d.buildShareItemKind("information", shareDataModel.getShareItemKinds()), new com.m4399.gamecenter.plugin.main.controllers.share.b() {
@Override
public void onShareItemClick(ShareItemKind shareItemKind) {
d.share(InfoDetailActivity.this, shareDataModel, shareItemKind);
}
}, "ad_game_news_share", "资讯");
} else if (itemId == R.id.m4399_menu_report) {
Bundle bundle = new Bundle();
bundle.putInt("intent.extra.report.content.type", 24);
bundle.putParcelable("intent.extra.report.model.contain", com.m4399.gamecenter.plugin.main.manager.chat.a.getInfoDetailReport(this.biP.getInformationDetailModel(), String.valueOf(this.mGameId), null));
GameCenterRouterManager.getInstance().openReport(this, bundle);
}
return true;
}
@Keep
@Subscribe(tags = {@Tag("tag.Favorite.completed")})
public void onFavoriteResult(Bundle bundle) {
boolean z = bundle.getInt("intent.action.share.success") == 2;
boolean z2 = bundle.getInt("intent.extra.favorite.id") == this.mNewsId;
if (z && z2) {
this.aKG = bundle.getBoolean("intent.extra.is.favorite");
if (this.aKG) {
xp();
}
}
xm();
}
@Keep
@Subscribe(tags = {@Tag("tag.info.detail.comment")}, thread = EventThread.MAIN_THREAD)
public void updateInfoDetailComment(JSONObject jSONObject) {
if (JSONUtils.getInt("id", jSONObject) != this.mNewsId) {
return;
}
this.biQ.bindCommentCount(JSONUtils.getInt(GamePlayerVideoModel.COMMENT_NUM, jSONObject));
if (JSONUtils.getBoolean("web_ctrl_cmt_bar_show", jSONObject) || !xn()) {
showCommentBarIfNeed();
} else {
hideCommentBarIfNeed();
}
}
@Keep
@Subscribe(tags = {@Tag("tag.common.comment.praise")}, thread = EventThread.MAIN_THREAD)
public void praiseCommonComment(Bundle bundle) {
String string = bundle.getString("intent.extra.from.key");
if (TextUtils.isEmpty(string) || string.equals("info_detail")) {
return;
}
int i = bundle.getInt("intent.extra.comment.id");
k.executeJs(this.mWebView, "javascript:m_common.praiseSuccess(" + i + ")");
}
@Keep
@Subscribe(tags = {@Tag("fragment.add.comment")}, thread = EventThread.MAIN_THREAD)
public void processNewlyAddComment(Bundle bundle) {
if (this.mNewsId != bundle.getInt("intent.extra.information.news.id")) {
return;
}
int i = bundle.getInt("intent.extra.comment.action.type", 1);
String string = bundle.getString("intent.extra.comment.server.result");
k.executeJs(this.mWebView, (i == 1 ? k.JS_COMMON_ADD_COMMENT : k.JS_COMMON_REPLY_COMMENT) + "('" + string + "')");
if (i == 1) {
this.mWebView.scrollTo(0, 0);
}
}
@Override
public void onResume() {
com.m4399.gamecenter.plugin.main.providers.x.a aVar;
super.onResume();
this.mWebView.onResume();
LinearLayout linearLayout = this.biN;
if (linearLayout != null && linearLayout.getY() != 0.0f) {
this.biN.setY(0.0f);
}
InfoDetailBottomView infoDetailBottomView = this.biQ;
if (infoDetailBottomView != null && (aVar = this.biP) != null) {
infoDetailBottomView.bindView(aVar.getGameModel());
}
this.mViewStart = System.currentTimeMillis();
}
@Keep
@Subscribe(tags = {@Tag("tag.common.comment.reply")})
public void onCommonCmtReplySuccess(String str) {
E(k.JS_REPLY_COMMON_CMT_SUCCESS, str);
}
@Keep
@Subscribe(tags = {@Tag("tag.common.comment.del")})
public void removeCommonComment(String str) {
E(k.JS_DEL_COMMON_CMT, str);
}
private void E(String str, String str2) {
k.executeJs(this.mWebView, str + "('" + str2 + "')");
}
@Override
public void onPause() {
super.onPause();
this.mWebView.onPause();
com.m4399.gamecenter.plugin.main.manager.stat.e.viewInfoDetail(this.mNewsId, this.mGameId, 0, System.currentTimeMillis() - this.mViewStart, this.mPassthrough);
this.aMA = false;
this.aLZ = null;
}
public void startDismissAnim(boolean z) {
getWindow().getDecorView().animate().alpha(0.0f).setDuration(500L).start();
e.postDelayed(new Runnable() {
@Override
public void run() {
InfoDetailActivity.this.finish();
InfoDetailActivity.this.overridePendingTransition(0, 0);
}
}, 500L);
}
@Override
public void onPageTop(int i, int i2, int i3, int i4) {
FavoriteGuidingBar favoriteGuidingBar = this.biS;
if (favoriteGuidingBar != null) {
favoriteGuidingBar.showOrHide(true, this.mWebView);
}
}
@Override
public void onScrollChanged(int i, int i2, int i3, int i4) {
FavoriteGuidingBar favoriteGuidingBar = this.biS;
if (favoriteGuidingBar == null || i2 <= i4) {
return;
}
favoriteGuidingBar.showOrHide(false, this.mWebView);
}
public void showCommentBarIfNeed() {
AppUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
InfoDetailActivity.this.biQ.setVisibility(0);
InfoDetailActivity.this.aY(true);
}
});
}
public void hideCommentBarIfNeed() {
AppUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
if (InfoDetailActivity.this.xn()) {
InfoDetailActivity.this.biQ.setVisibility(8);
InfoDetailActivity.this.aY(false);
} else {
InfoDetailActivity.this.biQ.setVisibility(0);
InfoDetailActivity.this.aY(true);
}
}
});
}
public boolean xn() {
com.m4399.gamecenter.plugin.main.providers.x.a aVar = this.biP;
if (aVar == null || aVar.getGameModel() == null) {
return true;
}
return this.biP.getGameModel().isEmpty();
}
public void xo() {
if (!this.aMz) {
xp();
return;
}
if ((this.biP.isEmpty() ^ true) && (!UserCenterManager.isLogin().booleanValue() || (this.biR && !this.aKG))) {
if (this.biS == null) {
this.biS = new FavoriteGuidingBar(this);
this.biS.setFavoriteType(2).setFavoriteId(this.mNewsId).setExt(new Object[]{20}).setFavorite(false);
this.biS.addToWebView(this.mWebView);
return;
}
return;
}
xp();
}
private void xp() {
FavoriteGuidingBar favoriteGuidingBar = this.biS;
if (favoriteGuidingBar == null) {
return;
}
favoriteGuidingBar.removeFromWebView(this.mWebView);
this.biS = null;
}
}