This commit is contained in:
2025-09-19 09:15:44 +08:00
parent c1d4263473
commit 0540879551
3 changed files with 19 additions and 5 deletions
@@ -272,7 +272,10 @@ class DishSamplingActivity : BaseActivity() {
toast("不允许重复添加同一食材")
return@show
}
binding.etInputDishType.setText(item.goodsName)
binding.etInputDishType.run {
setText(item.goodsName)
setSelection(length())
}
tempDishEntity = CookFoodGoodsEntity().apply {
goodsId = item.goodsId
goodsName = item.goodsName
@@ -182,6 +182,10 @@ class SubmitFoodActivity : BaseActivity() {
val firstWeight = firstGoodsArray.get(address, null)
if (firstWeight == null) {
//未设置数据
if (state != WeightUtil.STATE_STABLE) {
//首次记录数据需要稳定数据
return@addWeightListener
}
firstGoodsArray.put(address, weight)
return@addWeightListener
}
@@ -420,7 +424,11 @@ class SubmitFoodActivity : BaseActivity() {
initConfigData()
// setGridData(list)
list.forEach { entity ->
updateGridData(entity.also { it.useWeight = 0.0 })
//烹饪中重量数据从本地获取,否则显示0
if (isCooking.not()) {
entity.useWeight = 0.0
}
updateGridData(entity)
}
seasoningCookingItems = seasoningItems.map { it.copy() }.toList()
}
@@ -12,6 +12,9 @@ typealias WeightCallback = (address: Int, state: Int, weight: Double) -> Unit
object WeightUtil {
private const val TAG = "WeightUtil"
const val STATE_STABLE = SensorScale.STATE_STABLE
const val STATE_UNSTABLE = SensorScale.STATE_UNSTABLE
const val STATE_OVER_WEIGHT = SensorScale.STATE_OVER_WEIGHT
var isConnected = false
var weightFuncMap: MutableMap<String, WeightCallback?>? =
@@ -28,9 +31,9 @@ object WeightUtil {
override fun onGetWeight(address: Int, state: Int, weight: Double) {
super.onGetWeight(address, state, weight)
val stateStr = when (state) {
SensorScale.STATE_STABLE -> "稳定"
SensorScale.STATE_UNSTABLE -> "不稳定"
SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
STATE_STABLE -> "稳定"
STATE_UNSTABLE -> "不稳定"
STATE_OVER_WEIGHT -> "量程溢出"
else -> "$state"
}
val useWeight = (weight*1000).roundedOneDecimalPlace()