From 0127697560fb986d745892fc572dbc761490dee5 Mon Sep 17 00:00:00 2001 From: mazengfei <331023091@qq.com> Date: Fri, 3 Apr 2026 15:09:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(main):=20=E4=BC=98=E5=8C=96=E9=87=8D?= =?UTF-8?q?=E9=87=8F=E8=AF=86=E5=88=AB=E9=80=BB=E8=BE=91=E4=B8=8E=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=9B=E9=98=B2=E6=8A=96=E6=97=B6=E9=97=B4=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BA2s=EF=BC=9B=E4=BB=8E=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E4=B8=AD=E7=A7=BB=E9=99=A4.idea=E5=92=8Cobje?= =?UTF-8?q?ctbox-models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 9 +-- .idea/.gitignore | 3 - .idea/.name | 1 - .idea/AndroidProjectSystem.xml | 6 -- .idea/compiler.xml | 6 -- .idea/deploymentTargetSelector.xml | 18 ----- .idea/deviceManager.xml | 13 ---- .idea/gradle.xml | 20 ----- .idea/inspectionProfiles/Project_Default.xml | 6 -- .idea/material_theme_project_new.xml | 10 --- .idea/migrations.xml | 10 --- .idea/misc.xml | 9 --- .idea/runConfigurations.xml | 17 ---- .idea/vcs.xml | 6 -- app/objectbox-models/default.json | 77 ------------------- app/objectbox-models/default.json.bak | 77 ------------------- .../sw/dualscreen/activity/MainActivity.kt | 40 ++++++++-- .../presentation/MainScreenPresentation.kt | 21 +++-- 18 files changed, 50 insertions(+), 299 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.name delete mode 100644 .idea/AndroidProjectSystem.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/deploymentTargetSelector.xml delete mode 100644 .idea/deviceManager.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/material_theme_project_new.xml delete mode 100644 .idea/migrations.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml delete mode 100644 app/objectbox-models/default.json delete mode 100644 app/objectbox-models/default.json.bak diff --git a/.gitignore b/.gitignore index aa724b7..0a2adbc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,12 @@ *.iml .gradle /local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml +/.idea/ .DS_Store /build /captures .externalNativeBuild .cxx local.properties +app/objectbox-models/*.json +app/objectbox-models/*.json.bak diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index f829bf6..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -DualScreen \ No newline at end of file diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml deleted file mode 100644 index 4a53bee..0000000 --- a/.idea/AndroidProjectSystem.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index b589d56..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml deleted file mode 100644 index 43f0d31..0000000 --- a/.idea/deploymentTargetSelector.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml deleted file mode 100644 index 91f9558..0000000 --- a/.idea/deviceManager.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index f94744b..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index cf247ce..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml deleted file mode 100644 index 7a72c89..0000000 --- a/.idea/material_theme_project_new.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml deleted file mode 100644 index f8051a6..0000000 --- a/.idea/migrations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index f031262..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 16660f1..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/objectbox-models/default.json b/app/objectbox-models/default.json deleted file mode 100644 index 7dd04ba..0000000 --- a/app/objectbox-models/default.json +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/app/objectbox-models/default.json.bak b/app/objectbox-models/default.json.bak deleted file mode 100644 index 6f685db..0000000 --- a/app/objectbox-models/default.json.bak +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/app/src/main/java/com/sw/dualscreen/activity/MainActivity.kt b/app/src/main/java/com/sw/dualscreen/activity/MainActivity.kt index dc50ed0..b1959fb 100644 --- a/app/src/main/java/com/sw/dualscreen/activity/MainActivity.kt +++ b/app/src/main/java/com/sw/dualscreen/activity/MainActivity.kt @@ -152,7 +152,7 @@ class MainActivity : BaseActivity() { 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() { * 联合支付-即放即取模式 */ 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() { * 联合支付-余量计量模式 */ 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() { } } 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() { } 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() { binding.previewView.visible() binding.ivImg.gone() + checkedItem = null } private fun updateDateTime() { diff --git a/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt b/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt index 3c6fefd..5c87227 100644 --- a/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt +++ b/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt @@ -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() }