4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.m4399.gamecenter.plugin.main.views.antifake;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Looper;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.dialog.Priority;
import com.dialog.b;
import com.download.DownloadChangedKind;
import com.download.DownloadChangedListener;
import com.download.DownloadHelper;
import com.download.DownloadManager;
import com.download.DownloadModel;
import com.download.OnPrepareListener;
import com.download.install.ApkInstaller;
import com.framework.helpers.ApkInstallHelper;
import com.framework.manager.network.NetworkStatusManager;
import com.framework.manager.storage.StorageVolume;
import com.framework.net.ILoadPageEventListener;
import com.framework.utils.ActivityStateUtils;
import com.framework.utils.UMengEventUtils;
import com.m4399.gamecenter.plugin.main.R;
import com.m4399.gamecenter.plugin.main.models.upgrade.AppUpgradeModel;
import com.m4399.gamecenter.plugin.main.utils.bp;
import com.m4399.gamecenter.plugin.main.utils.v;
import com.m4399.support.utils.ToastUtils;
import java.io.File;
import java.util.Map;
import org.json.JSONObject;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
public class a extends b implements View.OnClickListener, DownloadChangedListener {
private ProgressBar Zi;
private TextView eKK;
private TextView eKL;
private Button mDownloadBtn;
private View mLineView;
protected AppUpgradeModel mUpradeModel;
private boolean ZF() {
return true;
}
public a(Context context) {
super(context);
initView();
}
@Override
public void show() {
super.show();
UMengEventUtils.onEvent("app_main_guide_dialog_official_show", ZF() ? "包名未被篡改" : "包名被篡改");
}
protected void initView() {
View inflate = getLayoutInflater().inflate(R.layout.m4399_view_dialog_anti_fake, (ViewGroup) null);
setContentView(inflate);
TextView textView = (TextView) inflate.findViewById(R.id.tv_content);
this.Zi = (ProgressBar) inflate.findViewById(R.id.pb_download);
this.eKK = (TextView) inflate.findViewById(R.id.tv_download_progress);
this.eKL = (TextView) inflate.findViewById(R.id.tv_retry);
this.eKL.setOnClickListener(this);
this.mLineView = inflate.findViewById(R.id.v_line);
this.mDownloadBtn = (Button) inflate.findViewById(R.id.btn_download);
this.mDownloadBtn.setOnClickListener(this);
setCanceledOnTouchOutside(false);
setCancelable(false);
if (ZF()) {
textView.setText(Html.fromHtml(getContext().getString(R.string.dialog_anti_fake_content_2)));
this.mDownloadBtn.setText(R.string.dialog_anti_fake_btn_2);
((ViewStub) inflate.findViewById(R.id.vs_tips_2)).inflate();
} else {
textView.setText(Html.fromHtml(getContext().getString(R.string.dialog_anti_fake_content_1)));
this.mDownloadBtn.setText(R.string.dialog_anti_fake_btn_1);
((ViewStub) inflate.findViewById(R.id.vs_tips_1)).inflate();
}
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.btn_download) {
if (ZF()) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse("https://app.4399.cn/app-qd-cuangai.html"));
getContext().startActivity(intent);
} else {
ZK();
}
UMengEventUtils.onEvent("app_main_guide_dialog_official_click", ZF() ? "前往官网" : "立即安装");
return;
}
if (id == R.id.tv_retry) {
if (NetworkStatusManager.checkIsAvalible()) {
ZK();
return;
} else {
ToastUtils.showToast(getContext(), R.string.app_beta_activity_dialog_btn_retry_hint);
return;
}
}
if (id == R.id.btn_close) {
dismiss();
UMengEventUtils.onEvent("app_main_guide_dialog_official_click", "关闭");
}
}
@Override
public Priority getPriority() {
return Priority.High;
}
@Override
public void dismiss() {
DownloadModel downloadInfo;
super.dismiss();
if (this.mUpradeModel == null || (downloadInfo = DownloadManager.getInstance().getDownloadInfo(this.mUpradeModel.getPackageName())) == null) {
return;
}
downloadInfo.removeDownloadChangedListener(this);
DownloadManager.getInstance().pauseDownload(downloadInfo);
if (downloadInfo.isRuningTask()) {
ToastUtils.showToast(getContext(), R.string.download_stop);
}
}
public void ZG() {
this.mLineView.setVisibility(8);
this.mDownloadBtn.setVisibility(8);
this.Zi.setVisibility(0);
this.eKK.setVisibility(0);
this.eKL.setVisibility(8);
}
public void ZH() {
this.mLineView.setVisibility(8);
this.mDownloadBtn.setVisibility(8);
this.Zi.setVisibility(0);
this.eKK.setVisibility(8);
this.eKL.setVisibility(0);
}
private void ZI() {
this.mLineView.setVisibility(0);
this.mDownloadBtn.setVisibility(0);
this.Zi.setVisibility(8);
this.eKK.setVisibility(8);
this.eKL.setVisibility(8);
}
private void ZJ() {
ZI();
this.mDownloadBtn.setText(R.string.app_upgrade_zero_app_title);
}
private void bindDownloadingView(DownloadModel downloadModel) {
ZG();
this.Zi.setProgress(downloadModel.getThousandProgressNumber());
this.eKK.setText(bp.formatFileSizeTwoScale(downloadModel.getCurrentBytes()) + "/" + bp.formatFileSize(this.mUpradeModel.getDownloadSize()));
}
@Override
public void onDownloadChanged(final DownloadChangedKind downloadChangedKind, DownloadModel downloadModel) {
int status = downloadModel.getStatus();
if (Looper.myLooper() == Looper.getMainLooper()) {
if (downloadChangedKind == DownloadChangedKind.Progess) {
bindDownloadingView(downloadModel);
}
if (status == 4) {
ZJ();
doInstall();
return;
} else {
if (status == 7 || status == 12) {
ZH();
return;
}
return;
}
}
Observable.just(downloadModel).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<DownloadModel>() {
@Override
public void call(DownloadModel downloadModel2) {
a.this.onDownloadChanged(downloadChangedKind, downloadModel2);
}
});
}
public void doDownload() {
DownloadModel downloadInfo = DownloadManager.getInstance().getDownloadInfo(this.mUpradeModel.getPackageName());
if (downloadInfo != null) {
boolean equals = downloadInfo.getMDownUrl().equals(this.mUpradeModel.getMDownUrl());
boolean exists = new File(downloadInfo.getFileName()).exists();
if (equals && exists) {
if (downloadInfo.getStatus() == 4) {
ZJ();
doInstall();
return;
} else {
bindDownloadingView(downloadInfo);
downloadInfo.rmAddDownloadChangedListener(this);
DownloadManager.getInstance().resumeDownload(downloadInfo);
onDownloadChanged(DownloadChangedKind.Status, downloadInfo);
return;
}
}
if (equals && downloadInfo.isInstalledTask()) {
ApkInstallHelper.startApp(getContext(), com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME);
return;
}
DownloadManager.getInstance().cancelDownload(downloadInfo, false);
}
OnPrepareListener onPrepareListener = new OnPrepareListener(this.mUpradeModel);
onPrepareListener.setDownloadPriority(1);
StorageVolume checkStorage = DownloadHelper.checkStorage(onPrepareListener);
if (checkStorage != null) {
onPrepareListener.setStorageType(checkStorage.getStorageType());
DownloadModel doDownload = DownloadHelper.doDownload(null, onPrepareListener);
if (doDownload != null) {
v.addPageTrace(doDownload);
doDownload.rmAddDownloadChangedListener(this);
}
bindDownloadingView(doDownload);
if (NetworkStatusManager.checkIsWifi()) {
return;
}
ToastUtils.showToast(getContext(), R.string.download_hint_3g_remind_1);
return;
}
Toast.makeText(getContext(), com.upgrade.R.string.no_free_space, 1).show();
}
protected void doInstall() {
DownloadModel downloadInfo = DownloadManager.getInstance().getDownloadInfo(this.mUpradeModel.getPackageName());
if (downloadInfo != null) {
ApkInstaller.installAllApk(downloadInfo.getFileName());
}
}
private void ZK() {
if (com.m4399.gamecenter.plugin.main.manager.ab.a.getInstance().getInstalledApps().get(com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME) != null) {
ApkInstallHelper.startApp(getContext(), com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME);
return;
}
AppUpgradeModel appUpgradeModel = this.mUpradeModel;
if (appUpgradeModel == null || appUpgradeModel.isEmpty()) {
final com.m4399.gamecenter.plugin.main.providers.ba.a aVar = new com.m4399.gamecenter.plugin.main.providers.ba.a() {
@Override
public void buildRequestParams(String str, Map map) {
super.buildRequestParams(str, map);
map.put("package", com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME);
map.put("versionCode", 0);
}
@Override
public AppUpgradeModel newAppUpgradeModel(final String str) {
return new AppUpgradeModel(str) {
@Override
public String getPackageName() {
return isPlugin() ? this.mPluginModel.getPackageName() : com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME;
}
};
}
};
aVar.loadData(new ILoadPageEventListener() {
@Override
public void onBefore() {
a.this.ZG();
}
@Override
public void onSuccess() {
if (ActivityStateUtils.isDestroy(a.this.getContext())) {
return;
}
a.this.mUpradeModel = (AppUpgradeModel) aVar.getUpgradeModel();
if (a.this.mUpradeModel.isEmpty()) {
a.this.ZH();
} else {
a.this.doDownload();
}
}
@Override
public void onFailure(Throwable th, int i, String str, int i2, JSONObject jSONObject) {
if (ActivityStateUtils.isDestroy(a.this.getContext())) {
return;
}
a.this.ZH();
}
});
return;
}
DownloadModel downloadInfo = DownloadManager.getInstance().getDownloadInfo(this.mUpradeModel.getPackageName());
if (downloadInfo != null && downloadInfo.isInstalledTask()) {
ApkInstallHelper.startApp(getContext(), com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME);
} else {
doDownload();
}
}
}