This commit is contained in:
mazengfei
2026-03-16 10:33:09 +08:00
parent 4b241ba81b
commit 8a83de3238
2 changed files with 9 additions and 2 deletions
@@ -169,7 +169,6 @@ abstract class GoodsListActivity : BaseActivity() {
binding.btnClearZero.setOnClickListener { binding.btnClearZero.setOnClickListener {
SensorScaleUtils.tare() SensorScaleUtils.tare()
} }
cameraUtils.setPreviewController(previewView)
userViewModel.getInitInfo() userViewModel.getInitInfo()
} }
@@ -177,9 +176,10 @@ abstract class GoodsListActivity : BaseActivity() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
cameraUtils.bind() cameraUtils.bind()
cameraUtils.setPreviewController(previewView)
binding.root.postDelayed({ binding.root.postDelayed({
SensorScaleUtils.addWeightListener(weightIntCallback) SensorScaleUtils.addWeightListener(weightIntCallback)
}, 1 * 1000) }, 1 * 1500)
} }
private var weightIntCallback: WeightCallback = { private var weightIntCallback: WeightCallback = {
@@ -478,6 +478,7 @@ abstract class GoodsListActivity : BaseActivity() {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
SensorScaleUtils.removeWeightListener(weightIntCallback)
unBindCamera() unBindCamera()
} }
@@ -66,6 +66,12 @@ object SensorScaleUtils {
} }
} }
fun removeWeightListener(callback: WeightCallback) {
if (callbackList.contains(callback)) {
callbackList.remove(callback)
}
}
/** /**
* 开启称重 * 开启称重
* @param autoScale 是否开启自动读取 * @param autoScale 是否开启自动读取