优化
This commit is contained in:
@@ -118,6 +118,7 @@ class MainScreenPresentation(
|
||||
initView()
|
||||
setupArcCamera()
|
||||
registerDataChange()
|
||||
startTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
private var isFirstGetWeight = true
|
||||
@@ -261,19 +262,34 @@ class MainScreenPresentation(
|
||||
/**
|
||||
* 显示识别出的菜品信息
|
||||
*/
|
||||
fun step3ShowRecognizeResult() {
|
||||
Timber.tag(TAG).d("step3")
|
||||
fun step3ShowRecognizeResult(userId: String) {
|
||||
Timber.tag(TAG).d("main,step3,耗时:${System.currentTimeMillis() - startTime}")
|
||||
LightManager.closeRedLight()
|
||||
LightManager.openGreenLight()
|
||||
currentStep = 3
|
||||
stepChangeCallback(currentStep)
|
||||
if (currentFood == null) {
|
||||
ToastUtils.showToast("选中物品为空")
|
||||
return
|
||||
}
|
||||
// updateFoodInfo(currentFood!!)
|
||||
|
||||
//foodRecSuccess(currentFood!!)
|
||||
//根据接口数据更新热量数据--------------------------
|
||||
userViewModel.getUserNutritionData(userId = userId) { nutrition ->
|
||||
activity.runOnUiThread {
|
||||
if (nutrition == null) {
|
||||
activity.hideWaitingDialog()
|
||||
ToastUtils.showToast("未查询到营养数据")
|
||||
return@runOnUiThread
|
||||
}
|
||||
this@MainScreenPresentation.userNutrition = nutrition
|
||||
loadUnbilledMode()
|
||||
|
||||
val imageUrl =
|
||||
if (currentFood!!.foodImg.isNullOrBlank()) currentFood!!.photoUri else currentFood!!.foodImg
|
||||
binding.ivRecImage.let {
|
||||
it.visible()
|
||||
it.load(imageUrl)
|
||||
}
|
||||
activity.updateImage(imageUrl)
|
||||
activity.hideWaitingDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
@@ -392,14 +408,19 @@ class MainScreenPresentation(
|
||||
calculateNutrition(recognitionWeight - lastWeight)
|
||||
}
|
||||
|
||||
private var isFirstOpen = true
|
||||
var startTime = 0L
|
||||
/**
|
||||
* 餐品识别中
|
||||
*/
|
||||
fun step1FoodRecognizing() {
|
||||
Timber.tag(TAG).d("main,step1,耗时:${System.currentTimeMillis() - startTime}")
|
||||
startTime = System.currentTimeMillis()
|
||||
hideStandbyScreen()
|
||||
activity.resetTouchTime()
|
||||
activity.resumeAnalysis()
|
||||
Timber.tag(TAG).d("step1")
|
||||
if (isFirstOpen.not()) {
|
||||
activity.resumeAnalysis()
|
||||
}
|
||||
//if (abs(lastWeight.toInt()) <= 5) {
|
||||
// activity.runOnUiThread {
|
||||
// ToastUtils.showToast("秤上重量几乎为0,请确认")
|
||||
@@ -426,11 +447,11 @@ class MainScreenPresentation(
|
||||
binding.flCameraView.visible()
|
||||
binding.ivRecImage.gone()
|
||||
binding.ivPreviewImage.visible()
|
||||
binding.ivFrame.visible()
|
||||
binding.ivFaceRecMask.gone()
|
||||
binding.tvFaceTip.gone()
|
||||
binding.llPriceInfo.gone()
|
||||
binding.flFace.gone()
|
||||
binding.ivFrame.gone()
|
||||
binding.flRecognizeIr.gone()
|
||||
|
||||
pauseCamera()
|
||||
@@ -458,7 +479,8 @@ class MainScreenPresentation(
|
||||
*/
|
||||
fun step2FaceRecognizing(foodInfo: FoodInfo) {
|
||||
isGoStep1 = true
|
||||
Timber.tag(TAG).d("step2")
|
||||
Timber.tag(TAG).d("main,step2,耗时:${System.currentTimeMillis() - startTime}")
|
||||
startTime = System.currentTimeMillis()
|
||||
currentStep = 2
|
||||
LightManager.closeRedLight()
|
||||
|
||||
@@ -497,7 +519,8 @@ class MainScreenPresentation(
|
||||
// 当前食物信息
|
||||
private var currentFood: FoodInfo? = null
|
||||
fun updateFood(foodInfo: FoodInfo?) {
|
||||
Timber.tag(TAG).d("updateFood")
|
||||
Timber.tag(TAG).d("main,updateFood,耗时:${System.currentTimeMillis() - startTime}")
|
||||
startTime = System.currentTimeMillis()
|
||||
currentFood = foodInfo
|
||||
if (foodInfo == null) {
|
||||
return
|
||||
@@ -513,6 +536,8 @@ class MainScreenPresentation(
|
||||
if (foodInfo.foodImg.isNullOrBlank()) foodInfo.photoUri else foodInfo.foodImg
|
||||
it.load(imageUrl)
|
||||
}
|
||||
} else {
|
||||
binding.ivRecImage.gone()
|
||||
}
|
||||
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||
if (mode == 0) {
|
||||
@@ -793,28 +818,7 @@ class MainScreenPresentation(
|
||||
return@runOnUiThread
|
||||
}
|
||||
}
|
||||
step3ShowRecognizeResult()
|
||||
//根据接口数据更新热量数据--------------------------
|
||||
userViewModel.getUserNutritionData(userId = userId) { nutrition ->
|
||||
activity.runOnUiThread {
|
||||
if (nutrition == null) {
|
||||
activity.hideWaitingDialog()
|
||||
ToastUtils.showToast("未查询到营养数据")
|
||||
return@runOnUiThread
|
||||
}
|
||||
this@MainScreenPresentation.userNutrition = nutrition
|
||||
loadUnbilledMode()
|
||||
|
||||
val imageUrl =
|
||||
if (currentFood!!.foodImg.isNullOrBlank()) currentFood!!.photoUri else currentFood!!.foodImg
|
||||
binding.ivRecImage.let {
|
||||
it.visible()
|
||||
it.load(imageUrl)
|
||||
}
|
||||
activity.updateImage(imageUrl)
|
||||
activity.hideWaitingDialog()
|
||||
}
|
||||
}
|
||||
step3ShowRecognizeResult(userId)
|
||||
})
|
||||
|
||||
recognizeViewModel.drawRectInfoText.observe(activity, Observer { info ->
|
||||
@@ -1140,10 +1144,9 @@ class MainScreenPresentation(
|
||||
}
|
||||
|
||||
fun postUserData() {
|
||||
Timber.tag(TAG).d("postUserData")
|
||||
if (userNutrition == null || currentFood == null) {
|
||||
Timber.tag(TAG)
|
||||
.d("postUserData userNutritionData = ${userNutrition == null}, currentFood = ${currentFood == null}")
|
||||
Timber.tag(TAG)
|
||||
.d("postUserData userNutritionData是否null: ${userNutrition == null}, currentFood是否null: ${currentFood == null},currentUserId是否null:${currentUserId == null}", )
|
||||
if (userNutrition == null || currentFood == null || currentUserId == null) {
|
||||
return
|
||||
}
|
||||
createOrder()
|
||||
|
||||
Reference in New Issue
Block a user