优化识别后未离开多次切换模式导致的不再识别问题

This commit is contained in:
2025-12-22 14:18:46 +08:00
parent 960b429e69
commit f080a8b73c
3 changed files with 84 additions and 45 deletions
@@ -692,7 +692,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
val weight = lastWeight
lastWeight = 0.0
presentation?.hideRecImage()
recognizeByWeight(weight, true)
presentation?.step1FoodRecognizing()
binding.root.postDelayed({
recognizeByWeight(weight, true)
},500)
}
isRefreshPage = !isRefreshPage
}
@@ -748,6 +752,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
foodWeight: Int,
eatWeight: Int,
eatNum: Int,
userId: String?,
block: () -> Unit
) {
Timber.tag(TAG).d("foodWeight=$foodWeight,eatWeight=$eatWeight")
@@ -769,7 +774,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
eatWeight = eatWeight,
//根据specId对应规格重量计算
eatNum = eatNum,
userId = null,
userId = userId,
notPay = chargeMode != 0,
//即放即取-1,称重-2
mode = if (pickupMode == 1) 1 else 2
@@ -823,6 +828,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
isStartRecognize = false
presentation?.hideNutritionView(event.chargeMode)
// presentation?.cancel()
if (event.chargeMode == 1) {
presentation?.let {
it.onStop()
it.setupArcCamera()
}
}
}
private var isRefreshPage = false
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -868,7 +880,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
foodInfo = checkedItem!!,
foodWeight = foodWeight.roundToInt(),
eatWeight = eatWeight.roundToInt(),
eatNum = eatNum
eatNum = eatNum,
userId = null,
) {
// TODO: 暂不关闭首页副屏
//presentation?.dismiss()
@@ -3,6 +3,7 @@ package com.sw.dualscreen.activity.fragment
import android.view.LayoutInflater
import com.sw.dualscreen.GlobalKey
import com.sw.dualscreen.R
import com.sw.dualscreen.activity.SettingActivity
import com.sw.dualscreen.databinding.FragmentBusinessBinding
import com.sw.dualscreen.model.response.ChargeModeEvent
import com.sw.dualscreen.sdk.SensorScaleUtils
@@ -37,7 +38,7 @@ class BusinessFragment: BaseFragment<FragmentBusinessBinding>() {
binding.btnClearZero.setOnClickListener {
SensorScaleUtils.tare()
}
binding.btnConfirm.setOnClickListener {
binding.btnConfirm.setOnClickListener { v ->
if (binding.rgCharge.checkedRadioButtonId == -1) {
ToastUtils.showToast("请设置计费模式")
return@setOnClickListener
@@ -59,8 +60,14 @@ class BusinessFragment: BaseFragment<FragmentBusinessBinding>() {
val pickupMode = if (binding.rgTakeFood.checkedRadioButtonId == R.id.rbPickAndPlace) 0 else 1
SPUtil.getInstance().put(GlobalKey.KEY_PICKUP_MODE, pickupMode)
ToastUtils.showToast("设置已保存")
activity?.finish()
//ToastUtils.showToast("设置已保存")
(activity as SettingActivity).let {
it.showWaitingDialog("设置保存中")
v.postDelayed({
it.hideWaitingDialog()
it.finish()
}, 1000)
}
}
SensorScaleUtils.addWeightListener { value ->
val realWeight = (value * 1000).roundToInt()