修改熟重和菜品称重位置,菜品构成删除未生效问题优化
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"
|
||||||
|
|||||||
@@ -1,208 +1,208 @@
|
|||||||
{
|
{
|
||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"id" : 1,
|
"id": 1,
|
||||||
"goodsId" : "17899",
|
"goodsId": "17899",
|
||||||
"goodsName" : "精盐",
|
"goodsName": "精盐",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0278",
|
"goodsOrRelationCode": "WP0278",
|
||||||
"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" : 0,
|
"sort": 0,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:16:17"
|
"createTime": "2025-08-18 10:16:17"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 2,
|
"id": 2,
|
||||||
"goodsId" : "17901",
|
"goodsId": "17901",
|
||||||
"goodsName" : "鸡精",
|
"goodsName": "鸡精",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0280",
|
"goodsOrRelationCode": "WP0280",
|
||||||
"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" : 1,
|
"sort": 1,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:02"
|
"createTime": "2025-08-18 10:17:02"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 3,
|
"id": 3,
|
||||||
"goodsId" : "17752",
|
"goodsId": "17752",
|
||||||
"goodsName" : "味精",
|
"goodsName": "味精",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0131",
|
"goodsOrRelationCode": "WP0131",
|
||||||
"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" : 2,
|
"sort": 2,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:16"
|
"createTime": "2025-08-18 10:17:16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 4,
|
"id": 4,
|
||||||
"goodsId" : "17800",
|
"goodsId": "17800",
|
||||||
"goodsName" : "老抽",
|
"goodsName": "老抽",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0179",
|
"goodsOrRelationCode": "WP0179",
|
||||||
"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" : 3,
|
"sort": 3,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:26"
|
"createTime": "2025-08-18 10:17:26"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 5,
|
"id": 5,
|
||||||
"goodsId" : "17749",
|
"goodsId": "17749",
|
||||||
"goodsName" : "白醋",
|
"goodsName": "白醋",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0128",
|
"goodsOrRelationCode": "WP0128",
|
||||||
"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" : 4,
|
"sort": 4,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:38"
|
"createTime": "2025-08-18 10:17:38"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 6,
|
"id": 6,
|
||||||
"goodsId" : "17895",
|
"goodsId": "17895",
|
||||||
"goodsName" : "胡椒粉",
|
"goodsName": "胡椒粉",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0274",
|
"goodsOrRelationCode": "WP0274",
|
||||||
"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" : 5,
|
"sort": 5,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:47"
|
"createTime": "2025-08-18 10:17:47"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 7,
|
"id": 7,
|
||||||
"goodsId" : "329",
|
"goodsId": "329",
|
||||||
"goodsName" : "酱油",
|
"goodsName": "酱油",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0329",
|
"goodsOrRelationCode": "WP0329",
|
||||||
"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" : 6,
|
"sort": 6,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:17:55"
|
"createTime": "2025-08-18 10:17:55"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 8,
|
"id": 8,
|
||||||
"goodsId" : "17733",
|
"goodsId": "17733",
|
||||||
"goodsName" : "料酒",
|
"goodsName": "料酒",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0112",
|
"goodsOrRelationCode": "WP0112",
|
||||||
"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" : 7,
|
"sort": 7,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:18:14"
|
"createTime": "2025-08-18 10:18:14"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 9,
|
"id": 9,
|
||||||
"goodsId" : "17889",
|
"goodsId": "17889",
|
||||||
"goodsName" : "五香粉",
|
"goodsName": "五香粉",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0268",
|
"goodsOrRelationCode": "WP0268",
|
||||||
"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" : 8,
|
"sort": 8,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:18:23"
|
"createTime": "2025-08-18 10:18:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 10,
|
"id": 10,
|
||||||
"goodsId" : "17815",
|
"goodsId": "18032",
|
||||||
"goodsName" : "豆瓣酱",
|
"goodsName": "菜籽油[青油]",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0194",
|
"goodsOrRelationCode": "WP0411",
|
||||||
"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,
|
"sort": 9,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:18:31"
|
"createTime": "2025-08-18 10:19:19"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 11,
|
"id": 11,
|
||||||
"goodsId" : "17803",
|
"goodsId": "17815",
|
||||||
"goodsName" : "生抽",
|
"goodsName": "豆瓣酱",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0182",
|
"goodsOrRelationCode": "WP0194",
|
||||||
"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" : 11,
|
"sort": 10,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:19:08"
|
"createTime": "2025-08-18 10:18:31"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 12,
|
"id": 12,
|
||||||
"goodsId" : "18032",
|
"goodsId": "17803",
|
||||||
"goodsName" : "菜籽油[青油]",
|
"goodsName": "生抽",
|
||||||
"foodId" : "",
|
"foodId": "",
|
||||||
"goodsOrRelationCode" : "WP0411",
|
"goodsOrRelationCode": "WP0182",
|
||||||
"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" : 10,
|
"sort": 11,
|
||||||
"isDel" : 0,
|
"isDel": 0,
|
||||||
"createTime" : "2025-08-18 10:19:19"
|
"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,11 +129,21 @@ 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>()
|
||||||
private fun addGridItemListener() {
|
private fun addGridItemListener() {
|
||||||
binding.include.root.forEach { child->
|
binding.include.root.forEach { child ->
|
||||||
(child as TextView).run {
|
(child as TextView).run {
|
||||||
clickWithDebounce {
|
clickWithDebounce {
|
||||||
val sort = tag.toString().toInt()
|
val sort = tag.toString().toInt()
|
||||||
@@ -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()
|
||||||
@@ -197,8 +209,8 @@ class DeviceConfigActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initConfigData() {
|
private fun initConfigData() {
|
||||||
repeat(12) {num->
|
repeat(12) { num ->
|
||||||
val firstOne = seasoningItems.firstOrNull {it.sort == num}
|
val firstOne = seasoningItems.firstOrNull { it.sort == num }
|
||||||
if (firstOne == null) {
|
if (firstOne == null) {
|
||||||
seasoningItems.add(SeasoningEntity().also { it.sort = num })
|
seasoningItems.add(SeasoningEntity().also { it.sort = num })
|
||||||
}
|
}
|
||||||
@@ -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