优化
This commit is contained in:
@@ -272,7 +272,10 @@ class DishSamplingActivity : BaseActivity() {
|
|||||||
toast("不允许重复添加同一食材")
|
toast("不允许重复添加同一食材")
|
||||||
return@show
|
return@show
|
||||||
}
|
}
|
||||||
binding.etInputDishType.setText(item.goodsName)
|
binding.etInputDishType.run {
|
||||||
|
setText(item.goodsName)
|
||||||
|
setSelection(length())
|
||||||
|
}
|
||||||
tempDishEntity = CookFoodGoodsEntity().apply {
|
tempDishEntity = CookFoodGoodsEntity().apply {
|
||||||
goodsId = item.goodsId
|
goodsId = item.goodsId
|
||||||
goodsName = item.goodsName
|
goodsName = item.goodsName
|
||||||
|
|||||||
@@ -182,6 +182,10 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
val firstWeight = firstGoodsArray.get(address, null)
|
val firstWeight = firstGoodsArray.get(address, null)
|
||||||
if (firstWeight == null) {
|
if (firstWeight == null) {
|
||||||
//未设置数据
|
//未设置数据
|
||||||
|
if (state != WeightUtil.STATE_STABLE) {
|
||||||
|
//首次记录数据需要稳定数据
|
||||||
|
return@addWeightListener
|
||||||
|
}
|
||||||
firstGoodsArray.put(address, weight)
|
firstGoodsArray.put(address, weight)
|
||||||
return@addWeightListener
|
return@addWeightListener
|
||||||
}
|
}
|
||||||
@@ -420,7 +424,11 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
initConfigData()
|
initConfigData()
|
||||||
// setGridData(list)
|
// setGridData(list)
|
||||||
list.forEach { entity ->
|
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()
|
seasoningCookingItems = seasoningItems.map { it.copy() }.toList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ typealias WeightCallback = (address: Int, state: Int, weight: Double) -> Unit
|
|||||||
|
|
||||||
object WeightUtil {
|
object WeightUtil {
|
||||||
private const val TAG = "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 isConnected = false
|
||||||
var weightFuncMap: MutableMap<String, WeightCallback?>? =
|
var weightFuncMap: MutableMap<String, WeightCallback?>? =
|
||||||
@@ -28,9 +31,9 @@ object WeightUtil {
|
|||||||
override fun onGetWeight(address: Int, state: Int, weight: Double) {
|
override fun onGetWeight(address: Int, state: Int, weight: Double) {
|
||||||
super.onGetWeight(address, state, weight)
|
super.onGetWeight(address, state, weight)
|
||||||
val stateStr = when (state) {
|
val stateStr = when (state) {
|
||||||
SensorScale.STATE_STABLE -> "稳定"
|
STATE_STABLE -> "稳定"
|
||||||
SensorScale.STATE_UNSTABLE -> "不稳定"
|
STATE_UNSTABLE -> "不稳定"
|
||||||
SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
|
STATE_OVER_WEIGHT -> "量程溢出"
|
||||||
else -> "$state"
|
else -> "$state"
|
||||||
}
|
}
|
||||||
val useWeight = (weight*1000).roundedOneDecimalPlace()
|
val useWeight = (weight*1000).roundedOneDecimalPlace()
|
||||||
|
|||||||
Reference in New Issue
Block a user