优化
This commit is contained in:
@@ -988,7 +988,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
params["foodVector"] = foodVectorJson.toRequestBody()
|
params["foodVector"] = foodVectorJson.toRequestBody()
|
||||||
val idList = viewModel.uploadCollectFoodPics(files, params)
|
val idList = viewModel.uploadCollectFoodPics(files, params)
|
||||||
if (idList.isNullOrEmpty()) {
|
if (idList.isNullOrEmpty()) {
|
||||||
loadRemindDialog("未返回id")
|
loadRemindDialog("上传失败,未返回向量数据id")
|
||||||
Timber.tag(TAG).d("idList为空")
|
Timber.tag(TAG).d("idList为空")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,8 @@ class CollectFragment : BaseFragment<FragmentCollectBinding>() {
|
|||||||
ToastUtils.showToast("请选择菜品名称")
|
ToastUtils.showToast("请选择菜品名称")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
if (foodCollectionList.size <= 1) {
|
val count = foodCollectionList.count { it.imageFile != null }
|
||||||
|
if (count == 0) {
|
||||||
ToastUtils.showToast("请拍摄菜品照片")
|
ToastUtils.showToast("请拍摄菜品照片")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ object UserNutritionUtils {
|
|||||||
|
|
||||||
// 处理食物信息
|
// 处理食物信息
|
||||||
if (weight > 0.0) {
|
if (weight > 0.0) {
|
||||||
calorie = calculateValue2(foodInfo.calorie,foodInfo.specWeight, weight)
|
calorie = calculateValue2(foodInfo.calorie,weight)
|
||||||
grain = calculateValue2(foodInfo.stapleFood, foodInfo.specWeight,weight)
|
grain = calculateValue2(foodInfo.stapleFood, weight)
|
||||||
fruitsVegetables = calculateValue2(foodInfo.fruitsVegetables, foodInfo.specWeight,weight)
|
fruitsVegetables = calculateValue2(foodInfo.fruitsVegetables, weight)
|
||||||
meatEggs = calculateValue2(foodInfo.meatEggs, foodInfo.specWeight,weight)
|
meatEggs = calculateValue2(foodInfo.meatEggs, weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 合并用户数据
|
// 合并用户数据
|
||||||
@@ -142,9 +142,9 @@ object UserNutritionUtils {
|
|||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun calculateValue2(nutrient: Double?, specWeight: Double?, weight: Double): Double {
|
private fun calculateValue2(nutrient: Double?, weight: Double): Double {
|
||||||
if ((nutrient?:0.0) == 0.0 || (specWeight?:0.0) == 0.0) return 0.0
|
if ((nutrient?:0.0) == 0.0) return 0.0
|
||||||
return nutrient!! * weight / specWeight!!
|
return nutrient!! * weight / 100.0
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 计算每百克含量
|
* 计算每百克含量
|
||||||
|
|||||||
Reference in New Issue
Block a user