feat(setting): 添加测试调料拿取功能并优化界面交互
- 在设置页面添加测试调料拿取入口并实现跳转功能 - 优化食材搜索对话框的网格布局管理器初始化逻辑 - 为未识别食材对话框添加重新识别和取消回调处理 - 优化准备食材页面标题文字显示效果 - 修复调料切换按钮点击防抖处理
This commit is contained in:
@@ -232,7 +232,12 @@ class FoodSearchDialog(
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
binding.recyclerView.layoutManager = GridLayoutManager(activity, 2, GridLayoutManager.VERTICAL, false)
|
// 仅当当前不是 GridLayoutManager 时才重新赋值(空态切回网格时)
|
||||||
|
binding.recyclerView.run {
|
||||||
|
if (layoutManager !is GridLayoutManager) {
|
||||||
|
layoutManager = GridLayoutManager(activity, 2, GridLayoutManager.VERTICAL, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
if (pageNo == 1) list.clear()
|
if (pageNo == 1) list.clear()
|
||||||
// 将接口返回的 rawMaterialsType(全部种类)移存到 rawMaterialsTypes,供弹窗使用
|
// 将接口返回的 rawMaterialsType(全部种类)移存到 rawMaterialsTypes,供弹窗使用
|
||||||
records.forEach {
|
records.forEach {
|
||||||
|
|||||||
@@ -212,36 +212,21 @@ class FoodRecognizeActivity : BaseActivity() {
|
|||||||
currentWeight = intent.getDoubleExtra(EXTRA_CURRENT_WEIGHT, 0.0)
|
currentWeight = intent.getDoubleExtra(EXTRA_CURRENT_WEIGHT, 0.0)
|
||||||
initialWeight = intent.getDoubleExtra(EXTRA_INITIAL_WEIGHT, 0.0)
|
initialWeight = intent.getDoubleExtra(EXTRA_INITIAL_WEIGHT, 0.0)
|
||||||
binding.tvWeight.text = "${currentWeight}g"
|
binding.tvWeight.text = "${currentWeight}g"
|
||||||
// val tempList = arrayListOf<GoodsItem>()
|
|
||||||
// Process recognized name list if available
|
|
||||||
recognizeNameList?.apply {
|
recognizeNameList?.apply {
|
||||||
// Iterate through each recognized item
|
|
||||||
forEach {
|
forEach {
|
||||||
// Extract goods name by splitting "WP" and taking the first part
|
|
||||||
val goodsName = it.name.split("WP").first()
|
val goodsName = it.name.split("WP").first()
|
||||||
val rawMaterialsType = it.rawMaterialsType
|
val rawMaterialsType = it.rawMaterialsType
|
||||||
// Add to goods name list and name-score mapping
|
|
||||||
goodsNameList.add(GoodsNameQueryDTO(goodsName, rawMaterialsType))
|
goodsNameList.add(GoodsNameQueryDTO(goodsName, rawMaterialsType))
|
||||||
nameScoreMap.put(goodsName, it)
|
nameScoreMap.put(goodsName, it)
|
||||||
|
|
||||||
// // TODO: 测试数据,临时使用-------------------------
|
|
||||||
// val testData = buildTestData(it)
|
|
||||||
// tempList.add(testData)
|
|
||||||
// // TODO: 测试数据,临时使用-------------------------
|
|
||||||
}
|
}
|
||||||
// // TODO: 测试数据,临时使用-------------------------
|
|
||||||
// loadRecognizeList(tempList)
|
|
||||||
// // TODO: 测试数据,临时使用-------------------------
|
|
||||||
// Clear the recognize name list after processing
|
|
||||||
recognizeNameList = null
|
recognizeNameList = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// If goods name list is not empty, query goods list from network
|
if (goodsNameList.isNotEmpty()) {
|
||||||
// if (goodsNameList.isNotEmpty()){
|
netViewModel.queryGoodsList(goodsType = "0", goodsNames = goodsNameList)
|
||||||
netViewModel.queryGoodsList(goodsType = "0", goodsNames = goodsNameList)
|
} else {
|
||||||
// } else {
|
loadRecognizeList(emptyList())
|
||||||
// loadRecognizeList(emptyList())
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildTestData(item: FoodModule.IdNameScore): GoodsItem {
|
private fun buildTestData(item: FoodModule.IdNameScore): GoodsItem {
|
||||||
@@ -309,7 +294,7 @@ class FoodRecognizeActivity : BaseActivity() {
|
|||||||
//保存原goodsId
|
//保存原goodsId
|
||||||
goods.oldGoodsId = goods.goodsId
|
goods.oldGoodsId = goods.goodsId
|
||||||
//PrepareFoodActivity中的goodsId就是materId
|
//PrepareFoodActivity中的goodsId就是materId
|
||||||
goods.goodsId = goods.materId ?:""
|
goods.goodsId = goods.materId ?: ""
|
||||||
list.add(goods.also { it.foodScore = foodScore })
|
list.add(goods.also { it.foodScore = foodScore })
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
|||||||
@@ -610,7 +610,12 @@ class PrepareFoodActivity : BaseActivity() {
|
|||||||
notRecognizeDialog = CommonDialog(this)
|
notRecognizeDialog = CommonDialog(this)
|
||||||
.setTitle("提示")
|
.setTitle("提示")
|
||||||
.setContent("未识别到食材,请稍后重试")
|
.setContent("未识别到食材,请稍后重试")
|
||||||
.setNegativeButton("取消")
|
.setNegativeButton("取消") {
|
||||||
|
manualCancelFlag = true
|
||||||
|
}
|
||||||
|
.setNeutralButton("重新识别") {
|
||||||
|
recognizeFood(currentWeight)
|
||||||
|
}
|
||||||
.setPositiveButton("手动设置"){
|
.setPositiveButton("手动设置"){
|
||||||
loadRecognizeResultPage(emptyList())
|
loadRecognizeResultPage(emptyList())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class SettingActivity : BaseActivity() {
|
|||||||
binding.llScaleObserve.visible()
|
binding.llScaleObserve.visible()
|
||||||
binding.llClearData.visible()
|
binding.llClearData.visible()
|
||||||
binding.llEnvSwitch.visible()
|
binding.llEnvSwitch.visible()
|
||||||
|
binding.llTestSeasoning.visible()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -93,6 +94,9 @@ class SettingActivity : BaseActivity() {
|
|||||||
binding.llEnvSwitch.clickWithDebounce {
|
binding.llEnvSwitch.clickWithDebounce {
|
||||||
EnvSwitchDialog(this).show()
|
EnvSwitchDialog(this).show()
|
||||||
}
|
}
|
||||||
|
binding.llTestSeasoning.clickWithDebounce {
|
||||||
|
startActivity<SubmitFoodActivity> { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
|
|
||||||
private fun addViewListener() {
|
private fun addViewListener() {
|
||||||
// 切换调料列表布局:4 列卡片 ↔ 2 列水平
|
// 切换调料列表布局:4 列卡片 ↔ 2 列水平
|
||||||
binding.ivSeasoningLayoutToggle.setOnClickListener {
|
binding.ivSeasoningLayoutToggle.clickWithDebounce {
|
||||||
seasoningAdapter.isListMode = !seasoningAdapter.isListMode
|
seasoningAdapter.isListMode = !seasoningAdapter.isListMode
|
||||||
val spanCount = if (seasoningAdapter.isListMode) 2 else 4
|
val spanCount = if (seasoningAdapter.isListMode) 2 else 4
|
||||||
(binding.rvSeasoning.layoutManager as? GridLayoutManager)?.spanCount = spanCount
|
(binding.rvSeasoning.layoutManager as? GridLayoutManager)?.spanCount = spanCount
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
android:imeOptions="actionSearch"
|
android:imeOptions="actionSearch"
|
||||||
android:paddingStart="3dp"
|
android:paddingStart="3dp"
|
||||||
android:paddingEnd="3dp"
|
android:paddingEnd="3dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
android:textColor="@color/black333"
|
android:textColor="@color/black333"
|
||||||
android:textColorHint="@color/gray_c8"
|
android:textColorHint="@color/gray_c8"
|
||||||
android:textSize="40sp"
|
android:textSize="40sp"
|
||||||
|
|||||||
@@ -237,6 +237,38 @@
|
|||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/llTestSeasoning"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="120dp"
|
||||||
|
android:layout_marginHorizontal="32dp"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:background="@drawable/shape_white_dc_15_corners"
|
||||||
|
android:clipToOutline="true"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="测试调料拿取"
|
||||||
|
android:textColor="@color/black333"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:src="@drawable/ic_arrow_right3"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- <!– 底部导航菜单 –>-->
|
<!-- <!– 底部导航菜单 –>-->
|
||||||
<!-- <LinearLayout-->
|
<!-- <LinearLayout-->
|
||||||
<!-- android:id="@+id/bottomMenu"-->
|
<!-- android:id="@+id/bottomMenu"-->
|
||||||
|
|||||||
Reference in New Issue
Block a user