fix(activity): 修复拿走物品后识别弹窗未自动关闭的问题

- 将关闭阈值从 weight < 10 调整为 weight < 20,覆盖轻微零点漂移
- 将 size == 1 判断改为 none { isShowing && it != goodsRecognizeDialog },避免 DialogManager 中存在幽灵条目时导致关闭逻辑失效
- GoodsStoreDialog:无论 funcType 值,均拍照上传图片以增加样本数据
- BaseViewModel:recognizeGoodsList 增加异常捕获,异常时回调空列表
This commit is contained in:
2026-05-09 15:44:05 +08:00
parent 7c5278bc88
commit 79f58a36e3
3 changed files with 58 additions and 45 deletions
@@ -212,17 +212,25 @@ abstract class BaseViewModel(
callback: (List<SearchGoodsInfo.Record>) -> Unit
) {
launch {
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
val response = repository.recognizeGoodsList(paramList)
val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
if (scoreList.isNullOrEmpty().not()) {
list.forEach { record ->
val item = scoreList.firstOrNull { it.name == record.goodsName }
record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
try {
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) {
callback(listOf())
return@launch
}
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
val response = repository.recognizeGoodsList(paramList)
val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
if (scoreList.isNullOrEmpty().not()) {
list.forEach { record ->
val item = scoreList.firstOrNull { it.name == record.goodsName }
record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
}
}
callback(list)
} catch (e: Exception) {
Timber.e(e)
callback(listOf())
}
callback(list)
}
}