功能优化
This commit is contained in:
@@ -132,17 +132,15 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
startActivity<SamplingListActivity> { }
|
||||
finish()
|
||||
}
|
||||
addWeighListener()
|
||||
addGridItemListener()
|
||||
loadSeasoning()
|
||||
addWeighListener()
|
||||
}
|
||||
|
||||
private fun addWeighListener() {
|
||||
WeightUtil.addWeightListener(onConnect = { state ->
|
||||
binding.viewPoint.setBackgroundResource(
|
||||
if (state) R.drawable.bg_circle_green else R.drawable.bg_circle_red
|
||||
)
|
||||
}, getWeight = { address, state, weight ->
|
||||
WeightUtil.addWeightListener(
|
||||
weightKey = TAG,
|
||||
getWeight = { address, state, weight ->
|
||||
Log.d(TAG, "addWeighListener: address=$address,stat=$state,weight=$weight")
|
||||
weightArray.put(address, weight)
|
||||
val item = seasoningItems.firstOrNull { address == addressArray[it.sort] }
|
||||
@@ -150,7 +148,7 @@ class DeviceConfigActivity : BaseActivity() {
|
||||
it.useWeight = weight.toDouble()
|
||||
updateGridData(it)
|
||||
}
|
||||
//setGridData(seasoningItems)
|
||||
Log.d(TAG, "addWeighListener: update-----------------------")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,16 @@ class DishSamplingActivity : BaseActivity() {
|
||||
initViewModel()
|
||||
foodName = intent.getStringExtra(FOOD_NAME)
|
||||
binding.etInputDish.setText(foodName)
|
||||
|
||||
WeightUtil.addWeightListener(
|
||||
weightKey = TAG,
|
||||
getWeight = { address, state, weight ->
|
||||
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
if (address == AddressUtil.ONE) {
|
||||
tempDishEntity?.useWeight = weight.toDouble()
|
||||
binding.tvDishPartWeight.text = "${weight}"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setTitleBar() {
|
||||
@@ -166,13 +176,6 @@ class DishSamplingActivity : BaseActivity() {
|
||||
binding.ivWeightClear.setOnClickListener {
|
||||
WeightUtil.tareTwo(AddressUtil.ONE)
|
||||
}
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
if (address == AddressUtil.ONE) {
|
||||
tempDishEntity?.useWeight = weight.toDouble()
|
||||
binding.tvDishPartWeight.text = "${weight}"
|
||||
}
|
||||
})
|
||||
binding.ivWeightAdd.setOnClickListener {
|
||||
if (tempDishEntity == null) {
|
||||
toast("请输入食材名称")
|
||||
|
||||
@@ -73,15 +73,17 @@ class PrepareCookActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun addViewClickListener() {
|
||||
WeightUtil.addWeightListener(
|
||||
weightKey = TAG,
|
||||
getWeight = { address, state, weight ->
|
||||
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
if (address == AddressUtil.ONE) {
|
||||
binding.tvDishPartWeight.text = "${weight}"
|
||||
}
|
||||
})
|
||||
binding.ivWeightClear.setOnClickListener {
|
||||
WeightUtil.tareTwo(AddressUtil.ONE)
|
||||
}
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
if (address == AddressUtil.ONE) {
|
||||
binding.tvDishPartWeight.text = "${weight}"
|
||||
}
|
||||
})
|
||||
binding.ivWeightAdd.setOnClickListener {
|
||||
if (clickIndex == -1) {
|
||||
toast("请选择菜品构成")
|
||||
|
||||
@@ -99,8 +99,15 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
private fun loadSeasoningFromLocal() {
|
||||
appViewModel.getCookFoodGoodsList(foodId = food!!.foodId!!, cookMode = food!!.cookMode) { it ->
|
||||
goodsList = mutableListOf()
|
||||
val goodsIdList = mutableListOf<String>()
|
||||
//设置主辅材数据
|
||||
goodsList?.addAll(it.filter { goods -> goods.materialType != 3 })
|
||||
val tempList = it.filter { goods -> goods.materialType != 3 }
|
||||
tempList.forEach {
|
||||
if (!goodsIdList.contains(it.goodsId)) {
|
||||
goodsList?.add(it)
|
||||
goodsIdList.add(it.goodsId)
|
||||
}
|
||||
}
|
||||
|
||||
//获取调料数据并展示
|
||||
val filterList: List<SeasoningEntity>? = it.filter { goods -> goods.materialType == 3 }
|
||||
@@ -166,7 +173,9 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun addWeightListener() {
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
WeightUtil.addWeightListener(
|
||||
weightKey = TAG,
|
||||
getWeight = { address, state, weight ->
|
||||
if (address == AddressUtil.TWO) {
|
||||
cookFoodEntity.foodWeight = weight.toDouble()
|
||||
binding.tvTotalWeight.text = "${weight / 1000f}"
|
||||
|
||||
Reference in New Issue
Block a user