|
@@ -25,6 +25,8 @@ import com.develop.common.router.Screens
|
|
|
import com.develop.common.widget.TimePickerView
|
|
|
import com.develop.step.CookSettingType
|
|
|
import com.develop.common.R
|
|
|
+import com.develop.common.bean.CfConfig
|
|
|
+import com.develop.common.bean.WorkMode
|
|
|
import com.develop.common.data_repo.FoodDataProvider
|
|
|
import com.develop.common.data_repo.db.ModesType
|
|
|
import com.develop.common.data_repo.db.entity.UserFavoriteRecipes
|
|
@@ -35,11 +37,14 @@ import com.develop.common.event.CookStepEvent
|
|
|
import com.develop.common.event.RefreshLikeDataEvent
|
|
|
import com.develop.common.food_sdk.FloatWindowManager
|
|
|
import com.develop.common.food_sdk.FoodSdkUtils
|
|
|
+import com.develop.common.food_sdk.GlobalDevEvent
|
|
|
import com.develop.common.tag.CURRENT_USER_ID
|
|
|
+import com.develop.common.tag.MODE_TYPE
|
|
|
import com.develop.common.tag.PRESS_DOWN_KEY_CODE
|
|
|
import com.develop.common.tag.TURN_DOWN_KEY_CODE
|
|
|
import com.develop.common.tag.TURN_UP_KEY_CODE
|
|
|
import com.develop.common.utils.CofarUtils
|
|
|
+import com.develop.common.utils.ConfigUtils
|
|
|
import com.develop.common.utils.TimeUtil
|
|
|
import com.develop.step.ui.cook_step.model.CookStepStatus
|
|
|
import com.develop.step.ui.cook_step.model.CookStepUiData
|
|
@@ -47,6 +52,7 @@ import com.drake.net.time.Interval
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.constant.core.*
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.core.DevInfo
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevCommonEvent
|
|
|
+import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevStatusEvent
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
@@ -65,6 +71,8 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
private var potCloverStatus = 1 //锅盖是否盖上 0 是 1 否
|
|
|
private var coverPath: Any? = null
|
|
|
private var isFromOverWrite = false
|
|
|
+ private var configJson: CfConfig? = null
|
|
|
+ private var isSelectMode: String? = ""
|
|
|
|
|
|
@JvmField
|
|
|
@Autowired(name = "cook_step_detail")
|
|
@@ -84,11 +92,12 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
private var currTime = 0
|
|
|
private var potCloverInterval: Interval? = null
|
|
|
private var potCloverEleStatus = 0
|
|
|
- private var photoPath:String? = ""
|
|
|
+ private var photoPath: String? = ""
|
|
|
private var currentBgId = R.drawable.pot_clover_ele_unlock //0是开锁图,1上锁图
|
|
|
- private fun turnDevModeUI() {
|
|
|
+ private fun turnDevModeUI(devMode: String?) {
|
|
|
+ isSelectMode = devMode
|
|
|
|
|
|
- if (CofarSDK.devInfo().devMode == DevModes.AIR_FRYER) {
|
|
|
+ if (isSelectMode == DevModes.AIR_FRYER) {
|
|
|
//隐藏点击
|
|
|
binding.controller.clCookDirection.visibility = View.GONE;
|
|
|
binding.controller.clCookSpeed.visibility = View.GONE;
|
|
@@ -98,11 +107,12 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
binding.controller.clTextView.visibility = View.INVISIBLE
|
|
|
}
|
|
|
|
|
|
- if (CofarSDK.devInfo().devMode == DevModes.SOUP) {
|
|
|
+ if (isSelectMode == DevModes.SOUP) {
|
|
|
//隐藏点击
|
|
|
binding.controller.clCookDirection.visibility = View.VISIBLE;
|
|
|
binding.controller.clCookSpeed.visibility = View.VISIBLE;
|
|
|
binding.controller.clCookWater.visibility = View.GONE
|
|
|
+ binding.controller.clTextView.visibility = View.GONE
|
|
|
|
|
|
}
|
|
|
|
|
@@ -111,6 +121,9 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
|
+ //做食谱步骤判断
|
|
|
+ configJson = ConfigUtils.loadConfig()
|
|
|
+
|
|
|
if (!isNightTheme()) {
|
|
|
binding.viewChangeCrush.setBgColor(R.color.view_change)
|
|
|
binding.viewChangeWeight.setBgColor(R.color.view_change)
|
|
@@ -264,7 +277,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
}
|
|
|
initData()
|
|
|
initStepData()
|
|
|
- turnDevModeUI()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private fun initData() {
|
|
@@ -272,6 +285,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
viewModel.stepDisplay.observe(this) { it ->
|
|
|
coverPath = FoodDataProvider.getImagePath(it.source.photoVideoFilePath)
|
|
|
currModes = it.workMode
|
|
|
+ isSelectMode = currModes // 做弹窗记录
|
|
|
if (it.workMode == "Final Step") {
|
|
|
binding.viewWeightClose1.setGone()
|
|
|
binding.viewWeightClose.setGone()
|
|
@@ -299,7 +313,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
binding.ivNextStep.setVisible()
|
|
|
}
|
|
|
|
|
|
- photoPath = it.source.photoVideoFilePath;
|
|
|
+ photoPath = it.source.photoVideoFilePath;
|
|
|
if (photoPath == null || photoPath == "") {
|
|
|
photoPath = viewModel.recipe?.photoPath;
|
|
|
}
|
|
@@ -392,7 +406,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
binding.ivPrevStep.setVisible()
|
|
|
binding.ivNextStep.setVisible()
|
|
|
}
|
|
|
- photoPath = it.source.photoVideoFilePath;
|
|
|
+ photoPath = it.source.photoVideoFilePath;
|
|
|
if (photoPath == null || photoPath == "") {
|
|
|
photoPath = viewModel.recipe?.photoPath;
|
|
|
}
|
|
@@ -421,11 +435,11 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
if (CofarSDK.devInfo().runningInstId != null) {
|
|
|
val info = CofarSDK.devInfo().runningInstId.split(":");
|
|
|
val cookStepEvent = CookStepEvent(
|
|
|
- recipeNumber = info[0],
|
|
|
- coverPath = photoPath!!,
|
|
|
- step = info[1].toInt(),
|
|
|
- isMode = false,
|
|
|
- modeName = this@CookStepActivity.binding.tvTitleStep.text.toString()
|
|
|
+ recipeNumber = info[0],
|
|
|
+ coverPath = photoPath!!,
|
|
|
+ step = info[1].toInt(),
|
|
|
+ isMode = false,
|
|
|
+ modeName = this@CookStepActivity.binding.tvTitleStep.text.toString()
|
|
|
|
|
|
|
|
|
)
|
|
@@ -457,7 +471,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
coverPath as String,
|
|
|
viewModel.stepIndex,
|
|
|
isMode = false,
|
|
|
- modeName = this@CookStepActivity.binding.tvTitleStep.text.toString()
|
|
|
+ modeName = this@CookStepActivity.binding.tvTitleStep.text.toString()
|
|
|
)
|
|
|
FloatWindowManager.showStepFlowWindow(cookStepEvent)
|
|
|
recordRecipes()
|
|
@@ -540,8 +554,29 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //没有食谱步骤
|
|
|
+ if (viewModel.allSteps.size == 0) {
|
|
|
+ finish()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var workModes: WorkMode? =
|
|
|
+ configJson?.workModes?.find { it.type == viewModel.allSteps[viewModel.stepIndex].workMode }
|
|
|
+ ?: return
|
|
|
+ var workDevMode = workModes?.devMode
|
|
|
+ //由于菜谱内包含汤锅和空炸估做判断当前步骤是否是所需要得锅
|
|
|
+ if (workDevMode != CofarSDK.devInfo().devMode) {
|
|
|
+ GlobalDevEvent.msgDilaog(
|
|
|
+ supportFragmentManager, getString(com.develop.common.R.string.step_pot_error),
|
|
|
+ getString(com.develop.common.R.string.confirm), workDevMode
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ turnDevModeUI(workDevMode)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
override fun clickNextStep() {
|
|
@@ -612,16 +647,42 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
whereIndex = -1
|
|
|
binding.controller.clSetTime.stopAlphaAnim()
|
|
|
if (tag == BUTTON_TAG_START) {
|
|
|
- if (CofarSDK.devInfo().potCloverStatus.toInt() == 1) {
|
|
|
- showPotCloverDialog()
|
|
|
- } else if (CofarSDK.devInfo().runningInstId != "${recipeNumber}:${viewModel.stepIndex}") {
|
|
|
- overrideModeDialog.showDialog(supportFragmentManager, "overrideModeDialog")
|
|
|
+
|
|
|
+ isClickType = 1
|
|
|
+ //判断是否是空炸错误,由于汤锅错误SDK 已经做了 ;
|
|
|
+ if (ConfigUtils.getBooleanErrCode(CofarSDK.devInfo().errCode.toInt())) {
|
|
|
+ showErrCodeDialog(CofarSDK.devInfo().errCode.toInt())
|
|
|
} else {
|
|
|
- viewModel.displayStep()?.let {
|
|
|
- viewModel.setTargetCookingStep(it)
|
|
|
- configDataAndStart(it.uiData)
|
|
|
+ if (viewModel.allSteps.size == 0) {
|
|
|
+ //没有菜谱步骤
|
|
|
+ return
|
|
|
}
|
|
|
- recordRecipes()
|
|
|
+ var workModes =
|
|
|
+ configJson?.workModes?.find { it.type == viewModel.allSteps[viewModel.stepIndex].workMode }
|
|
|
+ var wrokDevMode = workModes?.devMode
|
|
|
+ //由于菜谱内包含汤锅和空炸估做判断当前步骤是否是所需要得锅
|
|
|
+ if (wrokDevMode != CofarSDK.devInfo().devMode) {
|
|
|
+ GlobalDevEvent.msgDilaog(
|
|
|
+ supportFragmentManager,
|
|
|
+ getString(com.develop.common.R.string.step_pot_error),
|
|
|
+ getString(com.develop.common.R.string.confirm),
|
|
|
+ wrokDevMode
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ if (CofarSDK.devInfo().potCloverStatus.toInt() == 1) {
|
|
|
+ showPotCloverDialog()
|
|
|
+ } else if (CofarSDK.devInfo().runningInstId != "${recipeNumber}:${viewModel.stepIndex}") {
|
|
|
+ overrideModeDialog.showDialog(supportFragmentManager, "overrideModeDialog")
|
|
|
+ } else {
|
|
|
+ viewModel.displayStep()?.let {
|
|
|
+ viewModel.setTargetCookingStep(it)
|
|
|
+ configDataAndStart(it.uiData)
|
|
|
+ }
|
|
|
+ recordRecipes()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
} else if (tag == BUTTON_TAG_PAUSE) {
|
|
|
CofarSDK.pause()
|
|
@@ -632,6 +693,9 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
binding.controller.btnStart.setGone()
|
|
|
binding.controller.btnReset.setGone()
|
|
|
} else if (tag == BUTTON_TAG_STOP) {
|
|
|
+ //中途系统出现故障记录
|
|
|
+ isClickType = 0
|
|
|
+
|
|
|
CofarSDK.stop(true)
|
|
|
} else if (tag == BUTTON_TAG_RESET) {
|
|
|
val current = viewModel.displayStep() ?: return
|
|
@@ -1186,6 +1250,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
return super.onKeyDown(keyCode, event)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 所有步骤已经结束,展示结束页面
|
|
|
*/
|
|
@@ -1222,6 +1287,7 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 根据UI状态刷新View
|
|
|
*/
|
|
@@ -1400,6 +1466,25 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
}, 500)
|
|
|
}
|
|
|
|
|
|
+ @Subscribe
|
|
|
+ fun onDevStateEvent(event: DevStatusEvent) {
|
|
|
+ Log.d("TAG dddddd", "cook event:" + event.devInfo.toString())
|
|
|
+ //由于sdk没有判断E7到E16 需要判断运行和暂停过程中,设备发生故障弹出窗口告知故障
|
|
|
+ if (isClickType == DevStatus.RUNNING.toInt() || isClickType == DevStatus.PAUSE.toInt()) {
|
|
|
+ if (ConfigUtils.getBooleanErrCode(event.devInfo.errCode.toInt())) {
|
|
|
+ showErrCodeDialog(event.devInfo.errCode.toInt())
|
|
|
+ isClickType = event.devInfo.status
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ThreadUtils.runOnMainThread {
|
|
|
+ runningState = event.devInfo.status.toInt()
|
|
|
+ onDevStateChange(event.devInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
override fun finish() {
|
|
|
super.finish()
|
|
|
audioUtil.releaseMedia()
|
|
@@ -1424,4 +1509,36 @@ class CookStepActivity : CookStepBaseActivity() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //当换锅的时候,需要做的逻辑
|
|
|
+ @Subscribe
|
|
|
+ fun onDevModeChange(event: DevCommonEvent) {
|
|
|
+ //在当前页面,换了模式以后 重新启动
|
|
|
+ if (CommonEventTypes.DEV_MODE_CHANGE == event.type) {
|
|
|
+ //当步骤所需要的模式和换锅后的模式一致的时候,把弹窗删掉
|
|
|
+ if (isSelectMode == CofarSDK.devInfo().devMode) {
|
|
|
+ GlobalDevEvent.msgDialog.let {
|
|
|
+ if (it.isShow && it.isAdded) {
|
|
|
+ it.removeSelf()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //处理正常步骤,但客户换锅的情况下
|
|
|
+ GlobalDevEvent.msgDialog.let {
|
|
|
+ if (!it.isShow) {
|
|
|
+ GlobalDevEvent.msgDilaog(
|
|
|
+ supportFragmentManager,
|
|
|
+ getString(com.develop.common.R.string.step_pot_error),
|
|
|
+ getString(com.develop.common.R.string.confirm),
|
|
|
+ CofarSDK.devInfo().devMode
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|