Bladeren bron

sdk更新

wbspool 1 jaar geleden
bovenliggende
commit
74ff83f3bf

+ 19 - 36
BusinessCommon/src/main/java/com/develop/common/utils/AppVersionUtil.kt

@@ -2,13 +2,16 @@ package com.develop.common.utils
 
 import android.annotation.SuppressLint
 import android.app.Application
+import android.content.Context
 import android.net.Uri
 import android.os.PowerManager
 import android.provider.Settings
+import androidx.core.content.ContextCompat.getSystemService
 import com.azhon.appupdate.listener.OnDownloadListener
 import com.azhon.appupdate.util.LogUtil
 import com.blankj.utilcode.util.FileUtils
 import com.blankj.utilcode.util.ZipUtils
+import com.develop.base.ext.fromJson
 import com.develop.base.ext.globalApp
 import com.develop.base.util.FileKit
 import com.develop.base.util.GlobalToast
@@ -26,7 +29,6 @@ import com.develop.common.data_repo.net.model.response.RecipeDataConfig
 import com.develop.common.dialog.CancelConfirmDialog
 import com.develop.common.dialog.CommonDialog
 import com.develop.common.dialog.RecipeUpdateDialog
-import com.develop.common.event.RefreshDataEvent
 import com.develop.common.tag.SCREENSAVER
 import com.drake.net.Get
 import com.drake.net.Post
@@ -60,13 +62,15 @@ object AppVersionUtil {
                         cancelConfirmDialog.title =
                             getString(com.develop.common.R.string.update_title)
                         cancelConfirmDialog.showDialog(
-                            supportFragmentManager, "cancelConfirmDialog"
+                            supportFragmentManager,
+                            "cancelConfirmDialog"
                         )
                         cancelConfirmDialog.onDialogClickListener =
                             object : CancelConfirmDialog.OnDialogClickListener {
                                 override fun onConfirm() {
                                     commonDialog.showDialog(supportFragmentManager, "commonDialog")
-                                    UpdateUtil.updateApp(this@apply,
+                                    UpdateUtil.updateApp(
+                                        this@apply,
                                         result.apkUrl,
                                         object : OnDownloadListener {
                                             override fun cancel() {
@@ -198,27 +202,8 @@ object AppVersionUtil {
 
         TopResumedAtyHolder.getCurrentActivity()?.apply {
             if (newRecipes.isEmpty()) {
-                saveRecipeUpdateTime(recipeUpdateTime)
-                scopeNetLife {
-                    //判断是否还有新菜谱
-                    val result = Post<DevInfoResult>(Api.DEV_INFO) {
-                        body = DeviceInfoBody.genDeviceInfoBody()
-                    }.await()
-
-                    val ut = result.recipeUpdateTime
-                    val nr = LinkedList(result.newRecipes)
-                    if (!nr.isEmpty()) {
-                       downloadRecipes(nr,recipeUpdateDialog,
-                           nr.size.toLong(),downloadDir,downloadName,ut)
-                        return@scopeNetLife
-                    }else{
-                        recipeUpdateDialog.removeSelf()
-                        showRecipesUpdateDialog(recipeUpdateTime)
-                    }
-                }
-
-
-
+                recipeUpdateDialog.removeSelf()
+                showRecipesUpdateDialog(recipeUpdateTime)
                 return
             }
 
@@ -276,7 +261,7 @@ object AppVersionUtil {
             }
             val jsonContent = FileKit.readFileToString(jsonFile)
             val contentData = jsonDecoder.decodeFromString<RecipeDataConfig>(jsonContent)
-            // contentData.resetAllCodes()
+            contentData.resetAllCodes()
             FoodDataProvider.getDatabase().runInTransaction {
                 FoodDataProvider.getDatabase().recipeDao().apply {
 
@@ -322,29 +307,27 @@ object AppVersionUtil {
     }
 
 
-    private fun saveRecipeUpdateTime(recipeUpdateTime: Long?) {
-        val v =
-            FoodDataProvider.getUserDatabase().devConfigDao().recipeVersion() ?: DevVersion(0, 0)
-        v.recipeUpdateTime = recipeUpdateTime
-        FoodDataProvider.getUserDatabase().devConfigDao().saveDevVersion(v)
-    }
-
     private fun showRecipesUpdateDialog(recipeUpdateTime: Long?) {
         TopResumedAtyHolder.getCurrentActivity()?.apply {
             val minute = MMkvUtils.getInt(SCREENSAVER)
             if (minute != 0) {
                 Settings.System.putInt(
-                    contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, 1000 * 60 * minute
+                    contentResolver,
+                    Settings.System.SCREEN_OFF_TIMEOUT,
+                    1000 * 60 * minute
                 )
-                val uri: Uri = Settings.System.getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
+                val uri: Uri = Settings.System
+                    .getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
                 contentResolver.notifyChange(uri, null)
             }
             EventBus.getDefault().post(NoScreenEvent(false))
-            EventBus.getDefault().post(RefreshDataEvent())
             RecipeUpdateDialog().apply {
                 onDialogClickListener = object : RecipeUpdateDialog.OnDialogClickListener {
                     override fun onConfirm() {
-                        saveRecipeUpdateTime(recipeUpdateTime)
+                        val v = FoodDataProvider.getUserDatabase().devConfigDao().recipeVersion()
+                            ?: DevVersion(0, 0)
+                        v.recipeUpdateTime = recipeUpdateTime
+                        FoodDataProvider.getUserDatabase().devConfigDao().saveDevVersion(v)
                         removeSelf()
                     }
 

BIN
libThirdPart/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar