Jelajahi Sumber

完善空炸功能

wbspool 1 tahun lalu
induk
melakukan
424dd0f90e

+ 45 - 37
BusinessCommon/src/main/java/com/develop/common/utils/AppVersionUtil.kt

@@ -24,52 +24,60 @@ import java.util.*
 object AppVersionUtil {
 
     fun checkRecipeUpdate(shoNoUpdateDialog: Boolean = false) {
+
         TopResumedAtyHolder.getCurrentActivity()?.apply {
             scopeNetLife {
-                val result = Post<DevInfoResult>(Api.DEV_INFO) {
-                    body = DeviceInfoBody.genDeviceInfoBody()
-                }.await()
-                val downloadDir = this@apply.externalCacheDir.toString()
-                val downloadName = System.nanoTime().toString()
-                val recipeUpdateTime = result.recipeUpdateTime
-                val newRecipes = LinkedList(result.newRecipes)
-                if (newRecipes.isEmpty() && shoNoUpdateDialog) {
-                    val dialog = RecipeUpdateDialog()
-                    dialog.onDialogClickListener =
-                        object : RecipeUpdateDialog.OnDialogClickListener {
-                            override fun onConfirm() {
 
+                try {
+                    val result = Post<DevInfoResult>(Api.DEV_INFO) {
+                        body = DeviceInfoBody.genDeviceInfoBody()
+                    }.await()
+                    val downloadDir = this@apply.externalCacheDir.toString()
+                    val downloadName = System.nanoTime().toString()
+                    val recipeUpdateTime = result.recipeUpdateTime
+                    val newRecipes = LinkedList(result.newRecipes)
+                    if (newRecipes.isEmpty() && shoNoUpdateDialog) {
+                        val dialog = RecipeUpdateDialog()
+                        dialog.onDialogClickListener =
+                            object : RecipeUpdateDialog.OnDialogClickListener {
+                                override fun onConfirm() {
+
+                                }
+
+                                override fun onCancel() {
+                                }
                             }
+                        dialog.showNoUpdateTips(supportFragmentManager, "RECIPE_UPDATE_DIALOG")
 
-                            override fun onCancel() {
-                            }
-                        }
-                    dialog.showNoUpdateTips(supportFragmentManager, "RECIPE_UPDATE_DIALOG")
+                    }
+                    if (newRecipes.isNotEmpty()) {
+                        val dialog = RecipeUpdateDialog()
+                        dialog.onDialogClickListener =
+                            object : RecipeUpdateDialog.OnDialogClickListener {
+                                override fun onConfirm() {
+                                    downloadRecipes(
+                                        newRecipes,
+                                        dialog,
+                                        newRecipes.size.toLong(),
+                                        downloadDir,
+                                        downloadName,
+                                        recipeUpdateTime
+                                    )
+                                }
+
+                                override fun onCancel() {
+                                }
 
-                }
-                if (newRecipes.isNotEmpty()) {
-                    val dialog = RecipeUpdateDialog()
-                    dialog.onDialogClickListener =
-                        object : RecipeUpdateDialog.OnDialogClickListener {
-                            override fun onConfirm() {
-                                downloadRecipes(
-                                    newRecipes,
-                                    dialog,
-                                    newRecipes.size.toLong(),
-                                    downloadDir,
-                                    downloadName,
-                                    recipeUpdateTime
-                                )
                             }
+                        dialog.showUpdateTips(
+                            supportFragmentManager, "RECIPE_UPDATE_DIALOG", newRecipes.size.toLong()
+                        )
+                    }
+                }catch (e:java.lang.Exception){
+                    e.printStackTrace()
+                }
 
-                            override fun onCancel() {
-                            }
 
-                        }
-                    dialog.showUpdateTips(
-                        supportFragmentManager, "RECIPE_UPDATE_DIALOG", newRecipes.size.toLong()
-                    )
-                }
             }
 
         }