Browse Source

提交人:jtm
提交内容:电磁阀

江天明 1 year ago
parent
commit
9352c81618

BIN
BusinessCommon/src/main/res/drawable-xxxhdpi/pot_clover_ele_lock.png


BIN
BusinessCommon/src/main/res/drawable-xxxhdpi/pot_clover_ele_unlock.png


+ 70 - 12
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -12,11 +12,13 @@ import android.view.View
 import androidx.core.graphics.drawable.DrawableCompat
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.bumptech.glide.Glide
+import com.develop.base.ext.getSN
 import com.develop.base.ext.isNightTheme
 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.common.bean.TuyaEvent
 import com.develop.common.data_repo.db.ModesType
@@ -37,8 +39,10 @@ import com.develop.common.widget.DirectionView
 import com.develop.common.widget.RingControlView
 import com.develop.common.widget.TimePickerView
 import com.develop.step.CookSettingType
+import com.develop.step.R
 import com.develop.step.databinding.ActivityModeDetailBinding
 import com.develop.step.viewmodel.ModesViewMode
+import com.drake.net.time.Interval
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.CommonEventTypes
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
@@ -51,6 +55,7 @@ import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import java.util.Objects
+import java.util.concurrent.TimeUnit
 
 /**
  * 模式详情页
@@ -93,6 +98,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
     private var modeName = ""
     private var opMode = "HAND"
     lateinit var ctx: Context
+    private var potCloverInterval: Interval? = null
 
     private val backRequestDialog by lazy {
         CancelConfirmDialog()
@@ -116,7 +122,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             binding.clCookDirection.visibility = View.GONE;
             binding.clCookSpeed.visibility = View.GONE;
             binding.clCookWater.visibility = View.VISIBLE
-            binding.ivTurbo.visibility = View.GONE
+            binding.ivTurbo.visibility = View.INVISIBLE
 
 
         }
@@ -146,6 +152,11 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             }
         }
 
+        if (!getSN().startsWith("000")) {
+            binding.tvCount.setGone()
+            binding.ivPotCover.setGone()
+        }
+
         turnDevModeUI();
         viewModel.modeType = intent.extras?.getString(MODE_TYPE, ModesType.CHOP.name) ?: ""
         modeName = intent.extras?.getString("mode_name", "") ?: ""
@@ -553,6 +564,10 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         }, 500)
     }
 
+    private var potCloverEleStatus = 0
+
+    private var currentBgId = com.develop.common.R.drawable.pot_clover_ele_unlock //0是开锁图,1上锁图
+
     @Subscribe
     fun onDevStateEvent(event: DevStatusEvent) {
         if (!initModeData) {
@@ -561,7 +576,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         Log.d(
             "dddddddd", "targetTime==${event.devInfo.targetTime}" +
                     "==remainTime==${event.devInfo.remainTime}==targetTimeBuffer==${event.devInfo.targetTimeBuffer}" +
-                    "==minTime==${event.devInfo.mode.minTime}==maxTime==${event.devInfo.mode.maxTime}"
+                    "==minTime==${event.devInfo.mode.minTime}==maxTime==${event.devInfo.mode.maxTime}===potCloverEleStatus==${currDevInfo.potCloverEleStatus}"
         )
         ThreadUtils.runOnMainThread {
             currDevInfo = event.devInfo
@@ -569,6 +584,44 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             mRunningInstId = currDevInfo.runningInstId
             mSettingInstId = currDevInfo.settingInstId
             updateStatusBtn(currDevInfo.status.toByte())
+            if (getSN().startsWith("000")) {
+                if (!CofarSDK.devInfo().isWeightStatus && currDevInfo.mode.mode != "TURBO") {
+                    //电磁阀在非称重/切碎下显示开锁和上锁
+                    if (currDevInfo.potCloverEleStatus.toInt() == 0 && potCloverEleStatus != 0) {
+                        potCloverEleStatus = 0
+                        potCloverInterval?.cancel()
+                        if (currentBgId == com.develop.common.R.drawable.pot_clover_ele_unlock) {
+                            binding.tvCount.setGone()
+                        } else {
+                            binding.tvCount.setVisible()
+                            potCloverInterval = Interval(0, 1, TimeUnit.SECONDS, 5).life(this)
+                                .subscribe {
+                                    binding.tvCount.updateText(it.toString())
+                                }.finish {
+                                    binding.tvCount.setGone()
+                                    currentBgId =
+                                        com.develop.common.R.drawable.pot_clover_ele_unlock
+                                    binding.ivPotCover.setBackgroundResource(com.develop.common.R.drawable.pot_clover_ele_unlock)
+                                }
+                                .start()
+                        }
+                    } else if (currDevInfo.potCloverEleStatus.toInt() == 1 && potCloverEleStatus != 1) {
+                        potCloverEleStatus = 1
+                        potCloverInterval?.cancel()
+                        if (currentBgId == com.develop.common.R.drawable.pot_clover_ele_lock) {
+                            binding.tvCount.setGone()
+                        } else {
+                            binding.tvCount.setGone()
+                            currentBgId = com.develop.common.R.drawable.pot_clover_ele_lock
+                            binding.ivPotCover.setBackgroundResource(com.develop.common.R.drawable.pot_clover_ele_lock)
+                        }
+
+                    } else if (currDevInfo.potCloverEleStatus.toInt() == 2 && potCloverEleStatus != 2) {
+                        potCloverEleStatus = 2
+                        binding.tvCount.setGone()
+                    }
+                }
+            }
             currDevInfo.mode.apply {
                 updateTempUI(
                     minTemp.toFloat(),
@@ -1029,9 +1082,10 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         binding.clSetTime.stopAlphaAnim()
         binding.functionLayout.visibility = View.VISIBLE
         binding.llWeightView.visibility = View.GONE
+        binding.ivPotCover.setVisible()
         if (viewModel.modeType == ModesType.WIGHT.name || viewModel.modeType == ModesType.TURBO.name) {
-            binding.ivWeight.visibility = View.GONE
-            binding.ivTurbo.visibility = View.GONE
+            binding.ivWeight.visibility = View.INVISIBLE
+            binding.ivTurbo.visibility = View.INVISIBLE
             if (viewModel.modeType == ModesType.TURBO.name) {
                 Log.d("dddddd", "llTurboView===VISIBLE")
                 binding.llTurboView.visibility = View.VISIBLE
@@ -1050,8 +1104,8 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         whereIndex = -1
         binding.clSetTime.stopAlphaAnim()
         isWidget = false
-        binding.ivWeight.visibility = View.GONE
-        binding.ivTurbo.visibility = View.GONE
+        binding.ivWeight.visibility = View.INVISIBLE
+        binding.ivTurbo.visibility = View.INVISIBLE
         binding.functionLayout.visibility = View.GONE
         binding.llWeightView.visibility = View.VISIBLE
         Log.d("dddddd", "llTurboView===GONE")
@@ -1065,8 +1119,8 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         whereIndex = -1
         binding.clSetTime.stopAlphaAnim()
         isWidget = false
-        binding.ivWeight.visibility = View.GONE
-        binding.ivTurbo.visibility = View.GONE
+        binding.ivWeight.visibility = View.INVISIBLE
+        binding.ivTurbo.visibility = View.INVISIBLE
         binding.functionLayout.visibility = View.GONE
         Log.d("dddddd", "llTurboView===VISIBLE")
         binding.llTurboView.visibility = View.VISIBLE
@@ -1728,9 +1782,11 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         modeType = viewModel.modeType
         initModeData(viewModel.modeType)
         viewModel.changeStep(CookSettingType.WEIGHT)
-        binding.ivTurbo.visibility = View.GONE
+        binding.ivTurbo.visibility = View.INVISIBLE
+        binding.ivPotCover.setGone()
+        binding.tvCount.setGone()
         isWidget = false
-        binding.ivWeight.visibility = View.GONE
+        binding.ivWeight.visibility = View.INVISIBLE
         binding.tvModeName.text = viewModel.getModeTitle(resources)
 
     }
@@ -1739,6 +1795,8 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
      * 点击turbo操作
      */
     private fun turboClick() {
+        binding.ivPotCover.setGone()
+        binding.tvCount.setGone()
         CofarSDK.stop(false)
         whereIndex = -1
         binding.clSetTime.stopAlphaAnim()
@@ -1748,9 +1806,9 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         initModeData(viewModel.modeType)
         viewModel.changeStep(CookSettingType.TURBO)
         binding.tvModeName.text = viewModel.getModeTitle(resources)
-        binding.ivTurbo.visibility = View.GONE
+        binding.ivTurbo.visibility = View.INVISIBLE
         isWidget = false
-        binding.ivWeight.visibility = View.GONE
+        binding.ivWeight.visibility = View.INVISIBLE
         Log.d("dddddd", "llTurboView===VISIBLE")
         binding.llTurboView.visibility = View.VISIBLE
     }

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

@@ -14,6 +14,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
 import com.blankj.utilcode.util.LogUtils
 import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
 import com.develop.base.ext.background_drawable
+import com.develop.base.ext.getSN
 import com.develop.base.ext.isNightTheme
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.setGone
@@ -46,6 +47,7 @@ import com.develop.common.utils.CofarUtils
 import com.develop.common.utils.TimeUtil
 import com.develop.step.ui.cook_step.model.CookStepStatus
 import com.develop.step.ui.cook_step.model.CookStepUiData
+import com.drake.net.time.Interval
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.*
 import com.kuyuntech.cofarcooking.device.sdk.eventbus.core.DevInfo
 import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevCommonEvent
@@ -55,6 +57,7 @@ import kotlinx.serialization.json.Json
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import java.io.File
+import java.util.concurrent.TimeUnit
 
 @Route(path = Screens.Cook.COOK_STEP2)
 class CookStepActivity : CookStepBaseActivity() {
@@ -85,8 +88,10 @@ class CookStepActivity : CookStepBaseActivity() {
     private var currentMotorGer = 0
     private var currentWaterGear = 0
     private var currTime = 0
+    private var potCloverInterval: Interval? = null
+    private var potCloverEleStatus = 0
 
-
+    private var currentBgId = R.drawable.pot_clover_ele_unlock //0是开锁图,1上锁图
     private fun turnDevModeUI() {
 
         if (CofarSDK.devInfo().devMode == DevModes.AIR_FRYER) {
@@ -127,6 +132,10 @@ class CookStepActivity : CookStepBaseActivity() {
             binding.viewChangeCrush.src = R.drawable.ic_cooking_weight
             binding.viewNote.setVisible()
         }
+        if (!getSN().startsWith("000")) {
+            binding.tvCount.setGone()
+            binding.ivPotCover.setGone()
+        }
 
         binding.controller.clSetTime.onTimePickerCallback =
             object : TimePickerView.OnTimePickerCallback {
@@ -731,6 +740,51 @@ class CookStepActivity : CookStepBaseActivity() {
 
             LogUtils.d("========${devInfo.motorGearBuffer}")
 
+            if (getSN().startsWith("000")) {
+                if (!CofarSDK.devInfo().isWeightStatus && devInfo.mode.mode != "TURBO") {
+                    //电磁阀在非称重/切碎下显示开锁和上锁
+                    if (devInfo.potCloverEleStatus.toInt() == 0 && potCloverEleStatus != 0) {
+                        potCloverEleStatus = 0
+                        potCloverInterval?.cancel()
+                        if (currentBgId == R.drawable.pot_clover_ele_unlock) {
+                            binding.tvCount.setGone()
+                        } else {
+                            binding.tvCount.setVisible()
+                            potCloverInterval = Interval(0, 1, TimeUnit.SECONDS, 5).life(this)
+                                .subscribe {
+                                    binding.tvCount.updateText(it.toString())
+                                }.finish {
+                                    binding.tvCount.setGone()
+                                    currentBgId = R.drawable.pot_clover_ele_unlock
+                                    binding.ivPotCover.setBackgroundResource(R.drawable.pot_clover_ele_unlock)
+                                }
+                                .start()
+                        }
+                    } else if (devInfo.potCloverEleStatus.toInt() == 1 && potCloverEleStatus != 1) {
+                        potCloverEleStatus = 1
+                        potCloverInterval?.cancel()
+                        if (currentBgId == com.develop.common.R.drawable.pot_clover_ele_lock) {
+                            binding.tvCount.setGone()
+                        } else {
+                            binding.tvCount.setVisible()
+                            potCloverInterval = Interval(0, 1, TimeUnit.SECONDS, 5).life(this)
+                                .subscribe {
+                                    binding.tvCount.updateText(it.toString())
+                                }.finish {
+                                    binding.tvCount.setGone()
+                                    currentBgId = com.develop.common.R.drawable.pot_clover_ele_lock
+                                    binding.ivPotCover.setBackgroundResource(com.develop.common.R.drawable.pot_clover_ele_lock)
+                                }
+                                .start()
+                        }
+
+                    } else if (devInfo.potCloverEleStatus.toInt() == 2 && potCloverEleStatus != 2) {
+                        potCloverEleStatus = 2
+                        binding.tvCount.setGone()
+                    }
+                }
+            }
+
             if (!it.hasStarted && devInfo.status == DevStatus.RUNNING.toInt()) {
                 // 标记这个步骤曾经开始过了
                 it.hasStarted = true

+ 24 - 0
BusinessStep/src/main/res/layout/activity_cook_step_base.xml

@@ -264,6 +264,30 @@
                 app:layout_constraintEnd_toStartOf="@+id/view_change_weight"
                 app:layout_constraintTop_toTopOf="parent" />
 
+            <ImageView
+                app:layout_constraintEnd_toStartOf="@id/view_remark"
+                app:layout_constraintTop_toTopOf="parent"
+                android:visibility="visible"
+                android:id="@+id/iv_pot_cover"
+                android:layout_width="@dimen/convert_70px"
+                android:layout_height="@dimen/convert_70px"
+                android:layout_marginTop="@dimen/convert_138px"
+                android:layout_marginEnd="@dimen/convert_40px"
+                android:layout_alignParentEnd="true"
+                android:background="@drawable/pot_clover_ele_unlock" />
+
+            <androidx.appcompat.widget.AppCompatTextView
+                app:layout_constraintTop_toTopOf="parent"
+                android:id="@+id/tv_count"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/convert_134px"
+                app:layout_constraintEnd_toStartOf="@id/iv_pot_cover"
+                android:layout_toStartOf="@id/iv_pot_cover"
+                android:textColor="@color/color_92cf40"
+                android:textSize="@dimen/convert_50px"
+                android:visibility="invisible" />
+
             <LinearLayout
                 android:id="@+id/ll_step_finish"
                 android:layout_width="match_parent"

+ 21 - 2
BusinessStep/src/main/res/layout/activity_mode_detail.xml

@@ -59,11 +59,30 @@
             android:layout_width="@dimen/convert_60px"
             android:layout_height="@dimen/convert_60px"
             android:layout_marginTop="@dimen/convert_28px"
-            android:layout_marginEnd="@dimen/convert_40px"
-            android:layout_toStartOf="@id/iv_weight"
+            android:layout_marginEnd="@dimen/convert_150px"
+            android:layout_alignParentEnd="true"
             android:background="@drawable/ic_turbo" />
 
 
+        <ImageView
+            android:visibility="visible"
+            android:id="@+id/iv_pot_cover"
+            android:layout_width="@dimen/convert_70px"
+            android:layout_height="@dimen/convert_70px"
+            android:layout_marginTop="@dimen/convert_24px"
+            android:layout_marginEnd="@dimen/convert_250px"
+            android:layout_alignParentEnd="true"
+            android:background="@drawable/pot_clover_ele_unlock" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tv_count"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/convert_24px"
+            android:layout_toStartOf="@id/iv_pot_cover"
+            android:textColor="@color/color_92cf40"
+            android:textSize="@dimen/convert_50px"
+            android:visibility="invisible" />
 
     </RelativeLayout>
 

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

@@ -189,6 +189,7 @@ fun getBrandNum(): String {
 fun getSN(): String {
     var serial: String
 
+    return "000A20010020123010190001"
     //通过反射获取sn号
     try {
         val c = Class.forName("android.os.SystemProperties")

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