|
@@ -12,6 +12,7 @@ import androidx.lifecycle.MutableLiveData
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import androidx.room.Update
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.develop.base.ext.getModelNum
|
|
|
import com.develop.base.ext.getSN
|
|
|
import com.develop.base.ext.isBrand011A
|
|
|
import com.develop.base.ext.isBrand036I
|
|
@@ -48,12 +49,14 @@ import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.constant.core.WorkModes
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevCommonEvent
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevPromptEvent
|
|
|
+import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevStatusEvent
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
|
|
|
import com.smarx.notchlib.utils.ScreenUtil
|
|
|
import com.tuya.smartai.iot_sdk.Log
|
|
|
import org.alee.component.skin.service.ThemeSkinService
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
|
|
|
@Route(path = Screens.Main.ENTRANCE_CHOSEN)
|
|
|
class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>() {
|
|
@@ -69,11 +72,21 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
|
|
|
private var title = ""
|
|
|
private var isShowLoading = false
|
|
|
+ private var isDevModes = true
|
|
|
+ private var isModelNum = ""
|
|
|
+ private var devMode = ""
|
|
|
+
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
MMkvUtils.save(FIRST_IN, true)
|
|
|
//设置键盘语言
|
|
|
- SettingKeyBoardUtils.setTingKeyBoard(this,MMkvUtils.getString(CURRENT_LANGUAGE)?.lowercase() ?:"en")
|
|
|
+ SettingKeyBoardUtils.setTingKeyBoard(
|
|
|
+ this,
|
|
|
+ MMkvUtils.getString(CURRENT_LANGUAGE)?.lowercase() ?: "en"
|
|
|
+ )
|
|
|
+ devMode = CofarSDK.devInfo().devMode
|
|
|
+ isModelNum = getModelNum()
|
|
|
+
|
|
|
prepareDataLiveData = FoodDataProvider.getPrepareLiveData() as MutableLiveData<Boolean>
|
|
|
prepareDataLiveData.observe(this) {
|
|
|
loadingDialog.removeSelf()
|
|
@@ -138,6 +151,7 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
|
|
|
EntranceType.manual_cooking -> {
|
|
|
if (FoodDataProvider.checkDataExit()) {
|
|
|
+
|
|
|
navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
|
|
|
if (DevModes.SOUP == CofarSDK.devInfo().devMode) {
|
|
@@ -264,96 +278,7 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
}
|
|
|
}
|
|
|
}.models = DataFactory.get002DEntranceData()
|
|
|
- }
|
|
|
-
|
|
|
-// else if (getSN().startsWith("011A")) {
|
|
|
-// binding.entranceRecycle.apply {
|
|
|
-// grid(2)
|
|
|
-// setup {
|
|
|
-// addType<EntranceData>(R.layout.item_entrance)
|
|
|
-// onBind {
|
|
|
-// val itemView = findView<EntranceItemView>(R.id.entrance_item)
|
|
|
-// val params = itemView.layoutParams as LayoutParams
|
|
|
-// params.height = (ScreenUtil.getScreenSize(this@ModeEntranceActivity)[1] / 2)
|
|
|
-// itemView.layoutParams = params
|
|
|
-// itemView.setEntranceData(getModel())
|
|
|
-//
|
|
|
-// }
|
|
|
-// R.id.entrance_item.onClick {
|
|
|
-// val clickModel = getModel<EntranceData>()
|
|
|
-// title = getString(clickModel.title2StrId)
|
|
|
-// when (clickModel.type) {
|
|
|
-// EntranceType.automatic_recipes -> {
|
|
|
-// if (FoodDataProvider.checkDataExit()) {
|
|
|
-// val bundle = Bundle()
|
|
|
-// bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
-// bundle.putInt(RECIPES_TYPE, LocalFood)
|
|
|
-// bundle.putString(HOME_TITLE, title)
|
|
|
-// navigateTo(Screens.Main.HOME) {
|
|
|
-// with(bundle)
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// showLoading()
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// EntranceType.automatic_programmes -> {
|
|
|
-// if (FoodDataProvider.checkDataExit()) {
|
|
|
-// val bundle = Bundle()
|
|
|
-// bundle.putInt(MODE_ENTRANCE, Mode)
|
|
|
-// bundle.putString(HOME_TITLE, title)
|
|
|
-// navigateTo(Screens.Main.HOME) {
|
|
|
-// with(bundle)
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// showLoading()
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// EntranceType.manual_cooking -> {
|
|
|
-// if (FoodDataProvider.checkDataExit()) {
|
|
|
-// navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
-// if (DevModes.SOUP == CofarSDK.devInfo().devMode) {
|
|
|
-// val bundle = Bundle()
|
|
|
-// bundle.putString(MODE_TYPE, WorkModes.ADAPTED_COOKING)
|
|
|
-// bundle.putString(
|
|
|
-// "mode_name",
|
|
|
-// resources.getString(com.develop.common.R.string.adapted_cooking)
|
|
|
-// )
|
|
|
-// with(bundle)
|
|
|
-// } else {
|
|
|
-// val bundle = Bundle()
|
|
|
-// bundle.putString(MODE_TYPE, WorkModes.AF_DIY)
|
|
|
-// with(bundle)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// showLoading()
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// EntranceType.download_new_recipes -> {
|
|
|
-// if (FoodDataProvider.checkDataExit()) {
|
|
|
-// val bundle = Bundle()
|
|
|
-// bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
-// bundle.putInt(RECIPES_TYPE, NetFood)
|
|
|
-// bundle.putString(HOME_TITLE, title)
|
|
|
-// navigateTo(Screens.Main.HOME) {
|
|
|
-// with(bundle)
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// showLoading()
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }.models = DataFactory.get011AEntranceData()
|
|
|
-// }
|
|
|
-//
|
|
|
- else {
|
|
|
+ } else {
|
|
|
binding.entranceRecycle.apply {
|
|
|
grid(2)
|
|
|
setup {
|
|
@@ -400,8 +325,9 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
|
|
|
EntranceType.manual_cooking -> {
|
|
|
if (FoodDataProvider.checkDataExit()) {
|
|
|
+
|
|
|
navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
- if (DevModes.SOUP == CofarSDK.devInfo().devMode) {
|
|
|
+ if (CofarSDK.devInfo().devMode == DevModes.SOUP) {
|
|
|
val bundle = Bundle()
|
|
|
bundle.putString(MODE_TYPE, WorkModes.ADAPTED_COOKING)
|
|
|
bundle.putString(
|
|
@@ -439,9 +365,9 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
}
|
|
|
}.models =
|
|
|
if (isBrand036I()) DataFactory.get036IEntranceData()
|
|
|
- else if (isBrand011A())DataFactory.get011A5037EntranceData()
|
|
|
- else if (isBrand054A())DataFactory.get054AEntranceData()
|
|
|
- else if (getSN().startsWith("045"))DataFactory.get045AEntranceData()
|
|
|
+ else if (isBrand011A()) DataFactory.get011A5037EntranceData()
|
|
|
+ else if (isBrand054A()) DataFactory.get054AEntranceData()
|
|
|
+ else if (getSN().startsWith("045")) DataFactory.get045AEntranceData()
|
|
|
else DataFactory.getEntranceData()
|
|
|
}
|
|
|
|
|
@@ -505,7 +431,7 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //2024.01.04 客户需要把法语的字体变回来
|
|
|
+ //2024.01.04 客户需要把法语的字体变回来
|
|
|
// if (isFrLanguage()) {
|
|
|
// binding.tvFavourite.textSize = HomeActivity.dp20
|
|
|
// binding.tvSetting.textSize = HomeActivity.dp20
|
|
@@ -515,8 +441,8 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
// }
|
|
|
|
|
|
//032客户需要隐藏登录和注册
|
|
|
- if (getSN().startsWith("032D")||getSN().startsWith("011A")){
|
|
|
- binding.tvUserName.visibility = View.GONE
|
|
|
+ if (getSN().startsWith("032D") || getSN().startsWith("011A")) {
|
|
|
+ binding.tvUserName.visibility = View.GONE
|
|
|
//头像需要占位显示
|
|
|
binding.ivAvatar.visibility = View.INVISIBLE
|
|
|
}
|
|
@@ -524,6 +450,7 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
}
|
|
|
|
|
|
override fun onResume() {
|
|
|
+ devMode = CofarSDK.devInfo().devMode
|
|
|
super.onResume()
|
|
|
AppVersionUtil.checkRecipeUpdate(false)
|
|
|
// UpdateUtil.checkApkVersion(false)
|
|
@@ -581,15 +508,41 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
loadingDialog.showDialog(supportFragmentManager, "Loading")
|
|
|
}
|
|
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onDevStateEvent(event: DevStatusEvent) {
|
|
|
+ Log.e("TAG devMode","devMode :$devMode")
|
|
|
+ ////devInfo.potStatus 0是有锅 1是没锅
|
|
|
+ //当没有锅得时候,默认是汤锅模式 //切当前Fragment可见状态 // 只针对5037的处理
|
|
|
+ if (isModelNum == "5037" && event.devInfo.potStatus.toInt() == 1) {
|
|
|
+ // isDevModes 避免重复刷新
|
|
|
+ if (isDevModes && devMode != DevModes.SOUP) {
|
|
|
+ isDevModes = false
|
|
|
+ CofarSDK.changeDevModeFocus(DevModes.SOUP)
|
|
|
+ }
|
|
|
+ } else if (isModelNum == "5037" && event.devInfo.potStatus.toInt() == 0) {
|
|
|
+ /**
|
|
|
+ * 由于客户无锅状态下是默认汤锅列表,但是在一进来是空炸锅,拿出来(无锅的时候已经换了汤锅模式),
|
|
|
+ * 但重新放空炸锅,onDevModeChange 是不会回调的,固需要用potCoverType 锅盖协议来判断是否需要重新换模式
|
|
|
+ * */
|
|
|
+ //potCoverType 0 是汤锅 1是空炸
|
|
|
+ if (event.devInfo.potCloverType.toInt() == 1 && devMode == DevModes.SOUP) {
|
|
|
+ CofarSDK.changeDevModeFocus(DevModes.AIR_FRYER)
|
|
|
+ } else if (event.devInfo.potCloverType.toInt() == 0 && devMode == DevModes.AIR_FRYER) {
|
|
|
+ CofarSDK.changeDevModeFocus(DevModes.SOUP)
|
|
|
+ }
|
|
|
+ isDevModes = true
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Subscribe
|
|
|
fun onDevModeChange(event: DevCommonEvent) {
|
|
|
//在当前页面,换了模式以后 重新启动
|
|
|
-// if (this == TopResumedAtyHolder.getCurrentActivity() && CommonEventTypes.DEV_MODE_CHANGE == event.type) {
|
|
|
-// val intent =
|
|
|
-// Intent(this, ModeEntranceActivity::class.java)
|
|
|
-// intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
-// this.startActivity(intent)
|
|
|
-// }
|
|
|
+ if (CommonEventTypes.DEV_MODE_CHANGE == event.type) {
|
|
|
+ devMode = CofarSDK.devInfo().devMode
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|