|
@@ -842,7 +842,6 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
if (gamePackageUrl.isEmpty() || gameVersionCode.isEmpty()) {
|
|
if (gamePackageUrl.isEmpty() || gameVersionCode.isEmpty()) {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
-
|
|
|
|
val zipNames = gamePackageUrl.split("/")
|
|
val zipNames = gamePackageUrl.split("/")
|
|
val gameName = zipNames.last()
|
|
val gameName = zipNames.last()
|
|
if (TextUtils.isEmpty(UrlConstant.appGameRootPath) || !File(UrlConstant.appGameRootPath + File.separator + gameId).exists()) {
|
|
if (TextUtils.isEmpty(UrlConstant.appGameRootPath) || !File(UrlConstant.appGameRootPath + File.separator + gameId).exists()) {
|
|
@@ -853,12 +852,23 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
downLoadGamePackage(gameId, gamePackageUrl, gameVersionCode, gameName)
|
|
downLoadGamePackage(gameId, gamePackageUrl, gameVersionCode, gameName)
|
|
false
|
|
false
|
|
} else {
|
|
} else {
|
|
|
|
+ if(!File(UrlConstant.appGameRootPath + File.separator + gameId + File.separator + "index.html").exists()){
|
|
|
|
+ val t = UrlConstant.appGameRootPath + File.separator + gameId
|
|
|
|
+ val packagePath = UrlConstant.appGameRootPath + File.separator + gameId + File.separator + gameName
|
|
|
|
+ FileUtil.upZipFile(packagePath, t + File.separator)
|
|
|
|
+ }
|
|
val localGameVersionCode = SpUtil.readInt(gameId)
|
|
val localGameVersionCode = SpUtil.readInt(gameId)
|
|
if (localGameVersionCode == 0 || (gameVersionCode.isNotEmpty() && localGameVersionCode < gameVersionCode.toInt())) {
|
|
if (localGameVersionCode == 0 || (gameVersionCode.isNotEmpty() && localGameVersionCode < gameVersionCode.toInt())) {
|
|
downLoadGamePackage(gameId, gamePackageUrl, gameVersionCode, gameName)
|
|
downLoadGamePackage(gameId, gamePackageUrl, gameVersionCode, gameName)
|
|
false
|
|
false
|
|
} else {
|
|
} else {
|
|
- true
|
|
|
|
|
|
+ if(File(UrlConstant.appGameRootPath + File.separator + gameId + File.separator + "index.html").exists()){
|
|
|
|
+ true
|
|
|
|
+ }else{
|
|
|
|
+ downLoadGamePackage(gameId, gamePackageUrl, gameVersionCode, gameName)
|
|
|
|
+ false
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -921,15 +931,24 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
override fun fetchStart(task: DownloadTask, blockIndex: Int, contentLength: Long) {}
|
|
override fun fetchStart(task: DownloadTask, blockIndex: Int, contentLength: Long) {}
|
|
|
|
|
|
- override fun fetchProgress(task: DownloadTask, blockIndex: Int, increaseBytes: Long) {}
|
|
|
|
|
|
+ override fun fetchProgress(task: DownloadTask, blockIndex: Int, increaseBytes: Long) {
|
|
|
|
+ Log.d("进度条","fetchProgress--$increaseBytes---$blockIndex")
|
|
|
|
+ }
|
|
|
|
|
|
- override fun fetchEnd(task: DownloadTask, blockIndex: Int, contentLength: Long) {}
|
|
|
|
|
|
+ override fun fetchEnd(task: DownloadTask, blockIndex: Int, contentLength: Long) {
|
|
|
|
+ Log.d("进度条","fetchEnd--$contentLength---$blockIndex")
|
|
|
|
+ }
|
|
|
|
|
|
override fun taskEnd(task: DownloadTask, cause: EndCause, realCause: Exception?) {
|
|
override fun taskEnd(task: DownloadTask, cause: EndCause, realCause: Exception?) {
|
|
|
|
+ if (cause.name == EndCause.SAME_TASK_BUSY.name){
|
|
|
|
+ task.cancel()
|
|
|
|
+ }
|
|
|
|
+ Log.d("进度条","taskEnd--${cause.name}")
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
val packagePath = path + File.separator + name
|
|
val packagePath = path + File.separator + name
|
|
FileUtil.upZipFile(packagePath, path + File.separator)
|
|
FileUtil.upZipFile(packagePath, path + File.separator)
|
|
SpUtil.putInt(gameId, gameVersionCode.toInt())
|
|
SpUtil.putInt(gameId, gameVersionCode.toInt())
|
|
|
|
+ Log.d("游戏下载","${gameId}----${gameVersionCode}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|