修改熟重和菜品称重位置,菜品构成删除未生效问题优化
This commit is contained in:
@@ -65,15 +65,15 @@
|
|||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||||
<activity
|
<!-- <activity-->
|
||||||
android:name=".ui.SubmitDishActivity"
|
<!-- android:name=".ui.SubmitDishActivity"-->
|
||||||
android:screenOrientation="portrait"
|
<!-- android:screenOrientation="portrait"-->
|
||||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
<!-- tools:ignore="DiscouragedApi,LockedOrientationActivity" />-->
|
||||||
<activity
|
<!-- <activity-->
|
||||||
android:name=".ui.DeviceSettingActivity"
|
<!-- android:name=".ui.DeviceSettingActivity"-->
|
||||||
android:launchMode="singleTask"
|
<!-- android:launchMode="singleTask"-->
|
||||||
android:screenOrientation="portrait"
|
<!-- android:screenOrientation="portrait"-->
|
||||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
<!-- tools:ignore="DiscouragedApi,LockedOrientationActivity" />-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.FoodSearchActivity"
|
android:name=".ui.FoodSearchActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "食盐、精制盐",
|
"popularName": "食盐、精制盐",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "鸡精、家乐鸡精",
|
"popularName": "鸡精、家乐鸡精",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "双桥味精,莲花味精、味精",
|
"popularName": "双桥味精,莲花味精、味精",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "老抽",
|
"popularName": "老抽",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "白醋,唯加白醋",
|
"popularName": "白醋,唯加白醋",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "胡椒粉",
|
"popularName": "胡椒粉",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "酱油",
|
"popularName": "酱油",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "料酒",
|
"popularName": "料酒",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "五香粉",
|
"popularName": "五香粉",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
@@ -155,40 +155,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 10,
|
"id": 10,
|
||||||
"goodsId" : "17815",
|
|
||||||
"goodsName" : "豆瓣酱",
|
|
||||||
"foodId" : "",
|
|
||||||
"goodsOrRelationCode" : "WP0194",
|
|
||||||
"relateionType" : 1,
|
|
||||||
"materialType" : 3,
|
|
||||||
"allEdible" : 1,
|
|
||||||
"useWeight" : 0.0,
|
|
||||||
"popularName" : "豆瓣酱、郫县豆瓣酱",
|
|
||||||
"canteenId" : "0",
|
|
||||||
"relateionType_dictText" : "食材原材料",
|
|
||||||
"sort" : 9,
|
|
||||||
"isDel" : 0,
|
|
||||||
"createTime" : "2025-08-18 10:18:31"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 11,
|
|
||||||
"goodsId" : "17803",
|
|
||||||
"goodsName" : "生抽",
|
|
||||||
"foodId" : "",
|
|
||||||
"goodsOrRelationCode" : "WP0182",
|
|
||||||
"relateionType" : 1,
|
|
||||||
"materialType" : 3,
|
|
||||||
"allEdible" : 1,
|
|
||||||
"useWeight" : 0.0,
|
|
||||||
"popularName" : "生抽",
|
|
||||||
"canteenId" : "0",
|
|
||||||
"relateionType_dictText" : "食材原材料",
|
|
||||||
"sort" : 11,
|
|
||||||
"isDel" : 0,
|
|
||||||
"createTime" : "2025-08-18 10:19:08"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 12,
|
|
||||||
"goodsId": "18032",
|
"goodsId": "18032",
|
||||||
"goodsName": "菜籽油[青油]",
|
"goodsName": "菜籽油[青油]",
|
||||||
"foodId": "",
|
"foodId": "",
|
||||||
@@ -196,13 +162,47 @@
|
|||||||
"relateionType": 1,
|
"relateionType": 1,
|
||||||
"materialType": 3,
|
"materialType": 3,
|
||||||
"allEdible": 1,
|
"allEdible": 1,
|
||||||
"useWeight" : 0.0,
|
"useWeight": 0,
|
||||||
"popularName": "菜籽油,爱菊菜籽油",
|
"popularName": "菜籽油,爱菊菜籽油",
|
||||||
"canteenId": "0",
|
"canteenId": "0",
|
||||||
"relateionType_dictText": "食材原材料",
|
"relateionType_dictText": "食材原材料",
|
||||||
|
"sort": 9,
|
||||||
|
"isDel": 0,
|
||||||
|
"createTime": "2025-08-18 10:19:19"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"goodsId": "17815",
|
||||||
|
"goodsName": "豆瓣酱",
|
||||||
|
"foodId": "",
|
||||||
|
"goodsOrRelationCode": "WP0194",
|
||||||
|
"relateionType": 1,
|
||||||
|
"materialType": 3,
|
||||||
|
"allEdible": 1,
|
||||||
|
"useWeight": 0,
|
||||||
|
"popularName": "豆瓣酱、郫县豆瓣酱",
|
||||||
|
"canteenId": "0",
|
||||||
|
"relateionType_dictText": "食材原材料",
|
||||||
"sort": 10,
|
"sort": 10,
|
||||||
"isDel": 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:19:19"
|
"createTime": "2025-08-18 10:18:31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12,
|
||||||
|
"goodsId": "17803",
|
||||||
|
"goodsName": "生抽",
|
||||||
|
"foodId": "",
|
||||||
|
"goodsOrRelationCode": "WP0182",
|
||||||
|
"relateionType": 1,
|
||||||
|
"materialType": 3,
|
||||||
|
"allEdible": 1,
|
||||||
|
"useWeight": 0,
|
||||||
|
"popularName": "生抽",
|
||||||
|
"canteenId": "0",
|
||||||
|
"relateionType_dictText": "食材原材料",
|
||||||
|
"sort": 11,
|
||||||
|
"isDel": 0,
|
||||||
|
"createTime": "2025-08-18 10:19:08"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,9 @@ class TextCellAdapter(var list: MutableList<SeasoningEntity>) :
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun loadCell(tvCell: TextView, item: SeasoningEntity) {
|
fun loadCell(tvCell: TextView, item: SeasoningEntity) {
|
||||||
|
tvCell.text = getTextSpan(item)
|
||||||
|
}
|
||||||
|
fun loadCell2(tvCell: TextView, item: SeasoningEntity) {
|
||||||
if (item.goodsName.isNullOrBlank()) {
|
if (item.goodsName.isNullOrBlank()) {
|
||||||
tvCell.run {
|
tvCell.run {
|
||||||
text = buildSpannableString {
|
text = buildSpannableString {
|
||||||
@@ -97,14 +100,14 @@ class TextCellAdapter(var list: MutableList<SeasoningEntity>) :
|
|||||||
|
|
||||||
fun getTextSpan(item: SeasoningEntity): SpannableStringBuilder {
|
fun getTextSpan(item: SeasoningEntity): SpannableStringBuilder {
|
||||||
val endIndex = if (item.sort == 10 || item.sort == 14) 10 else 6
|
val endIndex = if (item.sort == 10 || item.sort == 14) 10 else 6
|
||||||
var name = item.goodsName!!
|
var name = if (item.goodsName.isNullOrBlank()) "未配置" else item.goodsName!!
|
||||||
if (name.length > endIndex) {
|
if (name.length > endIndex) {
|
||||||
name = "${name.substring(0, endIndex)}…"
|
name = "${name.substring(0, endIndex)}…"
|
||||||
}
|
}
|
||||||
return buildSpannableString {
|
return buildSpannableString {
|
||||||
appendText(
|
appendText(
|
||||||
name,
|
name,
|
||||||
ForegroundColorSpan("#000000".toColorInt()),
|
ForegroundColorSpan(if (item.goodsName.isNullOrBlank()) "#999999".toColorInt() else "#000000".toColorInt()),
|
||||||
StyleSpan(Typeface.BOLD),
|
StyleSpan(Typeface.BOLD),
|
||||||
AbsoluteSizeSpan(28, true),
|
AbsoluteSizeSpan(28, true),
|
||||||
LineHeightSpan { text, start, end, spanstartv, v, fm ->
|
LineHeightSpan { text, start, end, spanstartv, v, fm ->
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.text.style.AbsoluteSizeSpan
|
|||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.text.style.LineHeightSpan
|
import android.text.style.LineHeightSpan
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
|
import android.util.SparseIntArray
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.graphics.toColorInt
|
import androidx.core.graphics.toColorInt
|
||||||
import androidx.core.view.forEach
|
import androidx.core.view.forEach
|
||||||
@@ -18,7 +19,7 @@ import com.shuwei.dish.match.db.AppRepository
|
|||||||
import com.shuwei.dish.match.dialog.CommonDialog
|
import com.shuwei.dish.match.dialog.CommonDialog
|
||||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||||
import com.shuwei.dish.match.entity.ResetReasoningRecord
|
import com.shuwei.dish.match.entity.ResetReasoningRecord
|
||||||
import com.shuwei.dish.match.utils.DataUtil
|
import com.shuwei.dish.match.utils.AddressUtil
|
||||||
import com.shuwei.dish.match.utils.JsonAssetsLoader
|
import com.shuwei.dish.match.utils.JsonAssetsLoader
|
||||||
import com.shuwei.dish.match.utils.MultiClickDetector
|
import com.shuwei.dish.match.utils.MultiClickDetector
|
||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
@@ -61,6 +62,8 @@ class DeviceConfigActivity : BaseActivity() {
|
|||||||
private lateinit var appViewModel: AppViewModel
|
private lateinit var appViewModel: AppViewModel
|
||||||
|
|
||||||
private var cookMode: Int = 0
|
private var cookMode: Int = 0
|
||||||
|
private val weightArray = SparseIntArray()
|
||||||
|
private val addressArray = AddressUtil.getWeighAddressArray()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -126,6 +129,16 @@ class DeviceConfigActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
addGridItemListener()
|
addGridItemListener()
|
||||||
loadSeasoning()
|
loadSeasoning()
|
||||||
|
addWeighListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addWeighListener() {
|
||||||
|
WeightUtil.addWeightListener { address, state, weight ->
|
||||||
|
weightArray.put(address, weight)
|
||||||
|
val item = seasoningItems.firstOrNull { address == addressArray[it.sort]}
|
||||||
|
item?.useWeight = weight.toDouble()
|
||||||
|
setGridData(seasoningItems)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var seasoningItems = mutableListOf<SeasoningEntity>()
|
private var seasoningItems = mutableListOf<SeasoningEntity>()
|
||||||
@@ -167,8 +180,7 @@ class DeviceConfigActivity : BaseActivity() {
|
|||||||
this,
|
this,
|
||||||
"default_seasoning_list.json"
|
"default_seasoning_list.json"
|
||||||
)
|
)
|
||||||
val addressArray = DataUtil.getWeighAddressArray()
|
// val weightArray = WeightUtil.weightArray
|
||||||
val weightArray = WeightUtil.weightArray
|
|
||||||
appViewModel.clearAllSeasoning {
|
appViewModel.clearAllSeasoning {
|
||||||
record?.list?.forEach { entity ->
|
record?.list?.forEach { entity ->
|
||||||
entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
|
entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
|
||||||
@@ -215,7 +227,7 @@ class DeviceConfigActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clickGridItem(sort: Int, entity: SeasoningEntity) {
|
private fun clickGridItem(sort: Int, entity: SeasoningEntity) {
|
||||||
val currentAddress = DataUtil.getWeighAddressArray().get(sort)
|
val currentAddress = AddressUtil.getWeighAddressArray().get(sort)
|
||||||
// val seasoningEntity = list.first{it.sort == sort}
|
// val seasoningEntity = list.first{it.sort == sort}
|
||||||
BottomDialog2(
|
BottomDialog2(
|
||||||
weighIndex = sort,
|
weighIndex = sort,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.shuwei.dish.match.dialog.CommonDialog
|
|||||||
import com.shuwei.dish.match.entity.CookFoodEntity
|
import com.shuwei.dish.match.entity.CookFoodEntity
|
||||||
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
||||||
import com.shuwei.dish.match.entity.FoodRecord
|
import com.shuwei.dish.match.entity.FoodRecord
|
||||||
|
import com.shuwei.dish.match.utils.AddressUtil
|
||||||
import com.shuwei.dish.match.utils.KeyboardUtil
|
import com.shuwei.dish.match.utils.KeyboardUtil
|
||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||||
@@ -140,9 +141,11 @@ class DishSamplingActivity : BaseActivity() {
|
|||||||
|
|
||||||
private val dishAdapter by lazy {
|
private val dishAdapter by lazy {
|
||||||
DishPartAdapter(list).apply {
|
DishPartAdapter(list).apply {
|
||||||
addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, positon ->
|
addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, position ->
|
||||||
//删除操作
|
//删除操作
|
||||||
removeAt(positon)
|
list.removeAt(position)
|
||||||
|
notifyItemRemoved(position)
|
||||||
|
notifyItemRangeChanged(position, list.size - position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +181,7 @@ class DishSamplingActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.ivWeightClear.setOnClickListener {
|
binding.ivWeightClear.setOnClickListener {
|
||||||
Weigher.tareTwo(2)
|
Weigher.tareTwo(AddressUtil.ONE)
|
||||||
}
|
}
|
||||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||||
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
|||||||
import com.shuwei.dish.match.entity.FoodRecord
|
import com.shuwei.dish.match.entity.FoodRecord
|
||||||
import com.shuwei.dish.match.http.HttpUtil
|
import com.shuwei.dish.match.http.HttpUtil
|
||||||
import com.shuwei.dish.match.http.UrlConfig
|
import com.shuwei.dish.match.http.UrlConfig
|
||||||
|
import com.shuwei.dish.match.utils.AddressUtil
|
||||||
import com.shuwei.dish.match.utils.SwipeCallback
|
import com.shuwei.dish.match.utils.SwipeCallback
|
||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||||
@@ -74,7 +75,7 @@ class PrepareCookActivity : BaseActivity() {
|
|||||||
|
|
||||||
private fun addViewClickListener() {
|
private fun addViewClickListener() {
|
||||||
binding.ivWeightClear.setOnClickListener {
|
binding.ivWeightClear.setOnClickListener {
|
||||||
Weigher.tareTwo(2)
|
Weigher.tareTwo(AddressUtil.ONE)
|
||||||
}
|
}
|
||||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||||
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||||
@@ -272,7 +273,10 @@ class PrepareCookActivity : BaseActivity() {
|
|||||||
dishPartAdapter.notifyItemChanged(position)
|
dishPartAdapter.notifyItemChanged(position)
|
||||||
return@SwipeCallback
|
return@SwipeCallback
|
||||||
}
|
}
|
||||||
dishPartAdapter.removeAt(position)
|
// dishPartAdapter.removeAt(position)
|
||||||
|
list.removeAt(position)
|
||||||
|
dishPartAdapter.notifyItemRemoved(position)
|
||||||
|
dishPartAdapter.notifyItemRangeChanged(position, list.size - position)
|
||||||
toast("已删除")
|
toast("已删除")
|
||||||
})
|
})
|
||||||
itemTouchHelper.attachToRecyclerView(this)
|
itemTouchHelper.attachToRecyclerView(this)
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
//
|
//
|
||||||
// private fun addViewListener() {
|
// private fun addViewListener() {
|
||||||
// addWeightListener()
|
// addWeightListener()
|
||||||
// binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(1) }
|
// binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(AddressUtil.TWO) }
|
||||||
//
|
//
|
||||||
// binding.btnCook.clickWithDebounce {
|
// binding.btnCook.clickWithDebounce {
|
||||||
// cook()
|
// cook()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.shuwei.dish.match.entity.FoodRecord
|
|||||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||||
import com.shuwei.dish.match.http.HttpUtil
|
import com.shuwei.dish.match.http.HttpUtil
|
||||||
import com.shuwei.dish.match.http.UrlConfig
|
import com.shuwei.dish.match.http.UrlConfig
|
||||||
import com.shuwei.dish.match.utils.DataUtil
|
import com.shuwei.dish.match.utils.AddressUtil
|
||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
@@ -150,7 +150,7 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
|
|
||||||
private fun addViewListener() {
|
private fun addViewListener() {
|
||||||
addWeightListener()
|
addWeightListener()
|
||||||
binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(1) }
|
binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(AddressUtil.TWO) }
|
||||||
|
|
||||||
binding.btnCook.clickWithDebounce {
|
binding.btnCook.clickWithDebounce {
|
||||||
cook()
|
cook()
|
||||||
@@ -232,7 +232,7 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val weightRelateArray by lazy {
|
private val weightRelateArray by lazy {
|
||||||
DataUtil.getWeighAddressArray()
|
AddressUtil.getWeighAddressArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun prepareData(acton: () -> Unit) {
|
// private fun prepareData(acton: () -> Unit) {
|
||||||
|
|||||||
+4
-1
@@ -2,7 +2,10 @@ package com.shuwei.dish.match.utils
|
|||||||
|
|
||||||
import android.util.SparseIntArray
|
import android.util.SparseIntArray
|
||||||
|
|
||||||
object DataUtil {
|
object AddressUtil {
|
||||||
|
|
||||||
|
const val ONE = 1
|
||||||
|
const val TWO = 2
|
||||||
|
|
||||||
fun getWeighAddressArray(): SparseIntArray {
|
fun getWeighAddressArray(): SparseIntArray {
|
||||||
return SparseIntArray().apply {
|
return SparseIntArray().apply {
|
||||||
@@ -12,7 +12,7 @@ import com.wabon.wbintelligenthardwaresdk.api.SensorScale
|
|||||||
|
|
||||||
object WeightUtil {
|
object WeightUtil {
|
||||||
|
|
||||||
val weightArray = SparseIntArray()
|
// val weightArray = SparseIntArray()
|
||||||
|
|
||||||
fun connect(initCallback: (connect: Boolean) -> Unit) {
|
fun connect(initCallback: (connect: Boolean) -> Unit) {
|
||||||
Weigher.setListener(object : WeightListenerImpl() {
|
Weigher.setListener(object : WeightListenerImpl() {
|
||||||
@@ -34,17 +34,17 @@ object WeightUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetWeight(address: Int, state: Int, weight: Int) {
|
override fun onGetWeight(address: Int, state: Int, weight: Int) {
|
||||||
runOnUiThread {
|
// runOnUiThread {
|
||||||
val stateStr = when (state) {
|
// val stateStr = when (state) {
|
||||||
SensorScale.STATE_STABLE -> "稳定"
|
// SensorScale.STATE_STABLE -> "稳定"
|
||||||
SensorScale.STATE_UNSTABLE -> "不稳定"
|
// SensorScale.STATE_UNSTABLE -> "不稳定"
|
||||||
SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
|
// SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
|
||||||
else -> ""
|
// else -> ""
|
||||||
}
|
// }
|
||||||
val result1 = String.format("$stateStr 重量:%s kg", weight / 1000f)
|
// val result1 = String.format("$stateStr 重量:%s kg", weight / 1000f)
|
||||||
//Log.d("WeightUtil", "ttlReturn, address:$address,$result1")
|
// //Log.d("WeightUtil", "ttlReturn, address:$address,$result1")
|
||||||
weightArray.put(address, weight)
|
// weightArray.put(address, weight)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReadIdentify(rate: Int) {
|
override fun onReadIdentify(rate: Int) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:background="@drawable/bg_other_page">
|
tools:background="@drawable/bg_other_page">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user