feat(data): 更新食物营养数据模型并优化向量数据处理
- 在DataBean中将肉蛋相关字段重命名为肉蛋豆,并添加总重量字段 - 新增FoodVectorTool工具类用于处理食物向量数据的分页获取和存储 - 重构InitActivity中的食物向量数据获取逻辑,使用新的工具类替代原有实现 - 在MainActivity中集成食物向量数据同步功能,在清除本地数据后重新获取 - 更新MainScreenPresentation中营养信息显示逻辑,适配新的数据模型结构 - 修改ApiClient中的日志标记逻辑,为不同接口添加特定的标签 - 调整食物订单列表的数据更新方式,优化适配器通知策略
This commit is contained in:
@@ -485,9 +485,7 @@ class MainScreenPresentation(
|
||||
binding.nutritionInclude.tvUserName.text = userNutrition?.name.maskName()
|
||||
val recommendCalorie = (userNutrition?.recommendCalorie ?: 0.0).roundedDecimalPlace(1)
|
||||
|
||||
// binding.detailInclude.tvTotalWeight.text = "总重量:${userNutrition?.}克"
|
||||
binding.nutritionInclude.tvRecommendHeat.text =
|
||||
"推荐热量:${recommendCalorie.roundedDecimalPlace(1)}kcal"
|
||||
binding.nutritionInclude.tvRecommendHeat.text = "推荐热量:${recommendCalorie.roundedDecimalPlace(1)}kcal"
|
||||
// binding.nutritionInclude.tvRecommendHeat.text = "推荐热量:${recommendCalorie.removeTrailingZeros()}kcal"
|
||||
//updateWeight(lastWeight / 1000)
|
||||
// -------------------------------------------------
|
||||
@@ -715,8 +713,8 @@ class MainScreenPresentation(
|
||||
val last = foodOrderList.last()
|
||||
if (last.isLocalData) {
|
||||
foodOrderList.remove(last)
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyDataSetChanged()
|
||||
// foodOrderAdapter.submitList(foodOrderList)
|
||||
foodOrderAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -730,8 +728,8 @@ class MainScreenPresentation(
|
||||
last.eatNum = eatNum
|
||||
last.num = weight
|
||||
last.price = price
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
||||
// foodOrderAdapter.submitList(foodOrderList)
|
||||
foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -750,7 +748,8 @@ class MainScreenPresentation(
|
||||
isLocalData = true
|
||||
)
|
||||
)
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
// foodOrderAdapter.submitList(foodOrderList)
|
||||
foodOrderAdapter.notifyDataSetChanged()
|
||||
Log.d(
|
||||
TAG,
|
||||
"addFoodToOrder: size=${foodOrderList.size},新增数据:${foodOrderList.last()}"
|
||||
@@ -803,8 +802,10 @@ class MainScreenPresentation(
|
||||
val fruitsVegetables = energy.fruitsVegetables
|
||||
val meatEggs = energy.meatEggs
|
||||
|
||||
binding.detailInclude.tvTotalCalorie.text =
|
||||
"总热量:${totalKcal.roundedDecimalPlace(1)}千卡"
|
||||
binding.detailInclude.tvTotalCalorie.text = "总热量:${totalKcal.roundedDecimalPlace(1)}千卡"
|
||||
|
||||
val totalWeight = (userNutrition?.eatWeightSum ?: 0.0) + weight
|
||||
binding.detailInclude.tvTotalWeight.text = "总重量:${totalWeight.roundedDecimalPlace(1)}克"
|
||||
|
||||
val include = binding.nutritionInclude
|
||||
|
||||
@@ -874,9 +875,9 @@ class MainScreenPresentation(
|
||||
|
||||
// 设置肉蛋-----------------------------------------------------------
|
||||
val meatEggsArray = UserNutritionUtils.getCalorieArray(
|
||||
left = userNutrition?.meatEggsRecommend,
|
||||
mid = userNutrition?.meatEggsNearExcess,
|
||||
right = userNutrition?.meatEggsExcess
|
||||
left = userNutrition?.meatEggsBeansRecommend,
|
||||
mid = userNutrition?.meatEggsBeansNearExcess,
|
||||
right = userNutrition?.meatEggsBeansExcess
|
||||
)
|
||||
val meatEggsIndex =
|
||||
UserNutritionUtils.findCalorieIndex(energy.meatEggs, meatEggsArray)
|
||||
@@ -1480,12 +1481,11 @@ class MainScreenPresentation(
|
||||
if (model == null) return@runOnUiThread
|
||||
foodOrderList.clear()
|
||||
foodOrderList.addAll(model.list ?: emptyList())
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyDataSetChanged()
|
||||
binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
||||
//foodOrderAdapter.submitList(foodOrderList)
|
||||
foodOrderAdapter.notifyDataSetChanged()
|
||||
//binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
||||
Log.d(TAG, "addFoodToOrder: 更新总重量,订单列表------------------------------")
|
||||
binding.detailInclude.tvTotalCalorie.text =
|
||||
"总热量:${model.calorie.roundedDecimalPlace(1)}千卡"
|
||||
// binding.detailInclude.tvTotalCalorie.text = "总热量:${model.calorie.roundedDecimalPlace(1)}千卡"
|
||||
jointPaymentQueryFinish = true
|
||||
|
||||
//重新加载营养信息
|
||||
|
||||
Reference in New Issue
Block a user