Browse Source

011涂鸦优化

zhangshenjie 2 months ago
parent
commit
be590b3684

+ 17 - 8
BusinessCommon/src/main/java/com/develop/common/utils/CommonTuyaSoUtils.kt

@@ -56,13 +56,24 @@ object CommonTuyaSoUtils {
 
     fun navigateToAdaptedCooking(modeType: String) {
         //判断设备是否正在运行,而还判断是否有挂起程序,挂起程序是否自动程序且还要是diy模式才可以重新进入ModeDetail页面
-        if (CofarSDK.devInfo().runningStatus != DevStatus.STOP ) {
+        if (CofarSDK.devInfo().runningStatus != DevStatus.STOP) {
             if (CofarSDK.devInfo().runningInstId != modeType
-                &&(FloatWindowManager.isModeDiyShow() || AppActivityManager.getInstance().topActivity.localClassName.contains(
-                    "ModesDetailActivity") ) ){
+                && (FloatWindowManager.isModeDiyShow() || AppActivityManager.getInstance().topActivity.localClassName.contains(
+                    "ModesDetailActivity"
+                ))
+            ) {
                 EventBus.getDefault().post(TuyaEventEntity(recipeNumber = "", isType = 0))
                 return
             }
+
+            if (AppActivityManager.getInstance().topActivity.localClassName.contains(
+                    "CookStepActivity"
+                )
+            ) {
+                EventBus.getDefault().post(TuyaEventEntity(recipeNumber = "", isType = 0))
+                return
+            }
+
         }
         //当时测试有个BUG,料理机点击diy以后,手机没识别,然后手机点击diy模式,会导致程序崩溃,具体日志没看到什么东西,估在这多一个判断
         //当前模式是diy,且当前页面是ModesDetailActivity的时候,return方法
@@ -72,10 +83,10 @@ object CommonTuyaSoUtils {
                 "ModesDetailActivity"
             )
         ) {
-            if (CofarSDK.devInfo().runningStatus == DevStatus.STOP){
+            if (CofarSDK.devInfo().runningStatus == DevStatus.STOP) {
                 TuyaUtilsSo.getInstance().mapClean()
                 TuyaUtilsSo.getInstance().uploadData()
-                TuyaUtilsSo.getInstance().isUser=true;
+                TuyaUtilsSo.getInstance().isUser = true;
             }
             return
         }
@@ -102,7 +113,7 @@ object CommonTuyaSoUtils {
 
     }
 
-    fun tuyaSoEvent(){
+    fun tuyaSoEvent() {
         AppActivityManager.getInstance().topActivity.apply {
             EventBus.getDefault().post(TuyaSoEvent())
         }
@@ -124,6 +135,4 @@ object CommonTuyaSoUtils {
     }
 
 
-
-
 }

+ 35 - 13
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -1,5 +1,7 @@
 package com.develop.common.utils;
 
+import static com.develop.common.tag.CommonTagKt.HISTORYRECIPES;
+
 import android.content.Context;
 import android.os.PowerManager;
 import android.util.Log;
@@ -221,9 +223,13 @@ public class TuyaUtilsSo {
                     }
 
                     isUser = true;
-                    //烹饪温度
-                    CofarSDK.cfgHeat((short) (int) intValue, mode);
-                    tuyaEvent("change_temp");
+                    DevInfo infoTemp = CofarSDK.devInfo();
+                    BaseDevMode modesTemp = infoTemp.getMode();
+                    if (modesTemp.isTempChange()){
+                        //烹饪温度
+                        CofarSDK.cfgHeat((short) (int) intValue, mode);
+                        tuyaEvent("change_temp");
+                    }
 
                     break;
                 case TuyaSoDp.PAUSE:
@@ -238,9 +244,14 @@ public class TuyaUtilsSo {
                     break;
                 case TuyaSoDp.COOKING_TIME:
                     isUser = true;
-                    //烹饪时间
-                    CofarSDK.cfgTime((int) intValue);
-                    tuyaEvent("change_time");
+                    DevInfo infoTime = CofarSDK.devInfo();
+                    BaseDevMode modesTime = infoTime.getMode();
+                    if (modesTime.isTimeChange()){
+                        //烹饪时间
+                        CofarSDK.cfgTime((int) intValue);
+                        tuyaEvent("change_time");
+                    }
+
 
 
                     break;
@@ -249,15 +260,24 @@ public class TuyaUtilsSo {
                     break;
                 case TuyaSoDp.SPEED:
                     isUser = true;
+                    DevInfo infoGear = CofarSDK.devInfo();
+                    BaseDevMode modesGear = infoGear.getMode();
+                    if (modesGear.isMotorGearChange()){
+                        CofarSDK.cfgMotorGear((byte) intValue);
+                    }
                     //速度
-                    CofarSDK.cfgMotorGear((byte) intValue);
                     break;
                 case TuyaSoDp.REVERSIBLE:
                     isUser = true;
-                    //正反转
-                    CofarSDK.cfgMotorDirection((int) boolValue == 0 ? MotorDirections.FORWARD : MotorDirections.REVERSE);
-                    //按照以前的涂鸦,上面修改转向没有图标没有变动,估在发送一个eventbus
-                    tuyaEvent("change_direction");
+                    DevInfo info = CofarSDK.devInfo();
+                    BaseDevMode modes = info.getMode();
+                    if (modes.isMotorDirectionChange()){
+                        //正反转
+                        CofarSDK.cfgMotorDirection((int) boolValue == 0 ? MotorDirections.FORWARD : MotorDirections.REVERSE);
+                        //按照以前的涂鸦,上面修改转向没有图标没有变动,估在发送一个eventbus
+                        tuyaEvent("change_direction");
+                    }
+
                     break;
                 case TuyaSoDp.WEIGHT_CLEAR:
                     //称重清零
@@ -282,7 +302,6 @@ public class TuyaUtilsSo {
                     if (enumValue == 1) {
                         autoMaticType = -1;
                         isWeight = false;
-                        isUser = false;
                         CommonTuyaSoUtils.INSTANCE.navigateFinish();
                     }
                     break;
@@ -381,6 +400,9 @@ public class TuyaUtilsSo {
     TuyaApi.RestartCallback restartCallback = new TuyaApi.RestartCallback() {
         @Override
         public void invoke() {
+            //解绑的时候,把历史记录去掉
+            MMkvUtils.INSTANCE.save(HISTORYRECIPES, "");
+
             PowerManager pm = (PowerManager) AppActivityManager.getInstance().getTopActivity().getSystemService(Context.POWER_SERVICE);
             pm.reboot("");
         }
@@ -458,7 +480,7 @@ public class TuyaUtilsSo {
 
 
     public void uploadData() {
-        if (!tuyaNetwork || !isUser) {
+        if (!tuyaNetwork) {
             return;
         }