修改模式切换流程

This commit is contained in:
mazengfei
2025-11-06 19:19:45 +08:00
parent 0a09814a61
commit c898cbb3e2
3 changed files with 30 additions and 2 deletions
@@ -86,6 +86,8 @@ class SecondaryScreenPresentation(
// 当前步骤
var currentStep: Int = 0
private var isGoStep1 = false;//防止持续调用
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -189,6 +191,7 @@ class SecondaryScreenPresentation(
* 显示人脸识别
*/
fun step2(foodInfo: FoodInfo) {
isGoStep1 = true
Timber.d("step2")
currentStep = 2
LightManager.closeRedLight()
@@ -274,10 +277,24 @@ class SecondaryScreenPresentation(
fun updateWeight(weight: Double) {
lastWeight = weight * 1000 // 将千克转成克
Timber.d("updateWeight lastWeight = $weight")
if (currentStep == 2 &&
lastWeight <= 5 &&
isGoStep1
) {//人脸识别过程中,秤上物品拿走
isGoStep1 = false
activity.runOnUiThread {
Timber.e("切回step1")
step1()
}
}
if (currentFood == null) {
Timber.e("updateWeight currentFood is null")
return
}
if (userNutritionData == null) {
Timber.e("updateWeight userNutritionData is null")
return
@@ -299,6 +316,7 @@ class SecondaryScreenPresentation(
fun updateMealPickupMode(mode: Int) {
Timber.d("updateMealPickupMode mode = $mode")
mealPickupMode = mode
step1()
}
private fun calculateNutrition(weight1: Double) {