fix(main): 优化重量识别逻辑与日志;防抖时间调整为2s;从版本控制中移除.idea和objectbox-models
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
dbe3753821
commit
0127697560
@@ -1,77 +0,0 @@
|
||||
{
|
||||
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
|
||||
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
|
||||
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
|
||||
"entities": [
|
||||
{
|
||||
"id": "1:594331511073099531",
|
||||
"lastPropertyId": "11:7949771231314213889",
|
||||
"name": "Food",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:2317727855243736226",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "4:1528837175750321569",
|
||||
"name": "foodVector",
|
||||
"indexId": "1:6010838397086628487",
|
||||
"type": 28,
|
||||
"flags": 8
|
||||
},
|
||||
{
|
||||
"id": "5:5561277398349179032",
|
||||
"name": "collectId",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "6:8313847979709019172",
|
||||
"name": "foodId",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "7:1375536603452792462",
|
||||
"name": "foodName",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "8:7942065542192169896",
|
||||
"name": "version",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "9:4394472487596452023",
|
||||
"name": "otherField",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "10:5704890122356491756",
|
||||
"name": "createTime",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "11:7949771231314213889",
|
||||
"name": "isDel",
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
}
|
||||
],
|
||||
"lastEntityId": "1:594331511073099531",
|
||||
"lastIndexId": "1:6010838397086628487",
|
||||
"lastRelationId": "0:0",
|
||||
"lastSequenceId": "0:0",
|
||||
"modelVersion": 5,
|
||||
"modelVersionParserMinimum": 5,
|
||||
"retiredEntityUids": [],
|
||||
"retiredIndexUids": [],
|
||||
"retiredPropertyUids": [
|
||||
340951913928211738,
|
||||
5484846939472684412
|
||||
],
|
||||
"retiredRelationUids": [],
|
||||
"version": 1
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
{
|
||||
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
|
||||
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
|
||||
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
|
||||
"entities": [
|
||||
{
|
||||
"id": "1:594331511073099531",
|
||||
"lastPropertyId": "11:7949771231314213889",
|
||||
"name": "Food",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:2317727855243736226",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "4:1528837175750321569",
|
||||
"name": "foodVector",
|
||||
"indexId": "1:6010838397086628487",
|
||||
"type": 28,
|
||||
"flags": 8
|
||||
},
|
||||
{
|
||||
"id": "5:5561277398349179032",
|
||||
"name": "collectId",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "6:8313847979709019172",
|
||||
"name": "foodId",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "7:1375536603452792462",
|
||||
"name": "foodName",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "8:7942065542192169896",
|
||||
"name": "version",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "9:4394472487596452023",
|
||||
"name": "otherField",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "10:5704890122356491756",
|
||||
"name": "createTime",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "11:7949771231314213889",
|
||||
"name": "isDel",
|
||||
"type": 5
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
}
|
||||
],
|
||||
"lastEntityId": "1:594331511073099531",
|
||||
"lastIndexId": "1:6010838397086628487",
|
||||
"lastRelationId": "0:0",
|
||||
"lastSequenceId": "0:0",
|
||||
"modelVersion": 5,
|
||||
"modelVersionParserMinimum": 5,
|
||||
"retiredEntityUids": [],
|
||||
"retiredIndexUids": [],
|
||||
"retiredPropertyUids": [
|
||||
340951913928211738,
|
||||
5484846939472684412
|
||||
],
|
||||
"retiredRelationUids": [],
|
||||
"version": 1
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
private var bottomSheetDialog: CustomBottomSheetDialog? = null
|
||||
private var lastWeight: Int = 0
|
||||
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
||||
private var debouncer = Debouncer(5000)
|
||||
private var debouncer = Debouncer(2000)
|
||||
private var isRecognitionFood = true
|
||||
private var isFirstOpen = true
|
||||
|
||||
@@ -290,26 +290,33 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
* 联合支付-即放即取模式
|
||||
*/
|
||||
private fun loadJFJQBySettlement(weight: Int) {
|
||||
log("registerDataChange weight 联合支付-即放即取")
|
||||
//即放即取+联合支付人脸查询订单完成
|
||||
if (presentation!!.jointPaymentQueryFinish) {
|
||||
log("registerDataChange weight 联合支付-即放即取,人脸查询订单完成")
|
||||
if (weight > WEIGHT_RESET_RECOGNIZE) {
|
||||
//已识别完成人脸并查询到订单数据,增加重量不再重新识别
|
||||
log("registerDataChange weight 联合支付-即放即取,不再重新识别")
|
||||
return
|
||||
}
|
||||
//重量小于等于5克时改为识别中页面
|
||||
log("registerDataChange weight 联合支付-即放即取,step1FoodRecognizing")
|
||||
//重量小于等于10克时改为识别中页面
|
||||
isAnalyzing = false
|
||||
presentation?.step1FoodRecognizing()
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-即放即取,人脸查询订单没有完成")
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
//秤上重量过下,显示识别中页面
|
||||
//秤上重量过小,显示识别中页面
|
||||
log("registerDataChange weight 联合支付-即放即取,重量小于${WEIGHT_RESET_RECOGNIZE}g,step1FoodRecognizing")
|
||||
presentation?.step1FoodRecognizing()
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-即放即取,recognizeByWeight")
|
||||
// val isWeightChange = abs(weight - lastWeight) > 0.02
|
||||
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
|
||||
if (weight != lastWeight) {
|
||||
log("recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
log("registerDataChange weight 联合支付-即放即取,recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
}
|
||||
recognizeByWeight(weight, isWeightChange)
|
||||
}
|
||||
@@ -318,14 +325,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
* 联合支付-余量计量模式
|
||||
*/
|
||||
private fun loadYLJLBySettlement(weight: Int) {
|
||||
log("registerDataChange weight 联合支付-余量计量")
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("registerDataChange weight 联合支付-余量计量,重量小于${WEIGHT_RESET_RECOGNIZE}g,step1FoodRecognizing")
|
||||
//秤上重量过小,显示识别中页面
|
||||
presentation?.step1FoodRecognizing()
|
||||
lastWeight = weight
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-余量计量,订单完成状态:${presentation!!.jointPaymentQueryFinish}")
|
||||
//余量计量+联合支付人脸查询订单完成
|
||||
if (presentation!!.jointPaymentQueryFinish) {
|
||||
log("registerDataChange weight 联合支付-余量计量,updateWeight")
|
||||
presentation?.updateWeight(weight)
|
||||
lastWeight = weight
|
||||
return
|
||||
@@ -342,10 +353,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
}
|
||||
}
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("registerDataChange weight 秤重量小于${WEIGHT_RESET_RECOGNIZE}g")
|
||||
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||
checkedItem = null
|
||||
}
|
||||
if (settlementMode == 0) {
|
||||
log("registerDataChange weight 联合支付模式")
|
||||
//联合支付-------------------------------------------
|
||||
//0-即放即取,1-余量计量
|
||||
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||
@@ -387,36 +400,46 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
}
|
||||
|
||||
private fun recognizeByWeight(weight: Int, isWeightChange: Boolean, block: () -> Unit = {}) {
|
||||
log("registerDataChange weight 开始识别")
|
||||
if (weight != lastWeight) {
|
||||
val payTypeDesc = if (settlementMode == 0) "联合支付" else "独立支付"
|
||||
log("readWeight-${payTypeDesc},weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
log("registerDataChange weight readWeight-${payTypeDesc},weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
}
|
||||
presentation?.updateWeight(weight)
|
||||
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("recognizeByWeight---00002,秤重未超过${WEIGHT_RESET_RECOGNIZE}克")
|
||||
log("registerDataChange weight recognizeByWeight---00002,秤重未超过${WEIGHT_RESET_RECOGNIZE}克")
|
||||
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||
isRecognitionFood = true
|
||||
return
|
||||
}
|
||||
|
||||
if (isWeightChange && isRecognitionFood) {
|
||||
log("recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
||||
log("registerDataChange weight recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
||||
if (presentation?.mealPickupMode == 1 && checkedItem != null) {
|
||||
isRecognitionFood = false
|
||||
return
|
||||
}
|
||||
debouncer.debounce {
|
||||
log("recognizeByWeight---00004")
|
||||
log("registerDataChange weight recognizeByWeight---00004--recognizeFood")
|
||||
recognizeFood()
|
||||
if (presentation?.mealPickupMode == 0) {
|
||||
log("registerDataChange weight recognizeByWeight---00004--recognizeFood,mealPickupMode == 0")
|
||||
lastWeight = weight
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("registerDataChange weight recognizeByWeight---block")
|
||||
block()
|
||||
}
|
||||
if (presentation?.mealPickupMode == 1 || settlementMode == 0) {
|
||||
log("registerDataChange weight recognizeByWeight---lastWeight=${lastWeight}, weight=${weight}, checkedItem=${checkedItem}")
|
||||
if (weight - lastWeight > WEIGHT_CHANGE_VALUE && checkedItem == null) {
|
||||
debouncer.debounce {
|
||||
log("registerDataChange weight重新进行菜品识别 ")
|
||||
recognizeFood()
|
||||
}
|
||||
}
|
||||
lastWeight = weight
|
||||
}
|
||||
}
|
||||
@@ -679,6 +702,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
|
||||
binding.previewView.visible()
|
||||
binding.ivImg.gone()
|
||||
checkedItem = null
|
||||
}
|
||||
|
||||
private fun updateDateTime() {
|
||||
|
||||
@@ -485,6 +485,7 @@ class MainScreenPresentation(
|
||||
binding.nutritionInclude.tvUserName.text = userNutrition?.name.maskName()
|
||||
val recommendCalorie = (userNutrition?.recommendCalorie ?: 0.0).roundedDecimalPlace(1)
|
||||
|
||||
// binding.detailInclude.tvTotalWeight.text = "总重量:${userNutrition?.}克"
|
||||
binding.nutritionInclude.tvRecommendHeat.text =
|
||||
"推荐热量:${recommendCalorie.roundedDecimalPlace(1)}kcal"
|
||||
// binding.nutritionInclude.tvRecommendHeat.text = "推荐热量:${recommendCalorie.removeTrailingZeros()}kcal"
|
||||
@@ -1041,7 +1042,7 @@ class MainScreenPresentation(
|
||||
return@runOnUiThread
|
||||
}
|
||||
}
|
||||
pauseCamera()
|
||||
// pauseCamera()
|
||||
step3ShowRecognizeResult(userId)
|
||||
})
|
||||
|
||||
@@ -1306,29 +1307,33 @@ class MainScreenPresentation(
|
||||
|
||||
val listIsEmpty = facePreviewInfoList.isEmpty()
|
||||
val listFirstTrackId = if (listIsEmpty.not()) facePreviewInfoList[0].trackId else null
|
||||
Timber.tag(TAG)
|
||||
.d("listIsEmpty=$listIsEmpty,lastFaceTrackId=$lastFaceTrackId,listFirstTrackId=$listFirstTrackId")
|
||||
// Timber.tag(TAG)
|
||||
// .d("drawPreviewInfo,listIsEmpty=$listIsEmpty,lastFaceTrackId=$lastFaceTrackId,listFirstTrackId=$listFirstTrackId")
|
||||
if (listIsEmpty || (lastFaceTrackId != listFirstTrackId)) {
|
||||
if (lastFaceTrackId != -1 && currentUserId != null) {
|
||||
//0-即放即取,1-余量计量
|
||||
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||
Timber.tag(TAG).i("$lastFaceTrackId 用户离开")
|
||||
Timber.tag(TAG).i("drawPreviewInfo,$lastFaceTrackId 用户离开")
|
||||
lastFaceTrackId = -1
|
||||
//resumeCamera()
|
||||
Timber.tag(TAG)
|
||||
.d("postUserData userNutritionData是否null: ${userNutrition == null}, currentFood是否null: ${currentFood == null},currentUserId是否null:${currentUserId == null}")
|
||||
.d("drawPreviewInfo,postUserData userNutritionData是否null: ${userNutrition == null}, currentFood是否null: ${currentFood == null},currentUserId是否null:${currentUserId == null}")
|
||||
if (userNutrition == null || currentFood == null || currentUserId == null) {
|
||||
return
|
||||
}
|
||||
Timber.tag(TAG).d("drawPreviewInfo,开始提交订单")
|
||||
createOrder(notEnoughOneBlock = {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,notEnoughOneBlock")
|
||||
if (activity.settlementMode == 0) {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,notEnoughOneBlock,联合模式")
|
||||
setTopInfoVisible()
|
||||
}
|
||||
// if (mealPickupMode == 0) {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,notEnoughOneBlock,step2FaceRecognizing")
|
||||
currentStep = 2
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
// }
|
||||
}, successBlock = {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成")
|
||||
// TODO: 测试人脸识别问题--------------------
|
||||
//recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
|
||||
if (BuildConfig.DEBUG) {
|
||||
@@ -1342,13 +1347,17 @@ class MainScreenPresentation(
|
||||
// activity.isAnalyzing = false
|
||||
// step1FoodRecognizing()
|
||||
// } else {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,mealPickupMode=$mealPickupMode")
|
||||
if (mealPickupMode == 1) {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,step2FaceRecognizing")
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
isKeepFaceState = false
|
||||
if (activity.settlementMode == 0) {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,step2FaceRecognizing,联合支付")
|
||||
setTopInfoVisible()
|
||||
}
|
||||
} else {
|
||||
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,step1FoodRecognizing")
|
||||
activity.isAnalyzing = false
|
||||
step1FoodRecognizing()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user