|
@@ -14,6 +14,7 @@ import com.develop.food.base.http.observeStatus
|
|
|
import com.develop.food.base.repo.CURRENT_USER_ID
|
|
|
import com.develop.food.base.repo.FoodDataProvider
|
|
|
import com.develop.food.base.repo.entity.DevAccessory
|
|
|
+import com.develop.food.base.repo.entity.DevRecipeCategory
|
|
|
import com.develop.food.base.repo.entity.DevRecipePortionSize
|
|
|
import com.develop.food.base.repo.entity.UserOnLineRecipes
|
|
|
import com.develop.food.base.utils.DownloadUtil
|
|
@@ -193,11 +194,22 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- val jsonContent = FileKit.readFileToString(jsonFile)
|
|
|
+ val jsonContent = FileKit.readFileToStringB(jsonFile)
|
|
|
val contentData = Gson().fromJson(jsonContent, RecipeDataConfig::class.java)
|
|
|
//contentData.resetAllCodes()
|
|
|
FoodDataProvider.getDatabase().runInTransaction {
|
|
|
FoodDataProvider.getDatabase().recipeDao().apply {
|
|
|
+ val categorys = queryAllCategory()
|
|
|
+ val categoryMap = HashMap<String, DevRecipeCategory>()
|
|
|
+ for (category in categorys) {
|
|
|
+ categoryMap[category.number + ":" + category.lang] = category
|
|
|
+ }
|
|
|
+ for (devRecipeCategory in contentData.devRecipeCategorys) {
|
|
|
+ if (categoryMap.containsKey(devRecipeCategory.number + ":" + devRecipeCategory.lang)) {
|
|
|
+ devRecipeCategory.code =
|
|
|
+ categoryMap[devRecipeCategory.number + ":" + devRecipeCategory.lang]?.code.toString()
|
|
|
+ }
|
|
|
+ }
|
|
|
insertDevAccessorys(contentData.devAccessorys)
|
|
|
insertHotTags(contentData.devHotTags)
|
|
|
insertDevPortraits(contentData.devPortraits)
|