修改模式切换流程
This commit is contained in:
@@ -11,6 +11,7 @@ object GlobalData {
|
||||
* 设备id
|
||||
*/
|
||||
var deviceId: String = ""
|
||||
|
||||
/**
|
||||
* app版本号
|
||||
*/
|
||||
@@ -38,7 +39,7 @@ object GlobalData {
|
||||
|
||||
var appId = "Hkz1rBk6PZXbS8KwKr67K2eZtsz8bRoMHLg64bUdgCZj"
|
||||
var sdkKey = "AabXs3sHM8UhhE7oCGf4LVMLrdkGb1nJNksbjjTdVt7k"
|
||||
var activeKey = "085F-118G-Q3AB-1WVJ"
|
||||
var activeKey = "085F-118G-Q3LH-HPGZ"//2号楼"085F-118G-Q3AB-1WVJ" 5号楼"085F-118G-Q3LH-HPGZ"
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,4 +60,5 @@ object GlobalKey {
|
||||
const val KEY_TOKEN = "tokenKey"
|
||||
const val KEY_FIRST_RUN = "firstRun"
|
||||
const val KEY_USER_INFO = "userInfoKey"
|
||||
const val KEY_PICKUP_MODE = "pickupMode"
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import com.sw.dualscreen.GlobalData
|
||||
import com.sw.dualscreen.GlobalKey
|
||||
import com.sw.dualscreen.R
|
||||
import com.sw.dualscreen.adapter.GenericItemAdapter
|
||||
import com.sw.dualscreen.adapter.GridSpacingItemDecoration
|
||||
@@ -41,6 +43,7 @@ import com.sw.dualscreen.utils.Debouncer
|
||||
import com.sw.dualscreen.utils.GlideUtils
|
||||
import com.sw.dualscreen.utils.GsonUtils
|
||||
import com.sw.dualscreen.utils.ImageUtil
|
||||
import com.sw.dualscreen.utils.SPUtil
|
||||
import com.sw.dualscreen.view.CustomBottomSheetDialog
|
||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||
import com.sw.dualscreen.viewmodel.UserViewModel
|
||||
@@ -121,7 +124,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
arrayOf("即放即取", "余量取餐")
|
||||
)
|
||||
binding.spinner.adapter = spinnerAdapter
|
||||
binding.spinner.setSelection(0)
|
||||
val mode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0)
|
||||
binding.spinner.setSelection(mode ?: 0)
|
||||
presentation?.updateMealPickupMode(mode ?: 0)
|
||||
binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
@@ -129,6 +134,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
SPUtil.getInstance().put(GlobalKey.KEY_PICKUP_MODE, position)
|
||||
updateCurrentFood(null)
|
||||
isRecognitionFood = true
|
||||
presentation?.updateMealPickupMode(position)
|
||||
}
|
||||
@@ -435,6 +442,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
)
|
||||
presentation!!.setStepChangeCallback { step ->
|
||||
if (step == 1) {
|
||||
Timber.d("setStepChangeCallback${step}")
|
||||
updateCurrentFood(null)
|
||||
bottomSheetDialog?.dismiss()
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ class SecondaryScreenPresentation(
|
||||
// 当前步骤
|
||||
var currentStep: Int = 0
|
||||
|
||||
private var isGoStep1 = false;//防止持续调用
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -189,6 +191,7 @@ class SecondaryScreenPresentation(
|
||||
* 显示人脸识别
|
||||
*/
|
||||
fun step2(foodInfo: FoodInfo) {
|
||||
isGoStep1 = true
|
||||
Timber.d("step2")
|
||||
currentStep = 2
|
||||
LightManager.closeRedLight()
|
||||
@@ -274,10 +277,24 @@ class SecondaryScreenPresentation(
|
||||
fun updateWeight(weight: Double) {
|
||||
lastWeight = weight * 1000 // 将千克转成克
|
||||
Timber.d("updateWeight lastWeight = $weight")
|
||||
if (currentStep == 2 &&
|
||||
lastWeight <= 5 &&
|
||||
isGoStep1
|
||||
) {//人脸识别过程中,秤上物品拿走
|
||||
isGoStep1 = false
|
||||
activity.runOnUiThread {
|
||||
Timber.e("切回step1")
|
||||
step1()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (currentFood == null) {
|
||||
Timber.e("updateWeight currentFood is null")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (userNutritionData == null) {
|
||||
Timber.e("updateWeight userNutritionData is null")
|
||||
return
|
||||
@@ -299,6 +316,7 @@ class SecondaryScreenPresentation(
|
||||
fun updateMealPickupMode(mode: Int) {
|
||||
Timber.d("updateMealPickupMode mode = $mode")
|
||||
mealPickupMode = mode
|
||||
step1()
|
||||
}
|
||||
|
||||
private fun calculateNutrition(weight1: Double) {
|
||||
|
||||
Reference in New Issue
Block a user