This commit is contained in:
chenjuntao
2025-01-21 17:24:32 +08:00
parent b37f247b14
commit 73f7bee3cc
3 changed files with 9 additions and 7 deletions

View File

@ -7,9 +7,6 @@ import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider
@com.therouter.inject.ServiceProvider
class RegionSettingHelperProviderImpl : IRegionSettingHelperProvider {
override fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean {
return RegionSettingHelper.shouldThisGameDisplayMirrorInfo(gameId)
}
override fun getMirrorPosition(gameId: String): Int {
return RegionSettingHelper.getMirrorPosition(gameId)

View File

@ -357,6 +357,8 @@ data class GameEntity(
// 本地字段,使用镜像信息
var useMirrorInfo: Boolean = false,
// 本地字段,已使用的镜像实体,一旦存在便不再变更
var cachedMirrorData: GameEntity? = null,
// 本地字段,最后打开时间
var lastPlayedTime: Long = 0,
@ -462,13 +464,17 @@ data class GameEntity(
* 获取镜像数据
*/
fun obtainMirrorData(): GameEntity? {
if (cachedMirrorData != null) {
return cachedMirrorData
}
val regionSettingProvider = TheRouter.get(IRegionSettingHelperProvider::class.java)
return when (regionSettingProvider?.getMirrorPosition(_id)) {
1 -> mMirrorData
2 -> mMirrorData2
else -> null
}
}?.also { cachedMirrorData = it }
}
@IgnoredOnParcel
@ -853,7 +859,8 @@ data class GameEntity(
} else {
val provider = TheRouter.get(IRegionSettingHelperProvider::class.java)
useMirrorInfo =
(mirrorStatus == "on" || mirrorStatus2 == "on") && provider?.shouldThisGameDisplayMirrorInfo(_id) == true
(mirrorStatus == "on" && mMirrorData != null) && provider?.getMirrorPosition(_id) == 1
|| (mirrorStatus2 == "on" && mMirrorData2 != null) && provider?.getMirrorPosition(_id) == 2
}
return useMirrorInfo

View File

@ -6,8 +6,6 @@ import com.gh.gamecenter.feature.entity.IpInfo
interface IRegionSettingHelperProvider {
fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean
fun getMirrorPosition(gameId: String): Int
fun shouldThisGameShowSpecialDownload(gameId: String): Boolean