|
@@ -45,6 +45,11 @@ import org.greenrobot.eventbus.Subscribe
|
|
|
*/
|
|
|
@Route(path = Screens.Cook.COOK_MODES)
|
|
|
class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesViewMode>() {
|
|
|
+
|
|
|
+ private var modeType = ModesType.CHOP.name
|
|
|
+ private var lastModeType = ModesType.CHOP.name
|
|
|
+
|
|
|
+
|
|
|
private var userChanging = false //当前是否用户在操作
|
|
|
private var currDevInfo = DevInfo()
|
|
|
private var modeChange = false
|
|
@@ -88,8 +93,10 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
|
|
|
viewModel.modeType = intent.extras?.getString(MODE_TYPE, ModesType.CHOP.name) ?: ""
|
|
|
viewModel.lastModeType = viewModel.modeType
|
|
|
+ lastModeType = modeType
|
|
|
+
|
|
|
//初始化模式数据
|
|
|
- initModeData()
|
|
|
+ initModeData(lastModeType)
|
|
|
initData()
|
|
|
initListener()
|
|
|
}
|
|
@@ -389,57 +396,90 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun initModeData() {
|
|
|
+ private fun initModeData(type: String,keep:Boolean=false) {
|
|
|
viewModel.modeType.apply {
|
|
|
val baseMode = CofarSDK.devMode(this)
|
|
|
//显示对应模式UI
|
|
|
if (this == ModesType.WIGHT.name) {
|
|
|
+ CofarSDK.recordConfig()
|
|
|
+
|
|
|
//称重模式
|
|
|
viewModel.changeStep(CookSettingType.WEIGHT)
|
|
|
CofarSDK.changeMode(baseMode)
|
|
|
} else if (this == ModesType.TURBO.name) {
|
|
|
+ CofarSDK.recordConfig()
|
|
|
+
|
|
|
viewModel.changeStep(CookSettingType.TURBO)
|
|
|
CofarSDK.changeMode(baseMode)
|
|
|
} else {
|
|
|
//其他模式
|
|
|
changeCommonStep()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
viewModel.changeStep(CookSettingType.TEMP_SETTING)
|
|
|
- CofarSDK.changeMode(this, baseMode)
|
|
|
- currDevInfo.apply {
|
|
|
- targetTemp = baseMode.maxTemp.toShort()
|
|
|
- motorDirection = baseMode.motorDirection.toByte()
|
|
|
- motorGear = baseMode.defaultMotorGear.toByte()
|
|
|
- targetTime = baseMode.defaultTime.toInt()
|
|
|
- }
|
|
|
|
|
|
- baseMode.apply {
|
|
|
- currentTemp = defaultTemp
|
|
|
- updateTempUI(
|
|
|
- minTemp.toFloat(),
|
|
|
- maxTemp.toFloat(),
|
|
|
- defaultTemp,
|
|
|
- defaultTemp.toString(),
|
|
|
- isTempChange,
|
|
|
- true
|
|
|
- )
|
|
|
+ if(CofarSDK.devInfo().status != DevStatus.PAUSE.toInt()){
|
|
|
|
|
|
- currTime = defaultTime.toLong()
|
|
|
- updateTimeUI(
|
|
|
- minTime, maxTime, defaultTime, defaultTime.toLong(), isTimeChange, true
|
|
|
- )
|
|
|
+ var targetTemp = baseMode.defaultTemp.toShort()
|
|
|
+ var motorDirection = baseMode.motorDirection.toByte()
|
|
|
+ var motorGear = baseMode.defaultMotorGear.toByte()
|
|
|
+ var targetTime = baseMode.defaultTime.toInt()
|
|
|
|
|
|
- currentMotorGer = defaultMotorGear
|
|
|
- updateMotorGearUI(
|
|
|
- minMotorGear.toFloat(),
|
|
|
- maxMotorGear.toFloat(),
|
|
|
- defaultMotorGear,
|
|
|
- isMotorGearChange
|
|
|
- )
|
|
|
+ if(keep){
|
|
|
+ var restoreConfig:DevInfo ?= null
|
|
|
|
|
|
- updateMotorDirectionUI(motorDirection, isMotorDirectionChange)
|
|
|
+ restoreConfig = CofarSDK.changeMode(type, baseMode,true)
|
|
|
+
|
|
|
+ if(restoreConfig != null){
|
|
|
+ targetTemp = restoreConfig.targetTemp;
|
|
|
+ motorDirection = restoreConfig.motorDirection;
|
|
|
+ motorGear = restoreConfig.motorGear;
|
|
|
+ targetTime = restoreConfig.targetTime;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ CofarSDK.changeMode(type, baseMode)
|
|
|
+ }
|
|
|
|
|
|
- updateWeightUI(currDevInfo.weight.toFloat())
|
|
|
+ currDevInfo.apply {
|
|
|
+ targetTemp = baseMode.maxTemp.toShort()
|
|
|
+ motorDirection = baseMode.motorDirection.toByte()
|
|
|
+ motorGear = baseMode.defaultMotorGear.toByte()
|
|
|
+ targetTime = baseMode.defaultTime.toInt()
|
|
|
+ }
|
|
|
+
|
|
|
+ baseMode.apply {
|
|
|
+ currentTemp = CofarSDK.devInfo().targetTemp.toInt()
|
|
|
+ updateTempUI(
|
|
|
+ minTemp.toFloat(),
|
|
|
+ maxTemp.toFloat(),
|
|
|
+ CofarSDK.devInfo().temp.toInt(),
|
|
|
+ targetTemp.toString(),
|
|
|
+ isTempChange,
|
|
|
+ true
|
|
|
+ )
|
|
|
+
|
|
|
+ currTime = defaultTime.toLong()
|
|
|
+ updateTimeUI(
|
|
|
+ minTime, maxTime, defaultTime, targetTime.toLong(), isTimeChange, true
|
|
|
+ )
|
|
|
+
|
|
|
+ currentMotorGer = defaultMotorGear
|
|
|
+ updateMotorGearUI(
|
|
|
+ minMotorGear.toFloat(),
|
|
|
+ maxMotorGear.toFloat(),
|
|
|
+ motorGear.toInt(),
|
|
|
+ true
|
|
|
+ )
|
|
|
+
|
|
|
+ updateMotorDirectionUI(motorDirection.toInt(), isMotorDirectionChange)
|
|
|
+
|
|
|
+ updateWeightUI(currDevInfo.weight.toFloat())
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
initModeData = true
|
|
|
}
|
|
@@ -1085,7 +1125,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
private fun resetConfigClick() {
|
|
|
//确认
|
|
|
userChanging = false
|
|
|
- initModeData()
|
|
|
+ initModeData(modeType)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1117,7 +1157,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
CofarSDK.stop(false)
|
|
|
modeChange = true
|
|
|
viewModel.modeType = ModesType.WIGHT.name
|
|
|
- initModeData()
|
|
|
+ initModeData(viewModel.modeType)
|
|
|
viewModel.changeStep(CookSettingType.WEIGHT)
|
|
|
binding.ivTurbo.visibility = View.GONE
|
|
|
binding.ivWeight.visibility = View.GONE
|
|
@@ -1132,7 +1172,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
CofarSDK.stop(false)
|
|
|
modeChange = true
|
|
|
viewModel.modeType = ModesType.TURBO.name
|
|
|
- initModeData()
|
|
|
+ initModeData(viewModel.modeType)
|
|
|
viewModel.changeStep(CookSettingType.TURBO)
|
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources)
|
|
|
binding.ivTurbo.visibility = View.GONE
|
|
@@ -1161,7 +1201,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
|
|
|
binding.ivBanner.setBackgroundResource(viewModel.getBanner())
|
|
|
modeChange = false
|
|
|
binding.llTurboView.visibility = View.GONE
|
|
|
- initModeData()
|
|
|
+ initModeData(viewModel.modeType, keep = true)
|
|
|
changeCommonStep()
|
|
|
} else if (mRunningState != 0 && viewModel.modeType != ModesType.WIGHT.name && viewModel.modeType != ModesType.TURBO.name) {
|
|
|
if (CofarSDK.devInfo().runningInstId == viewModel.modeType) backRequestDialog.show(
|