fix(main): 修复计算吃饭数量返回值小于1的问题
- 修改返回值逻辑,当计算结果小于1时返回1 - 防止吃饭数量为0或负值导致的异常情况 - 优化代码可读性,提升鲁棒性
This commit is contained in:
@@ -978,7 +978,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
val eatNum = (realWeight / specWeight).roundToInt()
|
val eatNum = (realWeight / specWeight).roundToInt()
|
||||||
log("getEatNum:eatNum=$eatNum,realWeight=$realWeight,specWeight=$specWeight,realWeight/$specWeight=${realWeight / specWeight}}")
|
log("getEatNum:eatNum=$eatNum,realWeight=$realWeight,specWeight=$specWeight,realWeight/$specWeight=${realWeight / specWeight}}")
|
||||||
return eatNum;
|
return if (eatNum < 1) 1 else eatNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user