Browse Source

处理关闭当前页面

zhangshenjie 2 months ago
parent
commit
553df67b5f

+ 1 - 0
BusinessCommon/src/main/java/com/develop/common/utils/CommonTuyaSoUtils.kt

@@ -75,6 +75,7 @@ object CommonTuyaSoUtils {
             if (CofarSDK.devInfo().runningStatus == DevStatus.STOP){
                 TuyaUtilsSo.getInstance().mapClean()
                 TuyaUtilsSo.getInstance().uploadData()
+                TuyaUtilsSo.getInstance().isUser=true;
             }
             return
         }

+ 6 - 184
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -454,6 +454,7 @@ public class TuyaUtilsSo {
 
 
     public void uploadData() {
+        Log.i("tuya_iot","tuyaNetwork :"+tuyaNetwork + " isUser :"+isUser + "   isWeight:"+isWeight);
         if (!tuyaNetwork || !isUser) {
             return;
         }
@@ -466,7 +467,10 @@ public class TuyaUtilsSo {
                 BaseDevMode mode = info.getMode();
                 int time = (int) System.currentTimeMillis();
                 if (getAutoMaticModes(info.getRunningInstId()) != autoMaticType) {
-                    return;
+                    //称重的时候不忽略   由于称重的runningId 是 diy 对应不上,估在下面再处理多一个判断
+                    if (!info.isWeightStatus()){
+                        return;
+                    }
                 }
 
 //                Log.e("tuya_iot",info.toString());
@@ -575,7 +579,6 @@ public class TuyaUtilsSo {
                     if (event.type == DPEvent.Type.PROP_ENUM) {
                         sendDpEnum(event.dpid, value, time);
                     }
-
                 }
             }
         }).start();
@@ -637,39 +640,7 @@ public class TuyaUtilsSo {
 
                 int automatic = getModes(info.getRunningInstId());
 
-//                DPEvent[] dpEvents = new DPEvent[]{
-//                        new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
-//                        new DPEvent(TuyaSoDp.START_STOP, (byte) DPEvent.Type.PROP_BOOL, start_stop, 0),
-//                        new DPEvent(TuyaSoDp.AUTOMATIC_PROGRAM, (byte) DPEvent.Type.PROP_ENUM, automatic, 0),
-//                        new DPEvent(TuyaSoDp.WORK_STATE, (byte) DPEvent.Type.PROP_ENUM, work_state, 0),
-//                        new DPEvent(TuyaSoDp.COOKING_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getTargetTempBuffer() != -1 ? info.getTargetTempBuffer() : info.getTargetTemp()), 0),
-//                        new DPEvent(TuyaSoDp.CURRENT_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) CofarUtils.parseTemp(info.getTemp()), 0),
-////                        new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, 1, 0),
-////                        new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE,1, 0),
-//
-//                        new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime(), 0),
-//                        new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getRemainTime(), 0),
-//                        new DPEvent(TuyaSoDp.PAUSE, (byte) DPEvent.Type.PROP_BOOL, pause, 0),
-//                        new DPEvent(TuyaSoDp.SPEED, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getMotorGearBuffer() != -1 ? info.getMotorGearBuffer() : info.getMotorGear()), 0),
-//                        new DPEvent(TuyaSoDp.REVERSIBLE, (byte) DPEvent.Type.PROP_BOOL, (int) (info.getMotorDirectionBuffer() != -1 ? info.getMotorDirectionBuffer() : info.getMotorDirection()), 0),
-//                        new DPEvent(TuyaSoDp.POT_STATUS, (byte) DPEvent.Type.PROP_VALUE, pot_status, 0),
-//                        new DPEvent(TuyaSoDp.WEIGHT_NUMBER, (byte) DPEvent.Type.PROP_VALUE, info.getWeight(), 0),
-//                        new DPEvent(TuyaSoDp.POT_CLOVER_STATUS, (byte) DPEvent.Type.PROP_VALUE, (int) info.getPotCloverStatus(), 0),
-//                        new DPEvent(TuyaSoDp.MAX_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTime(), 0),
-//                        new DPEvent(TuyaSoDp.MIN_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTime(), 0),
-//                        new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTemp(), 0),
-//                        new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTemp(), 0),
-//
-////                        new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : 88, 0),
-////                        new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : 50, 0),
-//                        new DPEvent(TuyaSoDp.MAX_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxMotorGear(), 0),
-//                        new DPEvent(TuyaSoDp.MIN_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinMotorGear(), 0),
-//                        new DPEvent(TuyaSoDp.TIME_CHANGE, (byte) DPEvent.Type.PROP_BOOL, timeChange, 0),
-//                        new DPEvent(TuyaSoDp.TEMP_CHANGE, (byte) DPEvent.Type.PROP_BOOL, tempChange, 0),
-//                        new DPEvent(TuyaSoDp.MOTOR_GEAR_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorGearChange, 0),
-//                        new DPEvent(TuyaSoDp.MOTOR_DIRECTION_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorDirectionChange, 0)
-//
-//                };
+
 
                 List<DPEvent> dpEvents = new ArrayList<>(Arrays.asList(
                         new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
@@ -743,155 +714,6 @@ public class TuyaUtilsSo {
 //        ioTSDKManager.sendDP(dpEvents);
     }
 
-//    public void uploadDataCleanZero(){
-//        if (!tuyaNetwork) {
-//            return;
-//        }
-//
-//
-//        new Thread(new Runnable() {
-//            @Override
-//            public void run() {
-//                DevInfo info = CofarSDK.devInfo();
-//                BaseDevMode mode = info.getMode();
-//
-//                Log.v("tuya_iot",info.toString());
-////                BaseDevMode mode = baseDevMode;
-////                Log.e("tuya_iot",mode.toString());
-//                int status = info.getStatus();
-//                //getStatus    0 stop  1 start  2 pause
-//                int start_stop = status == 0 ? 0 : 1;   // 这里有个暂停,个人认为,暂停算是运行的一部分
-//                int pause = status == 2 ? 1 : 0;
-//                int pot_status = 0;
-//                if (info.getDevMode().equals("SOUP")) {
-//                    pot_status = 0;
-//                } else if (info.getDevMode().equals("AIR_FRYER")) {
-//                    pot_status = 1;
-//                } else if (info.getDevMode().equals("STAND_MIXER")) {
-//                    pot_status = 3;
-//                } else {
-//                    pot_status = 0;
-//                }
-//                int work_state = 0;
-//                if (status == 0) {
-//                    work_state = 0;
-//                } else if (status == 1) {
-//                    work_state = 3;
-//                } else if (status == 2) {
-//                    work_state = 2;
-//                }
-//
-//
-//                int timeChange = 1;
-//                int tempChange = 1;
-//                int motorGearChange = 1;
-//                int motorDirectionChange = 1;
-//                if (mode == null) {
-//                } else {
-//                    timeChange = mode.isTimeChange() ? 1 : 0;
-//                    tempChange = mode.isTempChange() ? 1 : 0;
-//                    motorGearChange = mode.isMotorGearChange() ? 1 : 0;
-//                    motorDirectionChange = mode.isMotorDirectionChange() ? 1 : 0;
-//                }
-//
-//
-//                int automatic = getModes(info.getRunningInstId());
-//
-////                DPEvent[] dpEvents = new DPEvent[]{
-////                        new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
-////                        new DPEvent(TuyaSoDp.START_STOP, (byte) DPEvent.Type.PROP_BOOL, start_stop, 0),
-////                        new DPEvent(TuyaSoDp.AUTOMATIC_PROGRAM, (byte) DPEvent.Type.PROP_ENUM, automatic, 0),
-////                        new DPEvent(TuyaSoDp.WORK_STATE, (byte) DPEvent.Type.PROP_ENUM, work_state, 0),
-////                        new DPEvent(TuyaSoDp.COOKING_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getTargetTempBuffer() != -1 ? info.getTargetTempBuffer() : info.getTargetTemp()), 0),
-////                        new DPEvent(TuyaSoDp.CURRENT_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) CofarUtils.parseTemp(info.getTemp()), 0),
-//////                        new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, 1, 0),
-//////                        new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE,1, 0),
-////
-////                        new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime(), 0),
-////                        new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getRemainTime(), 0),
-////                        new DPEvent(TuyaSoDp.PAUSE, (byte) DPEvent.Type.PROP_BOOL, pause, 0),
-////                        new DPEvent(TuyaSoDp.SPEED, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getMotorGearBuffer() != -1 ? info.getMotorGearBuffer() : info.getMotorGear()), 0),
-////                        new DPEvent(TuyaSoDp.REVERSIBLE, (byte) DPEvent.Type.PROP_BOOL, (int) (info.getMotorDirectionBuffer() != -1 ? info.getMotorDirectionBuffer() : info.getMotorDirection()), 0),
-////                        new DPEvent(TuyaSoDp.POT_STATUS, (byte) DPEvent.Type.PROP_VALUE, pot_status, 0),
-////                        new DPEvent(TuyaSoDp.WEIGHT_NUMBER, (byte) DPEvent.Type.PROP_VALUE, info.getWeight(), 0),
-////                        new DPEvent(TuyaSoDp.POT_CLOVER_STATUS, (byte) DPEvent.Type.PROP_VALUE, (int) info.getPotCloverStatus(), 0),
-////                        new DPEvent(TuyaSoDp.MAX_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTime(), 0),
-////                        new DPEvent(TuyaSoDp.MIN_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTime(), 0),
-////                        new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTemp(), 0),
-////                        new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTemp(), 0),
-////
-//////                        new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : 88, 0),
-//////                        new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : 50, 0),
-////                        new DPEvent(TuyaSoDp.MAX_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxMotorGear(), 0),
-////                        new DPEvent(TuyaSoDp.MIN_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinMotorGear(), 0),
-////                        new DPEvent(TuyaSoDp.TIME_CHANGE, (byte) DPEvent.Type.PROP_BOOL, timeChange, 0),
-////                        new DPEvent(TuyaSoDp.TEMP_CHANGE, (byte) DPEvent.Type.PROP_BOOL, tempChange, 0),
-////                        new DPEvent(TuyaSoDp.MOTOR_GEAR_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorGearChange, 0),
-////                        new DPEvent(TuyaSoDp.MOTOR_DIRECTION_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorDirectionChange, 0)
-////
-////                };
-//
-//                List<DPEvent> dpEvents = new ArrayList<>(Arrays.asList(
-//                        new DPEvent(TuyaSoDp.COOKING_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.CURRENT_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.SPEED, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.REVERSIBLE, (byte) DPEvent.Type.PROP_BOOL, 0, 0),
-//                        new DPEvent(TuyaSoDp.MAX_TIME, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.MIN_TIME, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.MAX_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.MIN_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, 0, 0),
-//                        new DPEvent(TuyaSoDp.TIME_CHANGE, (byte) DPEvent.Type.PROP_BOOL, timeChange, 0),
-//                        new DPEvent(TuyaSoDp.TEMP_CHANGE, (byte) DPEvent.Type.PROP_BOOL, tempChange, 0),
-//                        new DPEvent(TuyaSoDp.MOTOR_GEAR_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorGearChange, 0),
-//                        new DPEvent(TuyaSoDp.MOTOR_DIRECTION_CHANGE, (byte) DPEvent.Type.PROP_BOOL, motorDirectionChange, 0)
-//                ));
-//
-//
-//
-//
-//                /**
-//                 * 数值类型需要用  send_dp_value
-//                 * 枚举类型需要用  send_dp_enum
-//                 * 布尔值类型需要用 send_dp_bool
-//                 * */
-//
-//                //上报指令
-//                for (DPEvent event : dpEvents) {
-//                    int value = -1;
-//                    Object eventValue = event.value;
-//                    if (eventValue instanceof Short) {
-//                        Short shortValue = (Short) eventValue;
-//                        value = shortValue.intValue();
-//                    } else if (eventValue instanceof Integer) {
-//                        value = (int) eventValue;
-//                    } else if (eventValue instanceof Byte) {
-//                        Byte byteValue = (Byte) eventValue;
-//                        value = byteValue.intValue();
-//                    } else {
-//                        value = (int) eventValue;
-//                    }
-//
-//                    if (event.type == DPEvent.Type.PROP_BOOL) {
-//                        sendDpBool(event.dpid, value);
-//                    }
-//                    if (event.type == DPEvent.Type.PROP_VALUE) {
-//                        sendDpValue(event.dpid, value);
-//                    }
-//                    if (event.type == DPEvent.Type.PROP_STR) {
-//                        sendDpStr(event.dpid, String.valueOf(value));
-//                    }
-//                    if (event.type == DPEvent.Type.PROP_ENUM) {
-//                        sendDpEnum(event.dpid, value);
-//                    }
-//
-//                }
-//            }
-//        }).start();
-//    }
 
 
     private int getModes(String enumValue) {

+ 1 - 9
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -395,7 +395,6 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
 
     override fun onDestroy() {
         super.onDestroy()
-        TuyaUtilsSo.getInstance().setDpCurrentActivity()
         isWidget = false
         viewModel.stopTurbo()
         viewModel.cancelAnimator()
@@ -1340,6 +1339,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
     private fun initListener() {
         binding.ivBack.setOnClickListener {
             backClick()
+            TuyaUtilsSo.getInstance().setDpCurrentActivity()
         }
         binding.clCookTemp.setOnClickListener {
             viewModel.changeStep(CookSettingType.TEMP_SETTING)
@@ -2730,14 +2730,6 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
                         Glide.with(this).load(com.develop.common.R.drawable.ic_mode_diy)
                             .into(binding.ivBanner)
                     } else {
-//                        Glide.with(this).load(
-//                            resources.getIdentifier(
-//                                workMode.bg,
-//                                "drawable",
-//                                this.packageName
-//                            )
-//                        )
-//                            .into(binding.ivBanner)
                     }
                 }
                 binding.tvModeName.text =

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

@@ -225,9 +225,9 @@ fun getSN(): String {
 //        return "011D10390020123010190001"
 //        return "011A10390020123010190002"
 //        return "011A10390020123010190002"
-        return  "011D10390020123010190021";
+//        return  "011D10390020123010190021";
 //        return  "011D10390020123010190088";
-//        return  "011D10390020123010190003"
+        return  "011D10390020123010190003"
 //        return  "011A10390020123010190188"
 //        return "011A10390020123010190099"
 //        return "011A10390020123010190009"