优化不足一份的识别问题
This commit is contained in:
@@ -336,6 +336,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
if (isPageVisible.not() || isStartRecognize.not()) {
|
if (isPageVisible.not() || isStartRecognize.not()) {
|
||||||
if (ActivityManager.currentActivity() is MainActivity) {
|
if (ActivityManager.currentActivity() is MainActivity) {
|
||||||
isPageVisible = true
|
isPageVisible = true
|
||||||
|
isStartRecognize = true
|
||||||
}
|
}
|
||||||
return@addWeightListener
|
return@addWeightListener
|
||||||
}
|
}
|
||||||
@@ -765,18 +766,24 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
eatWeight: Int,
|
eatWeight: Int,
|
||||||
eatNum: Int,
|
eatNum: Int,
|
||||||
userId: String?,
|
userId: String?,
|
||||||
|
notEnoughOneBlock: ()-> Unit = {},
|
||||||
block: () -> Unit
|
block: () -> Unit
|
||||||
) {
|
) {
|
||||||
Timber.tag(TAG).d("foodWeight=$foodWeight,eatWeight=$eatWeight")
|
Timber.tag(TAG).d("foodWeight=$foodWeight,eatWeight=$eatWeight")
|
||||||
val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
val pickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||||
if (pickupMode == 0) {
|
if (pickupMode == 0) {
|
||||||
if (foodWeight <= 5 || eatWeight <= 5) {
|
if (foodWeight <= 5) {
|
||||||
ToastUtils.showToast("请取走餐品")
|
ToastUtils.showToast("餐品重量不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (eatWeight <= 5) {
|
||||||
|
ToastUtils.showToast("取餐重量过小")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (eatNum == 0) {
|
if (eatNum == 0) {
|
||||||
ToastUtils.showToast("您好,当前重量不足一份")
|
ToastUtils.showToast("您好,当前重量不足一份")
|
||||||
|
notEnoughOneBlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showWaitingDialog("加载中,请稍候……")
|
showWaitingDialog("加载中,请稍候……")
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ class MainScreenPresentation(
|
|||||||
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
|
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
|
||||||
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
|
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
|
||||||
|
|
||||||
var isKeepFaceState = true
|
// var isKeepFaceState = true
|
||||||
|
var isKeepFaceState = false
|
||||||
|
|
||||||
var currentUserId: String? = null
|
var currentUserId: String? = null
|
||||||
|
|
||||||
@@ -986,6 +987,9 @@ class MainScreenPresentation(
|
|||||||
if (facePreviewInfoList != null && rgbFaceRectTransformer != null) {
|
if (facePreviewInfoList != null && rgbFaceRectTransformer != null) {
|
||||||
drawPreviewInfo(facePreviewInfoList!!)
|
drawPreviewInfo(facePreviewInfoList!!)
|
||||||
}
|
}
|
||||||
|
if (facePreviewInfoList.isNullOrEmpty()) {
|
||||||
|
currentUserId = null
|
||||||
|
}
|
||||||
//recognizeViewModel.clearLeftFace(facePreviewInfoList)
|
//recognizeViewModel.clearLeftFace(facePreviewInfoList)
|
||||||
clearLeftFaceData()
|
clearLeftFaceData()
|
||||||
}
|
}
|
||||||
@@ -1154,8 +1158,19 @@ class MainScreenPresentation(
|
|||||||
if (userNutrition == null || currentFood == null || currentUserId == null) {
|
if (userNutrition == null || currentFood == null || currentUserId == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
postUserData()
|
createOrder(notEnoughOneBlock = {
|
||||||
if (mealPickupMode == 1 || isKeepFaceState) {
|
if (mealPickupMode == 0) {
|
||||||
|
currentStep = 2
|
||||||
|
step2FaceRecognizing(currentFood!!)
|
||||||
|
}
|
||||||
|
}){
|
||||||
|
if (MyApp.DEBUG) {
|
||||||
|
ToastUtils.showToast("订单已生成")
|
||||||
|
}
|
||||||
|
currentUserId = null
|
||||||
|
//ToastUtils.showToast("isKeepFaceState=$isKeepFaceState,mealPickupMode=$mealPickupMode")
|
||||||
|
//|| isKeepFaceState
|
||||||
|
if (mealPickupMode == 1) {
|
||||||
step2FaceRecognizing(currentFood!!)
|
step2FaceRecognizing(currentFood!!)
|
||||||
isKeepFaceState = false
|
isKeepFaceState = false
|
||||||
} else {
|
} else {
|
||||||
@@ -1165,12 +1180,9 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun postUserData() {
|
|
||||||
createOrder()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createOrder() {
|
fun createOrder(notEnoughOneBlock: ()-> Unit={}, block: ()-> Unit) {
|
||||||
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||||
val eatWeight = if (mealPickupMode == 0) {
|
val eatWeight = if (mealPickupMode == 0) {
|
||||||
//即放即取
|
//即放即取
|
||||||
@@ -1192,13 +1204,14 @@ class MainScreenPresentation(
|
|||||||
foodWeight = lastWeight.roundToInt(),
|
foodWeight = lastWeight.roundToInt(),
|
||||||
eatWeight = eatWeight.roundToInt(),
|
eatWeight = eatWeight.roundToInt(),
|
||||||
eatNum = activity.getEatNum(eatWeight, currentFood!!.specWeight),
|
eatNum = activity.getEatNum(eatWeight, currentFood!!.specWeight),
|
||||||
userId = currentUserId
|
userId = currentUserId,
|
||||||
) {
|
notEnoughOneBlock = notEnoughOneBlock,
|
||||||
if (MyApp.DEBUG) {
|
block = {
|
||||||
ToastUtils.showToast("订单已生成")
|
activity.runOnUiThread {
|
||||||
|
block()
|
||||||
}
|
}
|
||||||
currentUserId = null
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearLeftFaceData() {
|
private fun clearLeftFaceData() {
|
||||||
|
|||||||
Reference in New Issue
Block a user