|
@@ -1,6 +1,7 @@
|
|
package com.develop.step.details
|
|
package com.develop.step.details
|
|
|
|
|
|
import android.app.Application
|
|
import android.app.Application
|
|
|
|
+import android.util.Log
|
|
import androidx.lifecycle.AndroidViewModel
|
|
import androidx.lifecycle.AndroidViewModel
|
|
import androidx.lifecycle.LiveData
|
|
import androidx.lifecycle.LiveData
|
|
import androidx.lifecycle.MutableLiveData
|
|
import androidx.lifecycle.MutableLiveData
|
|
@@ -14,6 +15,7 @@ import com.develop.food.base.http.observeStatus
|
|
import com.develop.food.base.repo.CURRENT_USER_ID
|
|
import com.develop.food.base.repo.CURRENT_USER_ID
|
|
import com.develop.food.base.repo.FoodDataProvider
|
|
import com.develop.food.base.repo.FoodDataProvider
|
|
import com.develop.food.base.repo.entity.DevAccessory
|
|
import com.develop.food.base.repo.entity.DevAccessory
|
|
|
|
+import com.develop.food.base.repo.entity.DevRecipe
|
|
import com.develop.food.base.repo.entity.DevRecipeCategory
|
|
import com.develop.food.base.repo.entity.DevRecipeCategory
|
|
import com.develop.food.base.repo.entity.DevRecipePortionSize
|
|
import com.develop.food.base.repo.entity.DevRecipePortionSize
|
|
import com.develop.food.base.repo.entity.UserOnLineRecipes
|
|
import com.develop.food.base.repo.entity.UserOnLineRecipes
|
|
@@ -196,7 +198,8 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
|
|
}
|
|
}
|
|
val jsonContent = FileKit.readFileToStringB(jsonFile)
|
|
val jsonContent = FileKit.readFileToStringB(jsonFile)
|
|
val contentData = Gson().fromJson(jsonContent, RecipeDataConfig::class.java)
|
|
val contentData = Gson().fromJson(jsonContent, RecipeDataConfig::class.java)
|
|
- contentData.resetAllCodes()
|
|
|
|
|
|
+ Log.d("jsonContent",jsonContent)
|
|
|
|
+ //contentData.resetAllCodes()
|
|
FoodDataProvider.getDatabase().runInTransaction {
|
|
FoodDataProvider.getDatabase().runInTransaction {
|
|
FoodDataProvider.getDatabase().recipeDao().apply {
|
|
FoodDataProvider.getDatabase().recipeDao().apply {
|
|
val categorys = queryAllCategory()
|
|
val categorys = queryAllCategory()
|
|
@@ -222,6 +225,7 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
|
|
insertDevRecipeRelTags(contentData.devRecipeRelTags)
|
|
insertDevRecipeRelTags(contentData.devRecipeRelTags)
|
|
insertDevRecipeTags(contentData.devRecipeTags)
|
|
insertDevRecipeTags(contentData.devRecipeTags)
|
|
insertDevRecipes(contentData.devRecipes)
|
|
insertDevRecipes(contentData.devRecipes)
|
|
|
|
+ Log.d("jsonContent",Gson().toJson(contentData.devRecipes[0]))
|
|
}
|
|
}
|
|
ThreadUtils.runOnMainThread {
|
|
ThreadUtils.runOnMainThread {
|
|
downloadResource.value = Resource(100, Resource.Status.SUCCESS)
|
|
downloadResource.value = Resource(100, Resource.Status.SUCCESS)
|
|
@@ -232,6 +236,7 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
|
|
FoodDataProvider.getUserDatabase().userInfoDao().insertOnlineRecipe(
|
|
FoodDataProvider.getUserDatabase().userInfoDao().insertOnlineRecipe(
|
|
UserOnLineRecipes(CURRENT_USER_ID, it.number ?: "")
|
|
UserOnLineRecipes(CURRENT_USER_ID, it.number ?: "")
|
|
)
|
|
)
|
|
|
|
+ Log.d("jsonContent","更新菜谱:${it.number}==${it.name}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|