Browse Source

处理涂鸦bug

zhangshenjie 2 months ago
parent
commit
00538ebded

+ 52 - 0
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -3,6 +3,7 @@ package com.develop.common.utils;
 import static com.develop.common.tag.CommonTagKt.HISTORYRECIPES;
 
 import android.content.Context;
+import android.os.Handler;
 import android.os.PowerManager;
 import android.util.Log;
 
@@ -28,6 +29,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
 
 public class TuyaUtilsSo {
     /**
@@ -182,6 +185,9 @@ public class TuyaUtilsSo {
                     //启动/停止
                     String str = boolValue == 1 ? "start" : "stop";
                     tuyaEvent(str);
+                    if (str.equals("start")){
+                        startDevInfo(0);
+                    }
                     break;
                 case TuyaSoDp.AUTOMATIC_PROGRAM:
                     /**
@@ -241,6 +247,9 @@ public class TuyaUtilsSo {
                         aa = "start";
                     }
                     tuyaEvent(aa);
+                    if (aa.equals("start")){
+                        startDevInfo(1);
+                    }
                     break;
                 case TuyaSoDp.COOKING_TIME:
                     isUser = true;
@@ -828,6 +837,49 @@ public class TuyaUtilsSo {
         getTuyaApi().send_dp_enum(TuyaSoDp.CURRENT_ACTIVITY, 1, time);
     }
 
+    public void  startDevInfo(int type){
+        //因为下发了start ,需要延迟几秒后判断设备是否正常start
+        //0 stop  1 start  2 pause
+        Timer timer = new Timer();
+        TimerTask task = new TimerTask() {
+
+            @Override
+            public void run() {
+                //加入你在延时之后要做的事
+                DevInfo info = CofarSDK.devInfo();
+                if (type==0){
+                    if (info.getStatus()==0){
+                        setDpStop();
+                    }
+                }else {
+                    if (info.getStatus()==2){
+                        setDpPause();
+                    }
+                }
+            }
+        };
+        //写好上面的声明之后,要调用则可像如下所示:
+        timer.schedule(task, 2500); //task为你想要延时执行的事件,2000为延时2000毫秒
+
+
+
+    }
+
+    public void setDpStop(){
+        //由于app 下发了start指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个stop
+        int time = (int) System.currentTimeMillis();
+        int code = getTuyaApi().send_dp_bool(TuyaSoDp.START_STOP, 0, time);
+
+    }
+
+    public void setDpPause(){
+        //由于app 下发了Pause指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个Pause
+        int time = (int) System.currentTimeMillis();
+        int code = getTuyaApi().send_dp_bool(TuyaSoDp.PAUSE, 1, time);
+
+    }
+
+
     public void setDpFalse() {
         int time = (int) System.currentTimeMillis();
         getTuyaApi().send_dp_enum(134, 0, time);

+ 5 - 3
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -29,7 +29,6 @@ import com.develop.base.ext.runOnMainThread
 import com.develop.base.ext.setGone
 import com.develop.base.ext.setVisible
 import com.develop.base.ext.src
-import com.develop.base.ext.updateText
 import com.develop.base.util.ThreadUtils
 import com.develop.base.util.TuyaEventEntity
 import com.develop.base.widgets.CommonPopupWindow
@@ -676,16 +675,18 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
                 CofarSDK.confirm()
                 resumeClick()
             } else {
-                startClick(false)
+                startClick()
             }
+
         }
 
         if ("stop" == event.type) {
-            stopClick(false)
+            stopClick()
         }
 
         if ("pause" == event.type) {
             pauseClick()
+
         }
 
 
@@ -3204,4 +3205,5 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
     }
 
 
+
 }

+ 0 - 1
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -271,7 +271,6 @@ fun getSN(): String {
 //        return  "000A21050020123010190023"
 //        return "000A50670020123010190005"
 //        return  "033H19050020123010190001"
-
 //        return  "077A10390020123010190023"
     } else {
         //通过反射获取sn号