From f47b0326f4899dfeec5da28d97839aabbd9cc56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=B6=9B?= Date: Tue, 8 Nov 2022 09:26:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E5=99=A8=E4=B8=8B=E8=BD=BD=E6=B5=81=E7=A8=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20https://jira.shanqu.cc/browse/GHZS-122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/common/util/DownloadItemUtils.kt | 8 ++++++-- .../com/gh/common/util/DownloadObserver.kt | 18 +++++++++++------- .../adapter/viewholder/DetailViewHolder.java | 7 ++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt b/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt index a8bdada5c6..874735b74d 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt @@ -787,6 +787,7 @@ object DownloadItemUtils { DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance) } else if (str == context.getString(R.string.attempt)) { ChainBuilder().apply { + addHandler(UpdateNewSimulatorHandler()) addHandler(GamePermissionHandler()) addHandler(BrowserInstallHandler()) addHandler(PackageCheckHandler()) @@ -844,8 +845,11 @@ object DownloadItemUtils { val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context) val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context) var simulator = gameEntity.simulator - if (!isInstalledOldSimulator) { - simulator = Config.getNewSimulatorEntitySetting() + val newSimulator = Config.getNewSimulatorEntitySetting() + if (!isInstalledOldSimulator && newSimulator != null) {//在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的 + if (newSimulator.active) { + simulator = newSimulator + } } if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) { SimulatorDownloadManager.getInstance().showDownloadDialog( diff --git a/app/src/main/java/com/gh/common/util/DownloadObserver.kt b/app/src/main/java/com/gh/common/util/DownloadObserver.kt index e21841dd47..a87dad8491 100644 --- a/app/src/main/java/com/gh/common/util/DownloadObserver.kt +++ b/app/src/main/java/com/gh/common/util/DownloadObserver.kt @@ -241,16 +241,20 @@ object DownloadObserver { val gameName = downloadEntity.getMetaExtra(Constants.GAME_NAME) if (simulatorJson.isEmpty()) return var simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java) - val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, simulator.apk?.packageName) - val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application) - val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application) + val isInstalled = PackageUtils.isInstalledFromAllPackage( + HaloApp.getInstance().application, + simulator.apk?.packageName + ) + val isInstalledNewSimulator = + SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application) + val isInstalledOldSimulator = + SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application) // if (!isInstalled && !isInstalledNewSimulator) { val currentActivity = AppManager.getInstance().currentActivity() ?: return - if (!isInstalledOldSimulator || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器 - Config.getNewSimulatorEntitySetting().let { - simulator = it!! - } + val newSimulator = Config.getNewSimulatorEntitySetting() + if ((!isInstalledOldSimulator && newSimulator != null && newSimulator.active) || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器 + simulator = newSimulator!! } SimulatorDownloadManager.getInstance().showDownloadDialog( currentActivity, simulator, diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java index a694cfbcbe..a4900a55dd 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java @@ -315,9 +315,10 @@ public class DetailViewHolder { boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(mViewHolder.context); boolean isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(mViewHolder.context); SimulatorEntity simulator = mGameEntity.getSimulator(); - if (!isInstalledOldSimulator){ - if (Config.getNewSimulatorEntitySetting() != null){ - simulator = Config.getNewSimulatorEntitySetting(); + SimulatorEntity newSimulator = Config.getNewSimulatorEntitySetting(); + if (!isInstalledOldSimulator && newSimulator != null) { + if (newSimulator.getActive()) { + simulator = newSimulator; } }