大致完成模拟器游戏下载、模拟器下载与安装

This commit is contained in:
张玉久
2020-10-16 17:15:51 +08:00
parent 93126517b6
commit b1079e84d8
24 changed files with 560 additions and 257 deletions

View File

@ -9,14 +9,15 @@ import android.view.View;
import android.widget.TextView;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
import com.gh.common.dialog.CertificationDialog;
import com.gh.common.dialog.DeviceRemindDialog;
import com.gh.common.dialog.ReserveDialogFragment;
import com.gh.common.emulator.EmulatorDownloadManager;
import com.gh.common.emulator.EmulatorGameManager;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.history.HistoryHelper;
import com.gh.common.repository.ReservationRepository;
import com.gh.common.simulator.SimulatorDownloadManager;
import com.gh.common.simulator.SimulatorGameManager;
import com.gh.common.xapk.XapkInstaller;
import com.gh.common.xapk.XapkUnzipStatus;
import com.gh.download.DownloadManager;
@ -26,7 +27,6 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.EmulatorGameEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.LinkEntity;
import com.gh.gamecenter.entity.PluginLocation;
@ -227,9 +227,18 @@ public class DownloadItemUtils {
if (entryMap != null && !entryMap.isEmpty()) {
DownloadEntity downloadEntity = entryMap.get(apkEntity.getPlatform());
if (downloadEntity != null) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
return;
if (downloadEntity.getMeta().containsKey(Constants.EMULATOR_GAME)) {
if (downloadEntity.getStatus() != DownloadStatus.done) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
return;
}
} else {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
return;
}
}
}
@ -576,24 +585,26 @@ public class DownloadItemUtils {
});
}
} else if (str.equals(context.getString(R.string.install))) {
EmulatorGameEntity emulatorGameEntity = EmulatorGameManager.findGameByName(gameEntity.getName());
boolean isInstalled = PackageUtils.isInstalled(context, apk.getPackageName());
if (emulatorGameEntity != null && EmulatorGameManager.isEmulatorGame(apk.getFormat()) && !isInstalled) {
EmulatorDownloadManager.getInstance().showDownloadDialog(context, gameEntity);
return;
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.getUrl());
if (gameEntity.getSimulator() != null) {
boolean isInstalled = PackageUtils.isInstalled(context, gameEntity.getSimulator().getApk().getPackageName());
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
SimulatorDownloadManager.getInstance().showDownloadDialog(context, gameEntity.getSimulator());
return;
}
}
install(context, gameEntity, position, adapter);
} else if (str.equals(context.getString(R.string.launch))) {
//启动模拟器游戏
if (EmulatorGameManager.isEmulatorGame(gameEntity.getApk().get(0).getFormat())) {
EmulatorGameEntity emulatorGameEntity = EmulatorGameManager.findGameByName(gameEntity.getName());
if (emulatorGameEntity != null) {
File file = new File(emulatorGameEntity.getFilePath());
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
if (downloadEntity != null) {
File file = new File(downloadEntity.getPath());
if (!file.exists()) {
download(context, gameEntity, downloadBtn, entrance, location, false, traceEvent);
return;
}
ToastUtils.INSTANCE.showToast("启动模拟器游戏-" + emulatorGameEntity.getGameName());
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity);
}
return;
}