清理了上一次的信息
This commit is contained in:
@@ -6,7 +6,7 @@ package com.sw.dualscreen.ext
|
||||
* 多于2个字:张*某
|
||||
*/
|
||||
fun String?.maskName(): String {
|
||||
if (this == null || this.isEmpty()) return ""
|
||||
if (this == null || this.isEmpty()) return "-"
|
||||
|
||||
return when {
|
||||
length == 2 -> "${this[0]}*"
|
||||
|
||||
@@ -157,7 +157,10 @@ class SecondaryScreenPresentation(
|
||||
Timber.d("step1")
|
||||
currentStep = 1
|
||||
//回复上一次的设置
|
||||
lastWeight = 0.0
|
||||
// lastWeight = 0.0
|
||||
dinnerTypeInfo = null
|
||||
currentFood = null
|
||||
userNutritionData = null
|
||||
lastFood = null
|
||||
lastCalcResultInfo = null
|
||||
recognitionWeight = 0.0
|
||||
@@ -189,7 +192,7 @@ class SecondaryScreenPresentation(
|
||||
binding.flPreview.visibility = View.GONE
|
||||
|
||||
binding.flFace.visibility = View.VISIBLE
|
||||
binding.ivFaceBg.visibility = View.GONE
|
||||
binding.ivFaceBg.visibility = View.VISIBLE
|
||||
binding.tvFaceTip.visibility = View.VISIBLE
|
||||
binding.tvBottomTip.visibility = View.VISIBLE
|
||||
itemUserNutritionBinding.clNutritionData.visibility = View.GONE
|
||||
|
||||
@@ -20,6 +20,7 @@ object UserNutritionUtils {
|
||||
weight: Double,
|
||||
dinnerType: String
|
||||
): CalcResultInfo {
|
||||
|
||||
// 初始化变量
|
||||
var foodKcal = 0.0
|
||||
var totalKcal = 0.0
|
||||
@@ -27,7 +28,7 @@ object UserNutritionUtils {
|
||||
|
||||
// 处理食物信息
|
||||
foodKcal = calculateValue(foodInfo.stFoodInfoMaterial?.energyKcal, weight)
|
||||
|
||||
Timber.d("calculateNutrition foodKcal = ${foodKcal}, energyKcal = ${foodInfo.stFoodInfoMaterial?.energyKcal}, weight = $weight")
|
||||
grain = calculateValue(foodInfo.stFoodInfoPagodaAPPVO?.grainValue(), weight)
|
||||
fruits = calculateValue(foodInfo.stFoodInfoPagodaAPPVO?.fruitsValue(), weight)
|
||||
vegetable = calculateValue(foodInfo.stFoodInfoPagodaAPPVO?.vegetableValue(), weight)
|
||||
@@ -35,18 +36,20 @@ object UserNutritionUtils {
|
||||
|
||||
// 合并用户数据
|
||||
grain += userModel.stFoodInfoPagoda?.grainValue() ?: 0.0
|
||||
|
||||
fruits += userModel.stFoodInfoPagoda?.fruitsValue() ?: 0.0
|
||||
vegetable = vegetable.plus(userModel.stFoodInfoPagoda?.vegetableValue() ?: 0.0)
|
||||
meat += userModel.stFoodInfoPagoda?.meatValue() ?: 0.0
|
||||
|
||||
totalKcal = foodKcal + userModel.energyValue()
|
||||
Timber.d("calculateNutrition totalKcal = ${totalKcal}, energyValue = ${userModel.energyValue()}")
|
||||
if (totalKcal < 0){
|
||||
totalKcal = 0.0
|
||||
}
|
||||
// 判断当餐最大热量
|
||||
val maxKcal =
|
||||
userModel.totalEnergyCalculateScoreValue() * calculateDinnerTypeRatio(dinnerType) / 10
|
||||
|
||||
Timber.d("calculateNutrition maxKcal = ${maxKcal}, CalculateScoreValue = ${userModel.totalEnergyCalculateScoreValue()}")
|
||||
val pagoda = userModel.stFoodInfoPagoda
|
||||
val fruitsInfo = parseRecommend(pagoda?.fruitsRecommend, fruits)
|
||||
val vegetableInfo = parseRecommend(pagoda?.vegetableRecommend, vegetable)
|
||||
|
||||
@@ -190,6 +190,7 @@ class UserViewModel : BaseViewModel() {
|
||||
|
||||
fun getDinnerType() {
|
||||
Timber.d("getDinnerType")
|
||||
_dinnerTypeInfo.value = null
|
||||
launchWithLoading {
|
||||
val response = repository.getDinnerType()
|
||||
if (parseResponse(response)) {
|
||||
|
||||
Reference in New Issue
Block a user