Selaa lähdekoodia

提交人:jtm
提交内容:资源下载路径

江天明 1 vuosi sitten
vanhempi
commit
7795972405

+ 5 - 5
BusinessCommon/src/main/java/com/develop/common/data_repo/FoodDataProvider.kt

@@ -87,16 +87,16 @@ object FoodDataProvider {
                 try {
                     var targetZipFile = ZIP_PATH
                     val start = System.currentTimeMillis()
-                    ZipUtils.unzipFile(targetZipFile, RES_DST_PATH)
+                    ZipUtils.unzipFile(targetZipFile, TARGET_DST_PARENT)
                     Log.d(
                         "FoodDataProvider", "cost time:${System.currentTimeMillis() - start}"
                     )
-                    val sqliteFile = File(RES_DST_PATH, "sqlite.db")
+                    val sqliteFile = File(TARGET_DST_PARENT, "sqlite.db")
                     if (!sqliteFile.exists() || sqliteFile.length() == 0L) {
                         // 1s后再重试
                         Thread.sleep(1000)
-                        FileUtils.delete(RES_DST_PATH)
-                        ZipUtils.unzipFile(targetZipFile, RES_DST_PATH)
+                        FileUtils.delete(TARGET_DST_PARENT)
+                        ZipUtils.unzipFile(targetZipFile, TARGET_DST_PARENT)
                     }
                     validateDatabaseFile()
                 } catch (ex: Exception) {
@@ -196,7 +196,7 @@ object FoodDataProvider {
             return relativePath
         }
 //        preparedLock.await()
-        return "${RES_DST_PATH.absolutePath}/$relativePath"
+        return "${TARGET_DST_PARENT.absolutePath}/$relativePath"
     }
 
     private fun getResource(relativePath: String): File {

+ 4 - 2
BusinessMain/src/main/java/com/develop/main/viewmodel/HomeViewModel.kt

@@ -86,7 +86,7 @@ class HomeViewModel : BaseViewModel() {
     private var lastLocalSearchRecipeList = mutableListOf<DevRecipe>()
     private var lastLocalSearchFoodList = mutableListOf<DevRecipe>()
     private var localFavoriteRecipesList = mutableListOf<UserFavoriteRecipes>()
-     var lastSearchCategoryType = CategoryType.All
+    var lastSearchCategoryType = CategoryType.All
 
     private var recipeCount = 0
     private var foodCount = 0
@@ -103,13 +103,15 @@ class HomeViewModel : BaseViewModel() {
             result.forEach {
                 val size = FoodDataProvider.getDatabase().recipeDao()
                     .queryRecipesByCategory(it.number ?: "").size
-                allSize += size
                 categorySizeList[it.number ?: ""] = if (size.toString() == "null") {
                     "0"
                 } else {
                     size.toString()
                 }
             }
+            categorySizeList.forEach {
+                allSize += it.value.toInt()
+            }
             categorySizeList[globalApp().getString(com.develop.common.R.string.all)] =
                 allSize.toString()
             localCategoryLiveData.postValue(result)