zhangshenjie 4 ay önce
ebeveyn
işleme
b31f3b6dbb
26 değiştirilmiş dosya ile 215 ekleme ve 79 silme
  1. 9 4
      BusinessAirFryer/src/main/assets/config_054.json
  2. 1 1
      BusinessCommon/src/main/java/com/develop/common/food_sdk/FoodSdkUtils.kt
  3. BIN
      BusinessCommon/src/main/res/drawable-xxxhdpi/ic_screensaver.webp
  4. 1 1
      BusinessCommon/src/main/res/values-cz/strings.xml
  5. 1 0
      BusinessCommon/src/main/res/values-de/strings.xml
  6. 1 1
      BusinessCommon/src/main/res/values-en/strings.xml
  7. 1 0
      BusinessCommon/src/main/res/values-es/strings.xml
  8. 1 1
      BusinessCommon/src/main/res/values-fr/strings.xml
  9. 1 1
      BusinessCommon/src/main/res/values-it/strings.xml
  10. 3 0
      BusinessCommon/src/main/res/values-nl/strings.xml
  11. 2 0
      BusinessCommon/src/main/res/values-pl/strings.xml
  12. 1 1
      BusinessCommon/src/main/res/values-pt/strings.xml
  13. 6 0
      BusinessCommon/src/main/res/values-ru/strings.xml
  14. 3 0
      BusinessCommon/src/main/res/values-sk/strings.xml
  15. 1 0
      BusinessCommon/src/main/res/values-tr/strings.xml
  16. 1 0
      BusinessCommon/src/main/res/values-uk/strings.xml
  17. 3 0
      BusinessCommon/src/main/res/values/strings.xml
  18. 19 5
      BusinessMain/src/main/java/com/develop/main/ui/HomeActivity.kt
  19. 2 0
      BusinessSetting/src/main/java/com/develop/setting/ui/SettingMainActivity.kt
  20. 9 1
      BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepActivity.kt
  21. 50 8
      BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepBaseActivity.kt
  22. 17 17
      app/build.gradle
  23. 10 0
      app/src/main/java/com/develop/foodcooking/MainActivity.kt
  24. 3 2
      libBase/src/main/java/com/develop/base/ext/GlobaExt.kt
  25. 69 36
      libBase/src/main/java/com/develop/base/manager/WifiHelp.kt
  26. BIN
      libThirdPart/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar

+ 9 - 4
BusinessAirFryer/src/main/assets/config_054.json

@@ -81,7 +81,6 @@
       "devMode": "SOUP",
       "listShow": true
     },
-
     {
       "type": "CITRUS_JUICER",
       "name": "citrus_juicer",
@@ -98,7 +97,6 @@
       "devMode": "SOUP",
       "listShow": false
     },
-
     {
       "type": "POTATO_PEELER",
       "name": "potato_peeler",
@@ -107,7 +105,6 @@
       "devMode": "SOUP",
       "listShow": false
     },
-
     {
       "type": "AF_DIY",
       "name": "af_diy",
@@ -119,11 +116,19 @@
     {
       "type": "AF_AIR_FRYER",
       "name": "af_air_fryer",
-       "bg": "af_air_fryer_bg",
+      "bg": "af_air_fryer_bg",
       "icon": "af_air_fryer",
       "devMode": "AIR_FRYER",
       "listShow": true
     },
+    {
+      "type": "WIGHT",
+      "name": "wight",
+      "bg": "ic_mode_weight_054",
+      "icon": "ic_grid_weight_054",
+      "devMode": "AIR_FRYER",
+      "listShow": true
+    },
     {
       "type": "AF_BAKE",
       "name": "af_bake",

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/food_sdk/FoodSdkUtils.kt

@@ -12,7 +12,7 @@ object FoodSdkUtils {
     }
 
     fun parseTemp(temp: Short): Short {
-        return if (temp <= 35 && temp.toInt() != 0) {
+        return if (temp <= 37 && temp.toInt() != 0) {
             if(CofarSDK.devInfo().mode is Ferment010D){
                 0
             }else{

BIN
BusinessCommon/src/main/res/drawable-xxxhdpi/ic_screensaver.webp


+ 1 - 1
BusinessCommon/src/main/res/values-cz/strings.xml

@@ -321,5 +321,5 @@ neshromažďujeme žádné vaše osobní údaje.</string>
     <string name="e16_errCode">Please put in the correct pot, or end the current program</string>
 
 
-
+    <string name="step_running_pause">Běžíte, nejprve stiskněte pauzu</string>
 </resources>

+ 1 - 0
BusinessCommon/src/main/res/values-de/strings.xml

@@ -361,5 +361,6 @@ Nanfang plus client ist eine Online-Informationsplattform, die von Guangdong Nan
     <string name="Automatic_programmes_29">Automatische Programme</string>
     <string name="Download_new_recipes_29">Herunterladen neuer Rezepte</string>
 
+    <string name="step_running_pause">Läuft, bitte drücken Sie zuerst Pause</string>
 
 </resources>

+ 1 - 1
BusinessCommon/src/main/res/values-en/strings.xml

@@ -437,5 +437,5 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="turn_left_011">Left</string>
     <string name="preparation_011">Preparation:</string>
     <string name="ready_in_011">Cooking time:</string>
-
+    <string name="step_running_pause">Running, please press pause first</string>
 </resources>

+ 1 - 0
BusinessCommon/src/main/res/values-es/strings.xml

@@ -331,5 +331,6 @@ El cliente Southern plus es una plataforma de información en línea desarrollad
     <string name="Automatic_programmes_29">Programas automáticos</string>
     <string name="Download_new_recipes_29">Descargar nuevas recetas</string>
 
+    <string name="step_running_pause">Corriendo, presione pausa primero</string>
 
 </resources>

+ 1 - 1
BusinessCommon/src/main/res/values-fr/strings.xml

@@ -351,5 +351,5 @@ Southern plus client est une plate - forme d’information en ligne développée
     <string name="Automatic_programmes_29">Programmes automatiques</string>
     <string name="Download_new_recipes_29">Téléchargement de nouvelles recettes</string>
 
-
+    <string name="step_running_pause">En cours d’exécution, veuillez d’abord appuyer sur pause</string>
 </resources>

+ 1 - 1
BusinessCommon/src/main/res/values-it/strings.xml

@@ -340,5 +340,5 @@ Nanfang plus client è una piattaforma di informazioni online sviluppata e gesti
     <string name="Automatic_programmes_29">Programmi automatici</string>
     <string name="Download_new_recipes_29">Scarica nuove ricette</string>
 
-
+    <string name="step_running_pause">In esecuzione, premere prima la pausa</string>
 </resources>

+ 3 - 0
BusinessCommon/src/main/res/values-nl/strings.xml

@@ -319,4 +319,7 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="e14_errCode">Unplug air fryer attachment when in robot cooker mode</string>
     <string name="e15_errCode">TFT screen dissipation abnormal</string>
     <string name="e16_errCode">Please put in the correct pot, or end the current program</string>
+
+
+    <string name="step_running_pause">Hardlopen, druk eerst op pauze</string>
 </resources>

+ 2 - 0
BusinessCommon/src/main/res/values-pl/strings.xml

@@ -402,4 +402,6 @@
     <string name="preparation_011">Przygotowanie:</string>
     <string name="ready_in_011">Czas gotowania:</string>
 
+
+    <string name="step_running_pause">Biegnie, najpierw naciśnij pauzę</string>
 </resources>

+ 1 - 1
BusinessCommon/src/main/res/values-pt/strings.xml

@@ -318,6 +318,6 @@ Nanfang mais cliente é uma plataforma de informação on-line desenvolvida e op
     <string name="Automatic_programmes_29">Automatic programs</string>
     <string name="Download_new_recipes_29">Descarregar novas receitas</string>
 
-
+    <string name="step_running_pause">Em execução, pressione pausar primeiro</string>
 
 </resources>

+ 6 - 0
BusinessCommon/src/main/res/values-ru/strings.xml

@@ -322,4 +322,10 @@
     <string name="e14_errCode">Unplug air fryer attachment when in robot cooker mode</string>
     <string name="e15_errCode">TFT screen dissipation abnormal</string>
     <string name="e16_errCode">Please put in the correct pot, or end the current program</string>
+
+
+
+    <string name="step_running_pause">Во время бега, пожалуйста, сначала нажмите на паузу</string>
+
+
 </resources>

+ 3 - 0
BusinessCommon/src/main/res/values-sk/strings.xml

@@ -233,4 +233,7 @@
     <string name="e14_errCode">Unplug air fryer attachment when in robot cooker mode</string>
     <string name="e15_errCode">TFT screen dissipation abnormal</string>
     <string name="e16_errCode">Please put in the correct pot, or end the current program</string>
+
+    <string name="step_running_pause">Bežíte, najskôr stlačte pauzu</string>
+
 </resources>

+ 1 - 0
BusinessCommon/src/main/res/values-tr/strings.xml

@@ -326,5 +326,6 @@ Nanfang Plus Client, Guangdong Nanfang Newspaper Mobile Media Co, Ltd (bundan b
     <string name="soft">YUMUŞAK</string>
     <string name="waxy_soft">MUMSU YUMUŞAK</string>
 
+    <string name="step_running_pause">Çalışıyor, lütfen önce duraklat’a basın</string>
 
 </resources>

+ 1 - 0
BusinessCommon/src/main/res/values-uk/strings.xml

@@ -386,4 +386,5 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="turn_right_011">Гаразд</string>
     <string name="preparation_011">Підготовка:</string>
     <string name="ready_in_011">Час готування:</string>
+    <string name="step_running_pause">Під час бігу, будь ласка, спочатку натисніть паузу</string>
 </resources>

+ 3 - 0
BusinessCommon/src/main/res/values/strings.xml

@@ -486,4 +486,7 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="turn_left_011">Left</string>
     <string name="preparation_011">Preparation:</string>
     <string name="ready_in_011">Cooking time:</string>
+
+
+    <string name="step_running_pause">Running, please press pause first</string>
 </resources>

+ 19 - 5
BusinessMain/src/main/java/com/develop/main/ui/HomeActivity.kt

@@ -10,6 +10,7 @@ import android.view.View
 import android.widget.LinearLayout
 import androidx.databinding.ViewDataBinding
 import com.alibaba.android.arouter.facade.annotation.Route
+import com.develop.base.ext.appGlobalScope
 import com.develop.base.ext.background_drawable
 import com.develop.base.ext.getGoneLogin
 import com.develop.base.ext.getSN
@@ -41,6 +42,9 @@ 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.DevStatusEvent
 import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
@@ -346,11 +350,21 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
         isResetZero = CofarSDK.devInfo().resetZero.toInt()
         super.onResume()
         wifiHelp.scan()
-        val userInfo = FoodDataProvider
-            .getUserDatabase()
-            .userInfoDao()
-            .queryUserInfoByUserId(CURRENT_USER_ID)
-        updateUserInfoUi(userInfo)
+      updateUserInfo()
+    }
+   fun  updateUserInfo(){
+       appGlobalScope.launch(Dispatchers.IO) {
+           val userInfo = FoodDataProvider
+               .getUserDatabase()
+               .userInfoDao()
+               .queryUserInfoByUserId(CURRENT_USER_ID)
+
+           withContext(Dispatchers.Main){
+               updateUserInfoUi(userInfo)
+           }
+       }
+
+
     }
 
     @Subscribe

+ 2 - 0
BusinessSetting/src/main/java/com/develop/setting/ui/SettingMainActivity.kt

@@ -104,6 +104,7 @@ class SettingMainActivity : CommonBindingActivity<ActivitySettingMainBinding>()
          * 需要隐藏亮度 010D
          *
          * ps:修改了的话,记得同步下面tuya代码
+         * 也要修改GlobaExt 中的 getGoneTuYa
          * */
 
         dataList.clear()
@@ -490,6 +491,7 @@ class SettingMainActivity : CommonBindingActivity<ActivitySettingMainBinding>()
          * 需要隐藏亮度 010D
          *
          * ps:修改了的话,记得同步下面tuya代码
+         * 也要修改GlobaExt 中的 getGoneTuYa
          * */
 
 

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

@@ -120,6 +120,9 @@ class CookStepActivity : CookStepBaseActivity() {
         CancelConfirmDialog()
     }
 
+
+
+
     private fun turnDevModeUI(devMode: String?) {
         isSelectMode = devMode
         binding.controller.clCookTemp.visibility =  View.VISIBLE
@@ -730,8 +733,10 @@ class CookStepActivity : CookStepBaseActivity() {
     }
 
     override fun clickNextStep() {
-        //如果当前步骤运行中,设置了参数,然后切换了界面以后,在返回没有保持在调参数的界面
 
+
+
+        //如果当前步骤运行中,设置了参数,然后切换了界面以后,在返回没有保持在调参数的界面
         if (binding.controller.btnStart.tag == BUTTON_TAG_CONFIRM){
             handleButtonState(BUTTON_TAG_CANCEL)
         }
@@ -758,6 +763,9 @@ class CookStepActivity : CookStepBaseActivity() {
     }
 
     override fun clickPrevStep() {
+
+
+
         //如果当前步骤运行中,设置了参数,然后切换了界面以后,在返回没有保持在调参数的界面
         if (binding.controller.btnStart.tag == BUTTON_TAG_CONFIRM){
             handleButtonState(BUTTON_TAG_CANCEL)

+ 50 - 8
BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepBaseActivity.kt

@@ -132,7 +132,9 @@ abstract class CookStepBaseActivity :
     private val FLING_MIN_DISTANCE = 50
     private val FLING_MIN_VELOCITY = 0
 
-
+    private val runningDilaog by lazy {
+        CancelConfirmDialog()
+    }
 
 
     @SuppressLint("ClickableViewAccessibility")
@@ -142,6 +144,27 @@ abstract class CookStepBaseActivity :
         is011 = isBrand011A()
         hasShowScreenSaver = true
         ARouter.getInstance().inject(this)
+
+        //初始化runningDilaog 的参数
+        runningDilaog.showCancel = false
+        runningDilaog.showConfirm = true
+        runningDilaog.title = resources.getString(R.string.step_running_pause)
+        runningDilaog.confirmStr = resources.getString(R.string.confirm)
+        runningDilaog.onDialogClickListener =
+            object : CancelConfirmDialog.OnDialogClickListener {
+                override fun onConfirm() {
+                    runningDilaog.removeSelf();
+                }
+
+                override fun onCancel() {
+                }
+
+                override fun onKey() {
+                }
+
+            }
+
+
         binding.controller.apply {
             viewIconTemp.background_drawable = R.drawable.cook_temp_selector
             viewIconTime.background_drawable = R.drawable.cook_time_selector
@@ -231,12 +254,21 @@ abstract class CookStepBaseActivity :
         }
 
         binding.ivNextStep.setOnClickListener {
-            clickNextStep()
-            viewModel.stepUiData.doingModify = false
+            if (CofarSDK.devInfo().status == DevStatus.RUNNING.toInt()) {
+                runningDilaog.showDialog(supportFragmentManager, "RunningDialog")
+            } else {
+                clickNextStep()
+                viewModel.stepUiData.doingModify = false
+            }
         }
         binding.ivPrevStep.setOnClickListener {
-            clickPrevStep()
-            viewModel.stepUiData.doingModify = false
+            if (CofarSDK.devInfo().status == DevStatus.RUNNING.toInt()) {
+                runningDilaog.showDialog(supportFragmentManager, "RunningDialog")
+            } else {
+                clickPrevStep()
+                viewModel.stepUiData.doingModify = false
+            }
+
         }
         binding.controller.clCookTemp.setOnClickListener {
             whereIndex = -1
@@ -326,13 +358,23 @@ abstract class CookStepBaseActivity :
         binding.scrollLayout.setOnGestureChangeListener(object :
             BCustomerLinearLayout.OnGestureChangeListener {
             override fun scrollLeft() {
-                //向左手势
-                clickNextStep()
+                if (CofarSDK.devInfo().status == DevStatus.RUNNING.toInt()) {
+                    runningDilaog.showDialog(supportFragmentManager, "RunningDialog")
+                }else{
+                    //向左手势
+                    clickNextStep()
+                }
+
             }
 
             override fun scrollRight() {
+                if (CofarSDK.devInfo().status == DevStatus.RUNNING.toInt()) {
+                    runningDilaog.showDialog(supportFragmentManager, "RunningDialog")
+                }else{
                 //向右手势
                 clickPrevStep()
+                }
+
             }
 
         })
@@ -769,7 +811,7 @@ abstract class CookStepBaseActivity :
     }
 
 
-    private fun popNoteEdit() :PopupWindow {
+    private fun popNoteEdit(): PopupWindow {
         var noteEditPopupWindow =
             CommonPopupWindow.ViewBuilder<NoteEditLayout>()
                 .width(FrameLayout.LayoutParams.MATCH_PARENT)

+ 17 - 17
app/build.gradle

@@ -20,10 +20,10 @@ ext {
 
     versionCode = Integer.parseInt(new SimpleDateFormat("yyMMddHH").format(new Date()) + 1)
 //    versionCode=230617180
-//    brandCode="063B"
-    brandCode = "077A"
-//    model = "5037"
-    model = "1039"
+    brandCode="054A"
+//    brandCode = "053A"
+    model = "5037"
+//    model = "1039"
 
 }
 
@@ -894,24 +894,24 @@ android {
 //            //appCode 1.01 指向bug修复,2.01指向功能变更
 //            buildConfigField("String", "appCode", "\"1.01\"")
 
-//            manifestPlaceholders = [channelName: "brand054ATuya"]
-//            buildConfigField("String", "UpdatePlatform", "\"night\"")
-//            resValue("string", "app_theme", "@style/Splash054ATheme")
-//            buildConfigField("String", "model", "\"5037\"")
-//            buildConfigField("String", "brandCode", "\"054A\"")
-//            //appCode 1.01 指向bug修复,2.01指向功能变更
-//            buildConfigField("String", "appCode", "\"1.01\"")
-//            buildConfigField("String", "time","\"${getCurrentTime()}\"" )
-
-            manifestPlaceholders = [channelName: "brand077ATuya"]
+            manifestPlaceholders = [channelName: "brand054ATuya"]
             buildConfigField("String", "UpdatePlatform", "\"night\"")
-            resValue("string", "app_theme", "@style/SplashThemeNotLogo")
-            buildConfigField("String", "model", "\"1039\"")
-            buildConfigField("String", "brandCode", "\"077A\"")
+            resValue("string", "app_theme", "@style/Splash054ATheme")
+            buildConfigField("String", "model", "\"5037\"")
+            buildConfigField("String", "brandCode", "\"054A\"")
             //appCode 1.01 指向bug修复,2.01指向功能变更
             buildConfigField("String", "appCode", "\"1.01\"")
             buildConfigField("String", "time","\"${getCurrentTime()}\"" )
 
+//            manifestPlaceholders = [channelName: "brand077ATuya"]
+//            buildConfigField("String", "UpdatePlatform", "\"night\"")
+//            resValue("string", "app_theme", "@style/SplashThemeNotLogo")
+//            buildConfigField("String", "model", "\"1039\"")
+//            buildConfigField("String", "brandCode", "\"077A\"")
+//            //appCode 1.01 指向bug修复,2.01指向功能变更
+//            buildConfigField("String", "appCode", "\"1.01\"")
+//            buildConfigField("String", "time","\"${getCurrentTime()}\"" )
+
 
         }
     }

+ 10 - 0
app/src/main/java/com/develop/foodcooking/MainActivity.kt

@@ -8,6 +8,7 @@ import android.util.Log
 import android.view.LayoutInflater
 import android.view.WindowManager
 import androidx.lifecycle.scopeNetLife
+import com.develop.base.ext.getGoneTuYa
 import com.develop.base.ext.globalApp
 import com.develop.base.ext.isBrand062
 import com.develop.base.ext.navigateTo
@@ -92,7 +93,16 @@ class MainActivity : CommonBindingActivity<ActivityMainBinding>() {
         }
 
 
+//        //涂鸦获取,隐藏的涂鸦不请求
+//        if (!getGoneTuYa()){
+//            getDevInfo()
+//        }else{
+//            getAppTuya(true)
+//        }
+
+
         getDevInfo()
+
     }
 
     //获取是否有涂鸦功能

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

@@ -217,7 +217,7 @@ fun getSN(): String {
 //        return "000A30150020123010190001"
 //     return "000A10390020123010170001"
 //     return "000A10390020123010190001"
-//        return "054A50370020123010190001"
+        return "054A50370020123010190001"
 //        return "054A10390020123010190001"
 //        return "010D10390020123010190001"
 //        return "010F10390020123010190001"
@@ -258,12 +258,13 @@ fun getSN(): String {
 //        return  "049B10390020123010190001"
 //        return "000A50370020123010190017"
 //        return  "053A10390020123010190088"
+//          return "053A10390020123010190001"
 //        return  "000A10390020123010190023"
 //        return  "000A21050020123010190023"
 //        return "000A50670020123010190005"
 //        return  "033H19050020123010190001"
 
-        return  "077A10390020123010190023"
+//        return  "077A10390020123010190023"
     } else {
         //通过反射获取sn号
         try {

+ 69 - 36
libBase/src/main/java/com/develop/base/manager/WifiHelp.kt

@@ -9,7 +9,6 @@ import android.net.*
 import android.net.NetworkInfo.DetailedState
 import android.net.wifi.*
 import android.os.Parcelable
-import android.os.SystemClock
 import android.util.Log
 import com.develop.base.ext.appGlobalScope
 import com.develop.base.ext.getSN
@@ -24,13 +23,20 @@ class WifiHelp {
     private var timeDownUtil: TimeDownUtil? = null
     private val mapWifi = mutableMapOf<String, Int>() //存wifi重连次数
     private var currWifiSSID = ""
-    private var wifiData :WifiData ?=null
-    private var isWifiNum = if (getSN().startsWith("011"))  5 else 6
+    private var wifiData: WifiData? = null
+    private var isWifiNum = if (getSN().startsWith("011")) 5 else 6
 
     private var mDISCONNECTEDTime: Long = 0
 
     private var isWifiLoading = false;
 
+    //第一次按返回键系统的时间戳,默认为0。
+    private var firstTime: Long = 0
+
+    //第一次按返回键系统的时间戳,默认为0。
+    private var initWorkTime: Long = 0
+
+
     private fun init(build: Build) {
         mWifiManager =
             build.mContext?.applicationContext?.getSystemService(Context.WIFI_SERVICE) as WifiManager
@@ -246,7 +252,7 @@ class WifiHelp {
         val wifiConfigurationList = mWifiManager.configuredNetworks
         for (item in wifiConfigurationList) {
             if (item.SSID == addQuotationMarks(wifiData.ssid)) {
-                Log.e("TAG removeSaveWifi:","ssid :"+item.SSID + "    item :"+wifiData.ssid)
+                Log.e("TAG removeSaveWifi:", "ssid :" + item.SSID + "    item :" + wifiData.ssid)
                 mWifiManager.disconnect()
                 mWifiManager.removeNetwork(item.networkId)
                 mWifiManager.saveConfiguration()
@@ -254,8 +260,8 @@ class WifiHelp {
             }
         }
         mapWifi.forEach { (s, i) ->
-            Log.e("TAG MAP","name :"+s)
-            mapWifi[s]  = 0
+            Log.e("TAG MAP", "name :" + s)
+            mapWifi[s] = 0
         }
         currWifiSSID = ""
         this.wifiData = null
@@ -275,8 +281,8 @@ class WifiHelp {
             }
         }
         mapWifi.forEach { (s, i) ->
-            Log.e("TAG MAP","name :"+s)
-            mapWifi[s]  = 0
+            Log.e("TAG MAP", "name :" + s)
+            mapWifi[s] = 0
         }
         this.wifiData = null
         currWifiSSID = ""
@@ -403,11 +409,19 @@ class WifiHelp {
      * 刷新wifi的全部数据(搜索的WiFi与当前连接WiFi数据)
      */
     public fun refreshWifiData() {
+        var secondTime = System.currentTimeMillis()
+        //2秒内同时刷新return
+        if (secondTime - firstTime < 100) {
+            return
+        }
+        firstTime  = secondTime
+
         appGlobalScope.launch(Dispatchers.IO) {
             val list = getScanDevice()
             val connectionWifi = getConnectionWifi()
             withContext(Dispatchers.Main) {
                 timeDownUtil?.cancel()
+
                 mBuild?.mScanCallback?.invoke(list)
                 mBuild?.mAlreadyConnectionCallback?.invoke(connectionWifi)
 
@@ -606,7 +620,7 @@ class WifiHelp {
                 //在每次连接成功or连接失败后更新一次数据
 
                 //loading 的时候不刷新wifi列表
-                if (!isWifiLoading){
+                if (!isWifiLoading) {
                     refreshWifiData()
                 }
                 if (networkInfo.detailedState == NetworkInfo.DetailedState.CONNECTED) {
@@ -615,7 +629,7 @@ class WifiHelp {
                 }
 
                 //正在进行验证
-                if (networkInfo.detailedState == NetworkInfo.DetailedState.AUTHENTICATING){
+                if (networkInfo.detailedState == NetworkInfo.DetailedState.AUTHENTICATING) {
                 }
                 if (networkInfo.detailedState == NetworkInfo.DetailedState.DISCONNECTED) {
 
@@ -623,22 +637,28 @@ class WifiHelp {
 //                    if (SystemClock.elapsedRealtime() - mDISCONNECTEDTime < 1000) {
 //                        return
 //                    }
-                    Log.e("TAG WIFI","DISCONNECTED---DISCONNECTED---DISCONNECTED")
+                    Log.e("TAG WIFI", "DISCONNECTED---DISCONNECTED---DISCONNECTED")
 //                    mBuild?.mErrorAuthenticating?.invoke("failed to connect")
-                    if (wifiData!=null&&wifiData?.ssid==currWifiSSID){
-                        Log.e("TAG WIFI","进来了 ---- currWifiSSID :"+currWifiSSID)
-                        if (currWifiSSID==""){
+                    if (wifiData != null && wifiData?.ssid == currWifiSSID) {
+                        Log.e("TAG WIFI", "进来了 ---- currWifiSSID :" + currWifiSSID)
+                        if (currWifiSSID == "") {
                             return
                         }
                         if (mapWifi[currWifiSSID] != null) {
-                            Log.e("TAG WIFI","currWifiSSID :"+currWifiSSID+ "  次数:"+mapWifi[currWifiSSID])
-                            mapWifi[currWifiSSID] = mapWifi[currWifiSSID]!! +1
-                        }else{
+                            Log.e(
+                                "TAG WIFI",
+                                "currWifiSSID :" + currWifiSSID + "  次数:" + mapWifi[currWifiSSID]
+                            )
+                            mapWifi[currWifiSSID] = mapWifi[currWifiSSID]!! + 1
+                        } else {
                             mapWifi[currWifiSSID] = 0
                         }
                         //判断重连次数删除wifi
-                        if (mapWifi[currWifiSSID]!!>isWifiNum){
-                            Log.e("TAG WIFI","currWifiSSID :"+currWifiSSID+ "  removeSaveSSIDWifi")
+                        if (mapWifi[currWifiSSID]!! > isWifiNum) {
+                            Log.e(
+                                "TAG WIFI",
+                                "currWifiSSID :" + currWifiSSID + "  removeSaveSSIDWifi"
+                            )
                             mapWifi[currWifiSSID] = 0
                             removeSaveSSIDWifi(currWifiSSID)
                             return
@@ -651,7 +671,7 @@ class WifiHelp {
                     currWifiData?.apply {
                         if (this.isSavePwd || this.password.isNotEmpty()) {
                         } else {
-                            Log.e("TAG WIFI","进来了 ---- removeSaveWifi :"+this.ssid)
+                            Log.e("TAG WIFI", "进来了 ---- removeSaveWifi :" + this.ssid)
                             removeSaveWifi(this)
                         }
 
@@ -701,14 +721,23 @@ class WifiHelp {
 
     @SuppressLint("MissingPermission")
     fun initWork() {
-        val configurationList = mWifiManager.configuredNetworks //已经保存密码的WiFi
-        if (configurationList.isNotEmpty()) {
-            configurationList.forEach {
-                currWifiSSID = removeQuotationMarks(it.SSID)
-                connectSavedWiFi(currWifiSSID)
+        var initTime = System.currentTimeMillis()
+
+        //initWorkTime = 0
+        if (initTime - initWorkTime < 2000) {
+            return
+        }
+        Log.e("TAG WIFI","initWork initWork  initTime: $initTime   initWorkTime:$initWorkTime ")
+        initWorkTime = initTime
+        appGlobalScope.launch(Dispatchers.IO) {
+            val configurationList = mWifiManager.configuredNetworks //已经保存密码的WiFi
+            if (configurationList.isNotEmpty()) {
+                configurationList.forEach {
+                    currWifiSSID = removeQuotationMarks(it.SSID)
+                    connectSavedWiFi(currWifiSSID)
+                }
             }
         }
-
     }
 
     fun getDetailedState(): DetailedState? {
@@ -754,15 +783,20 @@ class WifiHelp {
      * @param[ssid] 字符串或一串16进制的数字
      */
     fun connectSavedWiFi(ssids: String) {
-        val config = getWiFiConfig(ssids)
-        config.let {
+        appGlobalScope.launch(Dispatchers.IO) {
+            val config = getWiFiConfig(ssids)
+            config.let {
+            }
+            config?.networkId?.let {
+                mWifiManager.enableNetwork(it, true)
+            }
+            mWifiManager.saveConfiguration()
 
+//            withContext(Dispatchers.Main){
+//                refreshWifiData()
+//            }
         }
-        config?.networkId?.let {
 
-            mWifiManager.enableNetwork(it, true)
-        }
-        mWifiManager.saveConfiguration()
     }
 
     /**
@@ -789,17 +823,16 @@ class WifiHelp {
     }
 
 
-    fun  setIsWifiLoading(isWifiLoading : Boolean){
+    fun setIsWifiLoading(isWifiLoading: Boolean) {
         this.isWifiLoading = isWifiLoading
     }
-    fun  getIsWifiLoading() :Boolean{
+
+    fun getIsWifiLoading(): Boolean {
         return isWifiLoading
     }
 }
 
 
-
-
 /**
  * wifi数据
  */

BIN
libThirdPart/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar