|
@@ -6,6 +6,9 @@ import android.util.AttributeSet
|
|
|
import android.util.Log
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
+import android.view.animation.AlphaAnimation
|
|
|
+import android.view.animation.Animation
|
|
|
+import android.view.animation.LinearInterpolator
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
import com.blankj.utilcode.util.ActivityUtils.startActivity
|
|
|
import com.blankj.utilcode.util.AppUtils
|
|
@@ -20,21 +23,24 @@ import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevStatusEvent
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
|
-class DevModeView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs){
|
|
|
+class DevModeView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs) {
|
|
|
|
|
|
- private var mode = CofarSDK.devInfo().devMode;
|
|
|
+ private var mode = CofarSDK.devInfo().devMode;
|
|
|
|
|
|
- private val binding: DevModeViewBinding
|
|
|
+ private val binding: DevModeViewBinding
|
|
|
|
|
|
- init {
|
|
|
- binding = DevModeViewBinding.inflate(LayoutInflater.from(context), this, true)
|
|
|
- setupClickListener()
|
|
|
- CofarSDK.register(this)
|
|
|
- updateUI()
|
|
|
- if(!AppUtils.getAppVersionName().split(".")[0].startsWith("5")){
|
|
|
- this.visibility = GONE
|
|
|
- }
|
|
|
- }
|
|
|
+ private var alphaAnimation: AlphaAnimation? = null
|
|
|
+
|
|
|
+ init {
|
|
|
+ binding = DevModeViewBinding.inflate(LayoutInflater.from(context), this, true)
|
|
|
+ setupClickListener()
|
|
|
+ CofarSDK.register(this)
|
|
|
+ animation()
|
|
|
+ updateUI()
|
|
|
+ if (!AppUtils.getAppVersionName().split(".")[0].startsWith("5")) {
|
|
|
+ this.visibility = GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
override fun onDetachedFromWindow() {
|
|
|
super.onDetachedFromWindow()
|
|
@@ -42,65 +48,68 @@ class DevModeView(context: Context, attrs: AttributeSet) : ConstraintLayout(cont
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Subscribe
|
|
|
fun onDevStateEvent(event: DevStatusEvent) {
|
|
|
- ThreadUtils.runOnMainThread{
|
|
|
+ ThreadUtils.runOnMainThread {
|
|
|
updateUI()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Subscribe
|
|
|
- fun onDevModeChange(event: DevCommonEvent){
|
|
|
- if(CommonEventTypes.DEV_MODE_CHANGE == event.type){
|
|
|
- mode = CofarSDK.devInfo().devMode;
|
|
|
- updateUI();
|
|
|
- val intent = Intent(this.context, Class.forName("com.develop.main.ui.ModeEntranceActivity"))
|
|
|
- intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
- this.context.startActivity(intent)
|
|
|
- }
|
|
|
+ fun onDevModeChange(event: DevCommonEvent) {
|
|
|
+ if (CommonEventTypes.DEV_MODE_CHANGE == event.type) {
|
|
|
+ mode = CofarSDK.devInfo().devMode;
|
|
|
+ updateUI();
|
|
|
+ val intent =
|
|
|
+ Intent(this.context, Class.forName("com.develop.main.ui.ModeEntranceActivity"))
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
+ this.context.startActivity(intent)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- private fun updateUI(){
|
|
|
+ private fun updateUI() {
|
|
|
//判断模式
|
|
|
- if(mode == DevModes.AIR_FRYER){
|
|
|
+ if (mode == DevModes.AIR_FRYER) {
|
|
|
binding.dfbAtive.visibility = View.GONE;
|
|
|
binding.dfbUnactive.visibility = View.VISIBLE;
|
|
|
binding.kqzgActive.visibility = View.VISIBLE;
|
|
|
binding.kqzgUnactive.visibility = View.GONE;
|
|
|
|
|
|
|
|
|
- if(CofarSDK.devInfo().potCloverStatus.toInt() == 0){
|
|
|
+ if (CofarSDK.devInfo().potCloverStatus.toInt() == 0) {
|
|
|
binding.kqzgCoverOpen.visibility = View.GONE
|
|
|
binding.kqzgCoverClose.visibility = View.VISIBLE
|
|
|
- }else{
|
|
|
+ binding.kqzgCoverOpen.clearAnimation()
|
|
|
+
|
|
|
+ } else {
|
|
|
binding.kqzgCoverOpen.visibility = View.VISIBLE
|
|
|
binding.kqzgCoverClose.visibility = View.GONE
|
|
|
+ binding.kqzgCoverOpen.startAnimation(alphaAnimation)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
|
|
|
- if(PotStatus.UNEXIST == CofarSDK.devInfo().potStatus){
|
|
|
+ if (PotStatus.UNEXIST == CofarSDK.devInfo().potStatus) {
|
|
|
binding.dfbAtive.visibility = View.GONE;
|
|
|
binding.dfbUnactive.visibility = View.VISIBLE;
|
|
|
binding.kqzgActive.visibility = View.GONE;
|
|
|
binding.kqzgUnactive.visibility = View.VISIBLE;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
binding.dfbAtive.visibility = View.VISIBLE;
|
|
|
binding.dfbUnactive.visibility = View.GONE;
|
|
|
binding.kqzgActive.visibility = View.GONE;
|
|
|
binding.kqzgUnactive.visibility = View.VISIBLE;
|
|
|
}
|
|
|
|
|
|
- if(CofarSDK.devInfo().potCloverStatus.toInt() == 0){
|
|
|
+ if (CofarSDK.devInfo().potCloverStatus.toInt() == 0) {
|
|
|
binding.tgCoverOpen.visibility = View.GONE
|
|
|
binding.tgCoverClose.visibility = View.VISIBLE
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
binding.tgCoverOpen.visibility = View.VISIBLE
|
|
|
binding.tgCoverClose.visibility = View.GONE
|
|
|
}
|
|
@@ -108,18 +117,24 @@ class DevModeView(context: Context, attrs: AttributeSet) : ConstraintLayout(cont
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun setupClickListener(){
|
|
|
-
|
|
|
+ private fun setupClickListener() {
|
|
|
|
|
|
- setOnClickListener {
|
|
|
- CofarSDK.changeDevMode(if (mode ==DevModes.SOUP) DevModes.AIR_FRYER else DevModes.SOUP)
|
|
|
|
|
|
- }
|
|
|
+ setOnClickListener {
|
|
|
+ CofarSDK.changeDevMode(if (mode == DevModes.SOUP) DevModes.AIR_FRYER else DevModes.SOUP)
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ private fun animation() {
|
|
|
+ alphaAnimation = AlphaAnimation(1f, 0f)
|
|
|
+ alphaAnimation?.duration = 300;
|
|
|
+ alphaAnimation?.interpolator = LinearInterpolator()
|
|
|
+ alphaAnimation?.repeatCount = Animation.INFINITE;
|
|
|
+ alphaAnimation?.repeatMode = Animation.REVERSE;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|