|
@@ -29,6 +29,7 @@ import com.develop.common.tag.CURRENT_LANGUAGE
|
|
import com.develop.common.tag.CURRENT_USER_ID
|
|
import com.develop.common.tag.CURRENT_USER_ID
|
|
import com.develop.common.utils.Resource
|
|
import com.develop.common.utils.Resource
|
|
import com.develop.step.ui.recipes_detail.model.CookDetailInfo
|
|
import com.develop.step.ui.recipes_detail.model.CookDetailInfo
|
|
|
|
+import com.develop.step.ui.recipes_detail.model.CookDetailInfoBean
|
|
import com.drake.net.Get
|
|
import com.drake.net.Get
|
|
import com.drake.net.Post
|
|
import com.drake.net.Post
|
|
import com.drake.net.component.Progress
|
|
import com.drake.net.component.Progress
|
|
@@ -49,11 +50,13 @@ class CookDetailViewModel : BaseViewModel() {
|
|
private var mRecipeUrl: String? = null
|
|
private var mRecipeUrl: String? = null
|
|
var cookDetailInfo :CookDetailInfo? = null
|
|
var cookDetailInfo :CookDetailInfo? = null
|
|
|
|
|
|
- //原始数据,用于做翻译功能
|
|
|
|
- var cookDetailInfoInit :CookDetailInfo? = null
|
|
|
|
|
|
+// //原始数据,用于做翻译功能
|
|
|
|
+// var cookDetailInfoInit :CookDetailInfoBean? = null
|
|
//是否线上菜谱
|
|
//是否线上菜谱
|
|
var isRemote = false
|
|
var isRemote = false
|
|
|
|
|
|
|
|
+ var language = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 数据源: 食谱编号
|
|
* 数据源: 食谱编号
|
|
@@ -82,7 +85,14 @@ class CookDetailViewModel : BaseViewModel() {
|
|
devRecipeNutritions,
|
|
devRecipeNutritions,
|
|
devRecipePortionSizes
|
|
devRecipePortionSizes
|
|
)
|
|
)
|
|
- cookDetailInfoInit = cookDetailInfo
|
|
|
|
|
|
+// cookDetailInfoInit = CookDetailInfoBean(
|
|
|
|
+// devRecipe,
|
|
|
|
+// devAccessorys,
|
|
|
|
+// devRecipeFoods,
|
|
|
|
+// devRecipeNutritions,
|
|
|
|
+// devRecipePortionSizes
|
|
|
|
+// )
|
|
|
|
+
|
|
portionSizeLiveData.postValue(cookDetailInfo?.portionSize?.firstOrNull())
|
|
portionSizeLiveData.postValue(cookDetailInfo?.portionSize?.firstOrNull())
|
|
recipeLiveData.postValue(cookDetailInfo)
|
|
recipeLiveData.postValue(cookDetailInfo)
|
|
}
|
|
}
|
|
@@ -120,7 +130,13 @@ class CookDetailViewModel : BaseViewModel() {
|
|
includeNutrition,
|
|
includeNutrition,
|
|
includePortionSize
|
|
includePortionSize
|
|
)
|
|
)
|
|
- cookDetailInfoInit = cookDetailInfo
|
|
|
|
|
|
+// cookDetailInfoInit = CookDetailInfoBean(
|
|
|
|
+// recipeBean,
|
|
|
|
+// includeAccessory,
|
|
|
|
+// includeMaterial,
|
|
|
|
+// includeNutrition,
|
|
|
|
+// includePortionSize
|
|
|
|
+// )
|
|
portionSizeLiveData.postValue(cookDetailInfo?.portionSize?.firstOrNull())
|
|
portionSizeLiveData.postValue(cookDetailInfo?.portionSize?.firstOrNull())
|
|
recipeLiveData.postValue(cookDetailInfo)
|
|
recipeLiveData.postValue(cookDetailInfo)
|
|
}
|
|
}
|
|
@@ -144,7 +160,7 @@ class CookDetailViewModel : BaseViewModel() {
|
|
}
|
|
}
|
|
|
|
|
|
fun jsonTranslate (jsons: String,value: String){
|
|
fun jsonTranslate (jsons: String,value: String){
|
|
-
|
|
|
|
|
|
+ language = value
|
|
var jsonObject = JSONObject(jsons)
|
|
var jsonObject = JSONObject(jsons)
|
|
var jsonArray = jsonObject.getJSONArray(value)
|
|
var jsonArray = jsonObject.getJSONArray(value)
|
|
var size = jsonArray.length()-1
|
|
var size = jsonArray.length()-1
|
|
@@ -180,15 +196,14 @@ class CookDetailViewModel : BaseViewModel() {
|
|
|
|
|
|
|
|
|
|
fun setTranslateDate(value :String):String{
|
|
fun setTranslateDate(value :String):String{
|
|
- var language = MMkvUtils.getString(CURRENT_LANGUAGE)?:""
|
|
|
|
var listLanguage = mutableListOf<String>()
|
|
var listLanguage = mutableListOf<String>()
|
|
listLanguage.add(value)
|
|
listLanguage.add(value)
|
|
|
|
|
|
var translateList = mutableListOf<TranslateBean>()
|
|
var translateList = mutableListOf<TranslateBean>()
|
|
- translateList.add(TranslateBean("name",cookDetailInfoInit?.recipe?.name))
|
|
|
|
- translateList.add(TranslateBean("introduction",cookDetailInfoInit?.recipe?.introduction))
|
|
|
|
- translateList.add(TranslateBean("difficulty",cookDetailInfoInit?.recipe?.difficultyLevel))
|
|
|
|
- var size = cookDetailInfoInit?.material?.size?:0
|
|
|
|
|
|
+ translateList.add(TranslateBean("name",cookDetailInfo?.recipe?.name))
|
|
|
|
+ translateList.add(TranslateBean("introduction",cookDetailInfo?.recipe?.introduction))
|
|
|
|
+ translateList.add(TranslateBean("difficulty",cookDetailInfo?.recipe?.difficultyLevel))
|
|
|
|
+ var size = cookDetailInfo?.material?.size?:0
|
|
|
|
|
|
if (size>0){
|
|
if (size>0){
|
|
size--
|
|
size--
|
|
@@ -196,7 +211,7 @@ class CookDetailViewModel : BaseViewModel() {
|
|
|
|
|
|
for (i in 0..size){
|
|
for (i in 0..size){
|
|
// DevRecipeFood
|
|
// DevRecipeFood
|
|
- var material = cookDetailInfoInit?.material?.get(i)
|
|
|
|
|
|
+ var material = cookDetailInfo?.material?.get(i)
|
|
material?.let {
|
|
material?.let {
|
|
translateList.add(TranslateBean("foodname_"+i, it.foodName ?: ""))
|
|
translateList.add(TranslateBean("foodname_"+i, it.foodName ?: ""))
|
|
}
|
|
}
|