|
@@ -6,6 +6,7 @@ import android.os.Bundle
|
|
import android.util.Log
|
|
import android.util.Log
|
|
import android.view.*
|
|
import android.view.*
|
|
import android.view.animation.LinearInterpolator
|
|
import android.view.animation.LinearInterpolator
|
|
|
|
+import android.widget.LinearLayout
|
|
import androidx.activity.viewModels
|
|
import androidx.activity.viewModels
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.develop.food.base.common.MODE_TYPE
|
|
import com.develop.food.base.common.MODE_TYPE
|
|
@@ -15,11 +16,15 @@ import com.develop.food.base.common.TURN_UP_KEY_CODE
|
|
import com.develop.food.base.data.ModesType
|
|
import com.develop.food.base.data.ModesType
|
|
import com.develop.food.base.data.model.CookSettingType
|
|
import com.develop.food.base.data.model.CookSettingType
|
|
import com.develop.food.base.event.CookStepEvent
|
|
import com.develop.food.base.event.CookStepEvent
|
|
|
|
+import com.develop.food.base.ext.background_drawable
|
|
import com.develop.food.base.manager.FloatWindowManager
|
|
import com.develop.food.base.manager.FloatWindowManager
|
|
import com.develop.food.base.router.Screens
|
|
import com.develop.food.base.router.Screens
|
|
import com.develop.food.base.ui.BaseActivity
|
|
import com.develop.food.base.ui.BaseActivity
|
|
import com.develop.food.base.utils.CofarUtils
|
|
import com.develop.food.base.utils.CofarUtils
|
|
|
|
+import com.develop.food.base.utils.GlobalApp
|
|
import com.develop.food.base.utils.ThreadUtils
|
|
import com.develop.food.base.utils.ThreadUtils
|
|
|
|
+import com.develop.food.base.utils.isNightTheme
|
|
|
|
+import com.develop.food.base.utils.resId2Dimension
|
|
import com.develop.food.base.widgets.CancelConfirmDialog
|
|
import com.develop.food.base.widgets.CancelConfirmDialog
|
|
import com.develop.food.base.widgets.DirectionView
|
|
import com.develop.food.base.widgets.DirectionView
|
|
import com.develop.food.base.widgets.TimePickerView
|
|
import com.develop.food.base.widgets.TimePickerView
|
|
@@ -41,7 +46,7 @@ import java.util.*
|
|
|
|
|
|
@Route(path = Screens.Cook.COOK_MODES)
|
|
@Route(path = Screens.Cook.COOK_MODES)
|
|
class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
- private var modeType = ModesType.CHOP.name
|
|
|
|
|
|
+ private var modeType = ModesType.FERMENT.name
|
|
override fun createViewBinding(inflater: LayoutInflater): ActivityModeDetailBinding {
|
|
override fun createViewBinding(inflater: LayoutInflater): ActivityModeDetailBinding {
|
|
return ActivityModeDetailBinding.inflate(layoutInflater)
|
|
return ActivityModeDetailBinding.inflate(layoutInflater)
|
|
}
|
|
}
|
|
@@ -49,7 +54,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
private val viewModel by viewModels<CookModesViewModel>()
|
|
private val viewModel by viewModels<CookModesViewModel>()
|
|
private var userChanging = false //当前是否用户在操作
|
|
private var userChanging = false //当前是否用户在操作
|
|
private var currDevInfo = DevInfo()
|
|
private var currDevInfo = DevInfo()
|
|
- private var lastModeType = ModesType.CHOP.name
|
|
|
|
|
|
+ private var lastModeType = ModesType.FERMENT.name
|
|
private var modeChange = false
|
|
private var modeChange = false
|
|
private var turboTimer: Timer? = null
|
|
private var turboTimer: Timer? = null
|
|
private var mSettingInstId = ""
|
|
private var mSettingInstId = ""
|
|
@@ -80,19 +85,29 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
}
|
|
}
|
|
private var rotateAnimator: ObjectAnimator? = null
|
|
private var rotateAnimator: ObjectAnimator? = null
|
|
private var rotateAnimDir = -1
|
|
private var rotateAnimDir = -1
|
|
|
|
+ private var whereIndex = -1
|
|
|
|
+ private var isMotorDirectionGearChange = false
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
configLock = true
|
|
configLock = true
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
hasShowScreenSaver = true
|
|
hasShowScreenSaver = true
|
|
- modeType = intent.extras?.getString(MODE_TYPE, ModesType.CHOP.name) ?: ""
|
|
|
|
|
|
+ modeType = intent.extras?.getString(MODE_TYPE, ModesType.FERMENT.name) ?: ""
|
|
lastModeType = modeType
|
|
lastModeType = modeType
|
|
|
|
+ if (isNightTheme()) {
|
|
|
|
+ val param = binding.ivBack.layoutParams as LinearLayout.LayoutParams
|
|
|
|
+ param.width = dp83
|
|
|
|
+ param.height = dp83
|
|
|
|
+ param.gravity = Gravity.CENTER_VERTICAL
|
|
|
|
+ param.marginStart = dp25
|
|
|
|
+ binding.ivBack.layoutParams = param
|
|
|
|
+ }
|
|
//初始化模式数据
|
|
//初始化模式数据
|
|
initModeData(modeType)
|
|
initModeData(modeType)
|
|
initData()
|
|
initData()
|
|
initListener()
|
|
initListener()
|
|
CofarSDK.resetLastPotStatus()
|
|
CofarSDK.resetLastPotStatus()
|
|
- ThreadUtils.runOnMainThread({configLock = false},500)
|
|
|
|
|
|
+ ThreadUtils.runOnMainThread({ configLock = false }, 500)
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
@@ -159,7 +174,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
}
|
|
}
|
|
|
|
|
|
backRequestDialog.apply {
|
|
backRequestDialog.apply {
|
|
- title = "Keep cooking in the background?"
|
|
|
|
|
|
+ title = GlobalApp().getString(R.string.keep_cooking_in_the_background)
|
|
onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
|
|
onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
|
|
override fun onConfirm() {
|
|
override fun onConfirm() {
|
|
val cookStepEvent = CookStepEvent(
|
|
val cookStepEvent = CookStepEvent(
|
|
@@ -195,9 +210,11 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
CofarSDK.stop(false)
|
|
CofarSDK.stop(false)
|
|
CofarSDK.startWeight()
|
|
CofarSDK.startWeight()
|
|
}
|
|
}
|
|
|
|
+
|
|
ModesType.TURBO.name -> {
|
|
ModesType.TURBO.name -> {
|
|
CofarSDK.stop(false)
|
|
CofarSDK.stop(false)
|
|
}
|
|
}
|
|
|
|
+
|
|
else -> {
|
|
else -> {
|
|
userChanging = false
|
|
userChanging = false
|
|
CofarSDK.startRunning(modeType)
|
|
CofarSDK.startRunning(modeType)
|
|
@@ -227,12 +244,13 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
setByUser: Boolean
|
|
setByUser: Boolean
|
|
) {
|
|
) {
|
|
if (setByUser) {
|
|
if (setByUser) {
|
|
- // currTime = time.toLong()
|
|
|
|
|
|
+ // currTime = time.toLong()
|
|
}
|
|
}
|
|
rollTimeEvent(hours, minute, second, time, setByUser)
|
|
rollTimeEvent(hours, minute, second, time, setByUser)
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onTimePickerTouchFirst() {
|
|
|
|
|
|
+ override fun onTimePickerTouchFirst(where: Int) {
|
|
|
|
+ whereIndex = where
|
|
userChanging = true
|
|
userChanging = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -252,6 +270,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
MotionEvent.ACTION_DOWN -> {
|
|
MotionEvent.ACTION_DOWN -> {
|
|
turboDownEvent()
|
|
turboDownEvent()
|
|
}
|
|
}
|
|
|
|
+
|
|
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
|
|
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
|
|
turboUpEvent()
|
|
turboUpEvent()
|
|
}
|
|
}
|
|
@@ -276,7 +295,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
private fun initData() {
|
|
private fun initData() {
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
- binding.ivBanner.setBackgroundResource(viewModel.getBanner(modeType))
|
|
|
|
|
|
+ binding.ivBanner.background_drawable = viewModel.getBanner(modeType)
|
|
viewModel.currentStep.observe(this) {
|
|
viewModel.currentStep.observe(this) {
|
|
if (it == null) {
|
|
if (it == null) {
|
|
return@observe
|
|
return@observe
|
|
@@ -288,15 +307,19 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
CookSettingType.WEIGHT -> {
|
|
CookSettingType.WEIGHT -> {
|
|
changeWeightStep()
|
|
changeWeightStep()
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.TEMP_SETTING -> {
|
|
CookSettingType.TEMP_SETTING -> {
|
|
changeTempSettingStep()
|
|
changeTempSettingStep()
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.TIME_SETTING -> {
|
|
CookSettingType.TIME_SETTING -> {
|
|
changeTimeSettingStep()
|
|
changeTimeSettingStep()
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.SPEED_SETTING -> {
|
|
CookSettingType.SPEED_SETTING -> {
|
|
changeSpeedSettingStep()
|
|
changeSpeedSettingStep()
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.DIRECTION_SETTING -> {
|
|
CookSettingType.DIRECTION_SETTING -> {
|
|
changeDirectionSettingStep()
|
|
changeDirectionSettingStep()
|
|
}
|
|
}
|
|
@@ -305,6 +328,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun changeWeightStep() {
|
|
private fun changeWeightStep() {
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.functionLayout.visibility = View.GONE
|
|
binding.functionLayout.visibility = View.GONE
|
|
@@ -314,6 +339,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun changeCommonStep() {
|
|
private fun changeCommonStep() {
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
binding.llWeightView.visibility = View.GONE
|
|
binding.llWeightView.visibility = View.GONE
|
|
if (modeType == ModesType.WIGHT.name || modeType == ModesType.TURBO.name) {
|
|
if (modeType == ModesType.WIGHT.name || modeType == ModesType.TURBO.name) {
|
|
@@ -343,11 +370,11 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
//处理蒸汽模式
|
|
//处理蒸汽模式
|
|
- if(modeType == ModesType.STEAM.name){
|
|
|
|
|
|
+ if (modeType == ModesType.STEAM.name) {
|
|
binding.tempRingText.visibility = View.GONE;
|
|
binding.tempRingText.visibility = View.GONE;
|
|
binding.clCookTemp.turnSteamMode();
|
|
binding.clCookTemp.turnSteamMode();
|
|
binding.steamFire.visibility = View.VISIBLE
|
|
binding.steamFire.visibility = View.VISIBLE
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
binding.clCookTemp.turnCommonMode();
|
|
binding.clCookTemp.turnCommonMode();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -369,6 +396,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun changeSpeedSettingStep() {
|
|
private fun changeSpeedSettingStep() {
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
binding.steamFire.visibility = View.GONE
|
|
binding.steamFire.visibility = View.GONE
|
|
binding.llWeightView.visibility = View.GONE
|
|
binding.llWeightView.visibility = View.GONE
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
@@ -384,7 +413,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
private fun changeDirectionSettingStep() {
|
|
private fun changeDirectionSettingStep() {
|
|
binding.steamFire.visibility = View.GONE
|
|
binding.steamFire.visibility = View.GONE
|
|
-
|
|
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
binding.llWeightView.visibility = View.GONE
|
|
binding.llWeightView.visibility = View.GONE
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
binding.functionLayout.visibility = View.VISIBLE
|
|
binding.tempRingView.visibility = View.INVISIBLE
|
|
binding.tempRingView.visibility = View.INVISIBLE
|
|
@@ -407,15 +437,19 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
CookSettingType.TEMP_SETTING -> {
|
|
CookSettingType.TEMP_SETTING -> {
|
|
clCookTemp.upSelectedView(true)
|
|
clCookTemp.upSelectedView(true)
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.TIME_SETTING -> {
|
|
CookSettingType.TIME_SETTING -> {
|
|
clCookTime.upSelectedView(true)
|
|
clCookTime.upSelectedView(true)
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.SPEED_SETTING -> {
|
|
CookSettingType.SPEED_SETTING -> {
|
|
clCookSpeed.upSelectedView(true)
|
|
clCookSpeed.upSelectedView(true)
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.DIRECTION_SETTING -> {
|
|
CookSettingType.DIRECTION_SETTING -> {
|
|
clCookDirection.upSelectedView(true)
|
|
clCookDirection.upSelectedView(true)
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.WEIGHT -> {
|
|
CookSettingType.WEIGHT -> {
|
|
// do nothing
|
|
// do nothing
|
|
}
|
|
}
|
|
@@ -434,21 +468,21 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
@Subscribe
|
|
@Subscribe
|
|
- fun onDevCommonEvent(event:DevCommonEvent){
|
|
|
|
|
|
+ fun onDevCommonEvent(event: DevCommonEvent) {
|
|
|
|
|
|
- if(configLock){
|
|
|
|
|
|
+ if (configLock) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
ThreadUtils.runOnMainThread({
|
|
ThreadUtils.runOnMainThread({
|
|
- if(CommonEventTypes.MOTOR_GEAR_RATHER_THEN_7 == event.type){
|
|
|
|
|
|
+ if (CommonEventTypes.MOTOR_GEAR_RATHER_THEN_7 == event.type) {
|
|
CofarSDK.cfgTime((10 * 60).toInt())
|
|
CofarSDK.cfgTime((10 * 60).toInt())
|
|
currDevInfo.mode.apply {
|
|
currDevInfo.mode.apply {
|
|
updateTimeUI(
|
|
updateTimeUI(
|
|
minTime,
|
|
minTime,
|
|
maxTime,
|
|
maxTime,
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else currDevInfo.targetTime.toInt(),
|
|
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else currDevInfo.targetTime.toInt(),
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
true,
|
|
true,
|
|
true
|
|
true
|
|
)
|
|
)
|
|
@@ -459,21 +493,21 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if(CommonEventTypes.MOTOR_GEAR_RATHER_THEN_7 == event.type){
|
|
|
|
|
|
+ if (CommonEventTypes.MOTOR_GEAR_RATHER_THEN_7 == event.type) {
|
|
CofarSDK.cfgTime((10 * 60).toInt())
|
|
CofarSDK.cfgTime((10 * 60).toInt())
|
|
currDevInfo.mode.apply {
|
|
currDevInfo.mode.apply {
|
|
updateTimeUI(
|
|
updateTimeUI(
|
|
minTime,
|
|
minTime,
|
|
maxTime,
|
|
maxTime,
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else currDevInfo.targetTime.toInt(),
|
|
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else currDevInfo.targetTime.toInt(),
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
true,
|
|
true,
|
|
true
|
|
true
|
|
)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(CommonEventTypes.MOTOR_GEAR_RATHER_THEN_3_WITH_TEMP == event.type || CommonEventTypes.MOTOR_REVERSE_CAN_NOT_RATHER_THEN_3 == event.type){
|
|
|
|
|
|
+ if (CommonEventTypes.MOTOR_GEAR_RATHER_THEN_3_WITH_TEMP == event.type || CommonEventTypes.MOTOR_REVERSE_CAN_NOT_RATHER_THEN_3 == event.type) {
|
|
CofarSDK.cfgMotorGear(3);
|
|
CofarSDK.cfgMotorGear(3);
|
|
currDevInfo.mode.apply {
|
|
currDevInfo.mode.apply {
|
|
updateMotorGearUI(
|
|
updateMotorGearUI(
|
|
@@ -485,15 +519,14 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- },500)
|
|
|
|
-
|
|
|
|
|
|
+ }, 500)
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Subscribe
|
|
@Subscribe
|
|
fun onDevStateEvent(event: DevStatusEvent) {
|
|
fun onDevStateEvent(event: DevStatusEvent) {
|
|
- if(!initModeData || turboLock){
|
|
|
|
|
|
+ if (!initModeData || turboLock) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
ThreadUtils.runOnMainThread {
|
|
ThreadUtils.runOnMainThread {
|
|
@@ -512,21 +545,21 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
updateTempUI(
|
|
updateTempUI(
|
|
minTemp.toFloat(),
|
|
minTemp.toFloat(),
|
|
maxTemp.toFloat(),
|
|
maxTemp.toFloat(),
|
|
- if(currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTemp.toInt() else currDevInfo.temp.toInt(),
|
|
|
|
|
|
+ if (currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTemp.toInt() else currDevInfo.temp.toInt(),
|
|
currDevInfo.targetTemp.toString(),
|
|
currDevInfo.targetTemp.toString(),
|
|
isTempChange
|
|
isTempChange
|
|
)
|
|
)
|
|
updateTimeUI(
|
|
updateTimeUI(
|
|
- if(currDevInfo.status == DevStatus.STOP.toInt() || userChanging) minTime else 0,
|
|
|
|
|
|
+ if (currDevInfo.status == DevStatus.STOP.toInt() || userChanging) minTime else 0,
|
|
maxTime,
|
|
maxTime,
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else (if(currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTime.toInt() else currDevInfo.remainTime.toInt()),
|
|
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toInt() else (if (currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTime.toInt() else currDevInfo.remainTime.toInt()),
|
|
|
|
+ if (currDevInfo.targetTimeBuffer.toInt() != -1) currDevInfo.targetTimeBuffer.toLong() else currDevInfo.targetTime.toLong(),
|
|
isTimeChange
|
|
isTimeChange
|
|
)
|
|
)
|
|
|
|
|
|
var motorGear = currDevInfo.motorGear.toInt()
|
|
var motorGear = currDevInfo.motorGear.toInt()
|
|
- if(currDevInfo.motorGearBuffer.toInt() != -1){
|
|
|
|
- motorGear = currDevInfo.motorGearBuffer.toInt()
|
|
|
|
|
|
+ if (currDevInfo.motorGearBuffer.toInt() != -1) {
|
|
|
|
+ motorGear = currDevInfo.motorGearBuffer.toInt()
|
|
}
|
|
}
|
|
|
|
|
|
updateMotorGearUI(
|
|
updateMotorGearUI(
|
|
@@ -549,7 +582,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
//初始化模式数据
|
|
//初始化模式数据
|
|
@SuppressLint("SetTextI18n")
|
|
@SuppressLint("SetTextI18n")
|
|
- private fun initModeData(type: String,keep:Boolean = false) {
|
|
|
|
|
|
+ private fun initModeData(type: String, keep: Boolean = false) {
|
|
|
|
|
|
userChanging = false
|
|
userChanging = false
|
|
val baseMode = CofarSDK.devMode(type)
|
|
val baseMode = CofarSDK.devMode(type)
|
|
@@ -563,16 +596,16 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
} else {
|
|
} else {
|
|
this.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
this.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
//其他模式
|
|
//其他模式
|
|
- changeCommonStep()
|
|
|
|
|
|
+ changeCommonStep()
|
|
|
|
|
|
- if(CofarSDK.devInfo().status != DevStatus.PAUSE.toInt() && CofarSDK.devInfo().status != DevStatus.RUNNING.toInt()){
|
|
|
|
|
|
+ if (CofarSDK.devInfo().status != DevStatus.PAUSE.toInt() && CofarSDK.devInfo().status != DevStatus.RUNNING.toInt()) {
|
|
|
|
|
|
var targetTemp = baseMode.defaultTemp.toShort()
|
|
var targetTemp = baseMode.defaultTemp.toShort()
|
|
var motorDirection = baseMode.motorDirection.toByte()
|
|
var motorDirection = baseMode.motorDirection.toByte()
|
|
var motorGear = baseMode.defaultMotorGear.toByte()
|
|
var motorGear = baseMode.defaultMotorGear.toByte()
|
|
var targetTime = baseMode.defaultTime.toInt()
|
|
var targetTime = baseMode.defaultTime.toInt()
|
|
|
|
|
|
- var restoreConfig:DevInfo ?= null
|
|
|
|
|
|
+ var restoreConfig: DevInfo? = null
|
|
|
|
|
|
if (modeType == ModesType.TURBO.name) {
|
|
if (modeType == ModesType.TURBO.name) {
|
|
|
|
|
|
@@ -581,27 +614,27 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
changeSpeedSettingStep()
|
|
changeSpeedSettingStep()
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- turboLock=false;
|
|
|
|
|
|
+ turboLock = false;
|
|
viewModel.changeStep(CookSettingType.TEMP_SETTING)
|
|
viewModel.changeStep(CookSettingType.TEMP_SETTING)
|
|
- if(keep){
|
|
|
|
|
|
+ if (keep) {
|
|
configLock = true;
|
|
configLock = true;
|
|
- restoreConfig = CofarSDK.changeMode(type, baseMode,true)
|
|
|
|
|
|
+ restoreConfig = CofarSDK.changeMode(type, baseMode, true)
|
|
ThreadUtils.runOnMainThread({
|
|
ThreadUtils.runOnMainThread({
|
|
- configLock = false;
|
|
|
|
- },500);
|
|
|
|
- if(restoreConfig != null){
|
|
|
|
|
|
+ configLock = false;
|
|
|
|
+ }, 500);
|
|
|
|
+ if (restoreConfig != null) {
|
|
targetTemp = restoreConfig.targetTemp;
|
|
targetTemp = restoreConfig.targetTemp;
|
|
motorDirection = restoreConfig.motorDirection;
|
|
motorDirection = restoreConfig.motorDirection;
|
|
motorGear = restoreConfig.motorGear;
|
|
motorGear = restoreConfig.motorGear;
|
|
targetTime = restoreConfig.targetTime;
|
|
targetTime = restoreConfig.targetTime;
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
CofarSDK.changeMode(type, baseMode)
|
|
CofarSDK.changeMode(type, baseMode)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if(restoreConfig == null){
|
|
|
|
|
|
+ if (restoreConfig == null) {
|
|
currDevInfo.apply {
|
|
currDevInfo.apply {
|
|
targetTemp = baseMode.defaultTemp.toShort()
|
|
targetTemp = baseMode.defaultTemp.toShort()
|
|
motorDirection = baseMode.motorDirection.toByte()
|
|
motorDirection = baseMode.motorDirection.toByte()
|
|
@@ -637,6 +670,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
)
|
|
)
|
|
|
|
|
|
currentMotorGer = defaultMotorGear
|
|
currentMotorGer = defaultMotorGear
|
|
|
|
+ this@ModesDetailActivity.isMotorDirectionGearChange =
|
|
|
|
+ isMotorDirectionChange
|
|
updateMotorGearUI(
|
|
updateMotorGearUI(
|
|
minMotorGear.toFloat(),
|
|
minMotorGear.toFloat(),
|
|
maxMotorGear.toFloat(),
|
|
maxMotorGear.toFloat(),
|
|
@@ -664,16 +699,16 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
private fun getTimeStr(time: Long): String {
|
|
private fun getTimeStr(time: Long): String {
|
|
|
|
|
|
- if(time >= 91*60){
|
|
|
|
|
|
+ if (time >= 91 * 60) {
|
|
var h = time / 3600;
|
|
var h = time / 3600;
|
|
var m = time % 3600 / 60;
|
|
var m = time % 3600 / 60;
|
|
- return "${if(h < 10) "0${h}" else h}:${if(m < 10) "0${m}" else m}";
|
|
|
|
- }else{
|
|
|
|
|
|
+ return "${if (h < 10) "0${h}" else h}:${if (m < 10) "0${m}" else m}";
|
|
|
|
+ } else {
|
|
|
|
|
|
var m = time / 60;
|
|
var m = time / 60;
|
|
var s = time % 60;
|
|
var s = time % 60;
|
|
|
|
|
|
- return "${if(m < 10) "0${m}" else m}:${if(s < 10) "0${s}" else s}";
|
|
|
|
|
|
+ return "${if (m < 10) "0${m}" else m}:${if (s < 10) "0${s}" else s}";
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -725,12 +760,12 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
private fun rotateStep(): Int {
|
|
private fun rotateStep(): Int {
|
|
- if(currDevInfo.targetTime >= 60){
|
|
|
|
- return 10;
|
|
|
|
|
|
+ if (currDevInfo.targetTime >= 60) {
|
|
|
|
+ return 10;
|
|
}
|
|
}
|
|
|
|
|
|
- if(currDevInfo.targetTime >= 10 * 60){
|
|
|
|
- return 30;
|
|
|
|
|
|
+ if (currDevInfo.targetTime >= 10 * 60) {
|
|
|
|
+ return 30;
|
|
}
|
|
}
|
|
|
|
|
|
return 1
|
|
return 1
|
|
@@ -739,15 +774,16 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
var lastKeyTime = 0L
|
|
var lastKeyTime = 0L
|
|
var lastKeyCode = 0;
|
|
var lastKeyCode = 0;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 旋转物理键
|
|
* 旋转物理键
|
|
*/
|
|
*/
|
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
var spend = (System.currentTimeMillis() - lastKeyTime);
|
|
var spend = (System.currentTimeMillis() - lastKeyTime);
|
|
- if( spend < 10){
|
|
|
|
|
|
+ if (spend < 10) {
|
|
return super.dispatchKeyEvent(event);
|
|
return super.dispatchKeyEvent(event);
|
|
}
|
|
}
|
|
- lastKeyTime = System.currentTimeMillis();
|
|
|
|
|
|
+ lastKeyTime = System.currentTimeMillis();
|
|
val currentStep = viewModel.currentStep.value
|
|
val currentStep = viewModel.currentStep.value
|
|
Log.d("aaaaaa", "${event.keyCode}")
|
|
Log.d("aaaaaa", "${event.keyCode}")
|
|
|
|
|
|
@@ -755,7 +791,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
if (event.action != KeyEvent.ACTION_UP) {
|
|
if (event.action != KeyEvent.ACTION_UP) {
|
|
|
|
|
|
- when ( event.keyCode) {
|
|
|
|
|
|
+ when (event.keyCode) {
|
|
//旋转+
|
|
//旋转+
|
|
TURN_UP_KEY_CODE -> {
|
|
TURN_UP_KEY_CODE -> {
|
|
when (currentStep) {
|
|
when (currentStep) {
|
|
@@ -772,6 +808,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
tempRingEvent(currentTemp)
|
|
tempRingEvent(currentTemp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.SPEED_SETTING -> {
|
|
CookSettingType.SPEED_SETTING -> {
|
|
if (isMotorGearChange) {
|
|
if (isMotorGearChange) {
|
|
//当前调节转速
|
|
//当前调节转速
|
|
@@ -783,14 +820,20 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
motorGearSpeedEvent(currentMotorGer)
|
|
motorGearSpeedEvent(currentMotorGer)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.TIME_SETTING -> {
|
|
CookSettingType.TIME_SETTING -> {
|
|
- if (isTimeChange){
|
|
|
|
|
|
+ if (isTimeChange) {
|
|
//当前调节时间
|
|
//当前调节时间
|
|
//dealWithTimeByOperation(true)
|
|
//dealWithTimeByOperation(true)
|
|
- handleRotateTimeChange(rotateStep())
|
|
|
|
|
|
+ handleRotateTimeChange(true)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ CookSettingType.DIRECTION_SETTING -> {
|
|
|
|
+ motorGearDirectionClick(DirectionView.Direction.RIGHT)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
else -> {}
|
|
else -> {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -806,8 +849,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
currentTemp = minTemp
|
|
currentTemp = minTemp
|
|
}
|
|
}
|
|
|
|
|
|
- if(currentTemp < 37){ //小于37度置0
|
|
|
|
- currentTemp=0
|
|
|
|
|
|
+ if (currentTemp < 37) { //小于37度置0
|
|
|
|
+ currentTemp = 0
|
|
}
|
|
}
|
|
|
|
|
|
currentTemp = CofarUtils.parseTemp(currentTemp.toShort()).toInt();
|
|
currentTemp = CofarUtils.parseTemp(currentTemp.toShort()).toInt();
|
|
@@ -817,8 +860,9 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
tempRingEvent(currentTemp)
|
|
tempRingEvent(currentTemp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.SPEED_SETTING -> {
|
|
CookSettingType.SPEED_SETTING -> {
|
|
- if (isMotorGearChange){
|
|
|
|
|
|
+ if (isMotorGearChange) {
|
|
//当前调节转速
|
|
//当前调节转速
|
|
currentMotorGer -= 1
|
|
currentMotorGer -= 1
|
|
if (currentMotorGer < minMotorGear) {
|
|
if (currentMotorGer < minMotorGear) {
|
|
@@ -828,13 +872,18 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
motorGearSpeedEvent(currentMotorGer)
|
|
motorGearSpeedEvent(currentMotorGer)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
CookSettingType.TIME_SETTING -> {
|
|
CookSettingType.TIME_SETTING -> {
|
|
if (isTimeChange) {
|
|
if (isTimeChange) {
|
|
//当前调节时间
|
|
//当前调节时间
|
|
//dealWithTimeByOperation(false)
|
|
//dealWithTimeByOperation(false)
|
|
- handleRotateTimeChange(-rotateStep())
|
|
|
|
|
|
+ handleRotateTimeChange(false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ CookSettingType.DIRECTION_SETTING -> {
|
|
|
|
+ motorGearDirectionClick(DirectionView.Direction.LEFT)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
else -> {}
|
|
else -> {}
|
|
}
|
|
}
|
|
@@ -847,80 +896,95 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
private var timeBuffer = 0;
|
|
private var timeBuffer = 0;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 旋转按钮切换时间
|
|
* 旋转按钮切换时间
|
|
*/
|
|
*/
|
|
- private fun handleRotateTimeChange(c:Int){
|
|
|
|
|
|
+ private fun handleRotateTimeChange(increase: Boolean) {
|
|
|
|
|
|
- ThreadUtils.runOnMainThread({
|
|
|
|
|
|
+ ThreadUtils.runOnMainThread {
|
|
//当前调节时间
|
|
//当前调节时间
|
|
- var targetTime = currDevInfo.targetTime.toInt()
|
|
|
|
- if(currDevInfo.remainTime.toInt() != 0){
|
|
|
|
- targetTime = currDevInfo.remainTime.toInt()
|
|
|
|
|
|
+ var targetTime = currDevInfo.targetTime
|
|
|
|
+ if (currDevInfo.remainTime != 0) {
|
|
|
|
+ targetTime = currDevInfo.remainTime
|
|
}
|
|
}
|
|
- if(currDevInfo.targetTimeBuffer.toInt() != -1){
|
|
|
|
- targetTime = currDevInfo.targetTimeBuffer.toInt()
|
|
|
|
|
|
+ if (currDevInfo.targetTimeBuffer != -1) {
|
|
|
|
+ targetTime = currDevInfo.targetTimeBuffer
|
|
|
|
+ }
|
|
|
|
+ var step = 0
|
|
|
|
+ if (whereIndex == 1) {
|
|
|
|
+ step += 60
|
|
|
|
+ } else {
|
|
|
|
+ step = rotateStep()
|
|
|
|
+ }
|
|
|
|
+ if (increase) {
|
|
|
|
+ targetTime += step
|
|
|
|
+ } else {
|
|
|
|
+ targetTime -= step
|
|
}
|
|
}
|
|
- targetTime+=c
|
|
|
|
|
|
|
|
|
|
|
|
- if(targetTime < currDevInfo.mode.minTime){ //处理边界
|
|
|
|
- targetTime = currDevInfo.mode.minTime
|
|
|
|
|
|
+ Log.d("kkkkkkk", "$whereIndex===$step===$targetTime")
|
|
|
|
+ if (targetTime < 0) {
|
|
|
|
+ targetTime = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if( targetTime > currDevInfo.mode.maxTime){ //处理边界
|
|
|
|
|
|
+ if (targetTime > currDevInfo.mode.maxTime) {
|
|
targetTime = currDevInfo.mode.maxTime
|
|
targetTime = currDevInfo.mode.maxTime
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(targetTime < 0){
|
|
|
|
- targetTime = 0;
|
|
|
|
|
|
+ if (targetTime < currDevInfo.mode.minTime) {
|
|
|
|
+ targetTime = currDevInfo.mode.minTime
|
|
}
|
|
}
|
|
val sec = targetTime % 60
|
|
val sec = targetTime % 60
|
|
- val min = ((targetTime / 60) % 60 )
|
|
|
|
|
|
+ val min = ((targetTime / 60) % 60)
|
|
val hour = (targetTime / 3600)
|
|
val hour = (targetTime / 3600)
|
|
var time = ""
|
|
var time = ""
|
|
- if(hour > 0){
|
|
|
|
- time += if(hour < 10){
|
|
|
|
|
|
+ if (hour > 0) {
|
|
|
|
+ time += if (hour < 10) {
|
|
"0${hour}"
|
|
"0${hour}"
|
|
- }else{
|
|
|
|
- "${hour}"
|
|
|
|
|
|
+ } else {
|
|
|
|
+ "$hour"
|
|
}
|
|
}
|
|
|
|
|
|
- time += if(min < 10){
|
|
|
|
|
|
+ time += if (min < 10) {
|
|
":0${min}"
|
|
":0${min}"
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
":${min}"
|
|
":${min}"
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- time += if(min < 10){
|
|
|
|
|
|
+ } else {
|
|
|
|
+ time += if (min < 10) {
|
|
"0${min}"
|
|
"0${min}"
|
|
- }else{
|
|
|
|
- "${min}"
|
|
|
|
|
|
+ } else {
|
|
|
|
+ "$min"
|
|
}
|
|
}
|
|
|
|
|
|
- time += if(sec < 10){
|
|
|
|
|
|
+ time += if (sec < 10) {
|
|
":0${sec}"
|
|
":0${sec}"
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
":${sec}"
|
|
":${sec}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- rollTimeEvent(hour,min,sec,time, setByUser = true)
|
|
|
|
-
|
|
|
|
|
|
+ rollTimeEvent(hour, min, sec, time, setByUser = true)
|
|
currDevInfo.apply {
|
|
currDevInfo.apply {
|
|
- updateTimeUI(mode.minTime, mode.maxTime,remainTime.toInt(),targetTime.toLong(),true)
|
|
|
|
- binding.apply {
|
|
|
|
- clSetTime.setTimeInternal(hour,min,sec,true,true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ updateTimeUI(
|
|
|
|
+ mode.minTime,
|
|
|
|
+ mode.maxTime,
|
|
|
|
+ remainTime,
|
|
|
|
+ targetTime.toLong(),
|
|
|
|
+ true
|
|
|
|
+ )
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ binding.clSetTime.setTimeInternal(
|
|
|
|
+ hour,
|
|
|
|
+ min,
|
|
|
|
+ sec,
|
|
|
|
+ changeSetting = true,
|
|
|
|
+ setByUser = true
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
private var pressStartTime = -1L;
|
|
private var pressStartTime = -1L;
|
|
|
|
|
|
|
|
|
|
@@ -932,21 +996,22 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
|
if (keyCode == PRESS_DOWN_KEY_CODE) {
|
|
if (keyCode == PRESS_DOWN_KEY_CODE) {
|
|
|
|
|
|
|
|
+ Log.d("======","down")
|
|
|
|
|
|
//当前是turbo模式下
|
|
//当前是turbo模式下
|
|
if (modeType == ModesType.TURBO.name) {
|
|
if (modeType == ModesType.TURBO.name) {
|
|
turboDownEvent()
|
|
turboDownEvent()
|
|
- }else{
|
|
|
|
- if(pressStartTime == -1L){
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (pressStartTime == -1L) {
|
|
pressStartTime = System.currentTimeMillis()
|
|
pressStartTime = System.currentTimeMillis()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- if(pressStartTime != -1L && (System.currentTimeMillis() - pressStartTime ) > 1000 && event.keyCode == PRESS_DOWN_KEY_CODE){
|
|
|
|
- this.onKeyLongPress(keyCode,event);
|
|
|
|
|
|
+ if (pressStartTime != -1L && (System.currentTimeMillis() - pressStartTime) > 1000 && event.keyCode == PRESS_DOWN_KEY_CODE) {
|
|
|
|
+ this.onKeyLongPress(keyCode, event);
|
|
event.startTracking()
|
|
event.startTracking()
|
|
pressStartTime = -1L
|
|
pressStartTime = -1L
|
|
- canStart=false;
|
|
|
|
|
|
+ canStart = false;
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -957,9 +1022,9 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
|
|
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
|
|
|
|
|
|
- if( modeType == ModesType.WIGHT.name){
|
|
|
|
|
|
+ if (modeType == ModesType.WIGHT.name) {
|
|
backClick()
|
|
backClick()
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
if (mRunningState == DevStatus.RUNNING.toInt() || currDevInfo.status == DevStatus.PAUSE.toInt()) {
|
|
if (mRunningState == DevStatus.RUNNING.toInt() || currDevInfo.status == DevStatus.PAUSE.toInt()) {
|
|
stopClick()
|
|
stopClick()
|
|
} else if (mRunningState == DevStatus.STOP.toInt()) {
|
|
} else if (mRunningState == DevStatus.STOP.toInt()) {
|
|
@@ -976,7 +1041,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
* 物理键离开事件
|
|
* 物理键离开事件
|
|
*/
|
|
*/
|
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
|
-
|
|
|
|
|
|
+ Log.d("======","up")
|
|
if (modeType == ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE) {
|
|
if (modeType == ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE) {
|
|
//当前是turbo模式下,并且是物理键按下
|
|
//当前是turbo模式下,并且是物理键按下
|
|
turboUpEvent()
|
|
turboUpEvent()
|
|
@@ -987,7 +1052,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (modeType != ModesType.WIGHT.name && modeType != ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE && canStart) {
|
|
|
|
|
|
+ if (modeType != ModesType.WIGHT.name && modeType != ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE && canStart) {
|
|
//非turbo模式
|
|
//非turbo模式
|
|
if (userChanging && currDevInfo.status.toByte() != DevStatus.STOP) {
|
|
if (userChanging && currDevInfo.status.toByte() != DevStatus.STOP) {
|
|
//用户调节中
|
|
//用户调节中
|
|
@@ -995,21 +1060,20 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
} else {
|
|
} else {
|
|
if (mRunningState == DevStatus.RUNNING.toInt()) {
|
|
if (mRunningState == DevStatus.RUNNING.toInt()) {
|
|
pauseClick()
|
|
pauseClick()
|
|
- } else if(currDevInfo.status == DevStatus.PAUSE.toInt()){
|
|
|
|
|
|
+ } else if (currDevInfo.status == DevStatus.PAUSE.toInt()) {
|
|
resumeClick();
|
|
resumeClick();
|
|
- }
|
|
|
|
- else if (mRunningState == DevStatus.STOP.toInt()) {
|
|
|
|
|
|
+ } else if (mRunningState == DevStatus.STOP.toInt()) {
|
|
startClick()
|
|
startClick()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- if(modeType == ModesType.WIGHT.name){
|
|
|
|
|
|
+ if (modeType == ModesType.WIGHT.name) {
|
|
weightClearClick();
|
|
weightClearClick();
|
|
}
|
|
}
|
|
|
|
|
|
- canStart=true;
|
|
|
|
|
|
+ canStart = true;
|
|
return super.onKeyUp(keyCode, event)
|
|
return super.onKeyUp(keyCode, event)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1039,8 +1103,14 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
tempRingView.setRange(minTemp, maxTemp)
|
|
tempRingView.setRange(minTemp, maxTemp)
|
|
tempRingView.setCanTouch(isTempChange)
|
|
tempRingView.setCanTouch(isTempChange)
|
|
var tempBuffer = CofarSDK.devInfo().targetTempBuffer;
|
|
var tempBuffer = CofarSDK.devInfo().targetTempBuffer;
|
|
- steamFire.configNum(CofarUtils.parseTemp( if(tempBuffer.toInt() != -1) tempBuffer else targetTemp.toShort()).toInt())
|
|
|
|
- clCookTemp.configSteamFire(CofarUtils.parseTemp(if(tempBuffer.toInt() != -1) tempBuffer else targetTemp.toShort()).toInt())
|
|
|
|
|
|
+ steamFire.configNum(
|
|
|
|
+ CofarUtils.parseTemp(if (tempBuffer.toInt() != -1) tempBuffer else targetTemp.toShort())
|
|
|
|
+ .toInt()
|
|
|
|
+ )
|
|
|
|
+ clCookTemp.configSteamFire(
|
|
|
|
+ CofarUtils.parseTemp(if (tempBuffer.toInt() != -1) tempBuffer else targetTemp.toShort())
|
|
|
|
+ .toInt()
|
|
|
|
+ )
|
|
|
|
|
|
if (!userChanging || focusUpdate) {
|
|
if (!userChanging || focusUpdate) {
|
|
clCookTemp.setConfigValue("--${CofarUtils.parseTemp(targetTemp.toShort())}°C--")
|
|
clCookTemp.setConfigValue("--${CofarUtils.parseTemp(targetTemp.toShort())}°C--")
|
|
@@ -1075,9 +1145,9 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
var hours = 0
|
|
var hours = 0
|
|
var minute = 0
|
|
var minute = 0
|
|
var sec = 0
|
|
var sec = 0
|
|
- if (remainTime > ( 91 * 60)) {
|
|
|
|
|
|
+ if (remainTime > (91 * 60)) {
|
|
hours = remainTime / 3600
|
|
hours = remainTime / 3600
|
|
- minute = remainTime % 3600 / 60
|
|
|
|
|
|
+ minute = remainTime % 3600 / 60
|
|
} else {
|
|
} else {
|
|
minute = remainTime / 60
|
|
minute = remainTime / 60
|
|
sec = remainTime % 60
|
|
sec = remainTime % 60
|
|
@@ -1160,7 +1230,6 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
private fun updateStatusBtn(status: Byte) {
|
|
private fun updateStatusBtn(status: Byte) {
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
//当前用户正在修改不更新按钮状态
|
|
//当前用户正在修改不更新按钮状态
|
|
if (userChanging) return
|
|
if (userChanging) return
|
|
//切碎功能隐藏按钮
|
|
//切碎功能隐藏按钮
|
|
@@ -1234,7 +1303,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
* 显示/隐藏 确认取消按钮
|
|
* 显示/隐藏 确认取消按钮
|
|
*/
|
|
*/
|
|
private fun showConfirmAndCancelBtn() {
|
|
private fun showConfirmAndCancelBtn() {
|
|
- if (currDevInfo.status.toByte() != DevStatus.STOP ) {
|
|
|
|
|
|
+ if (currDevInfo.status.toByte() != DevStatus.STOP) {
|
|
binding.btnCancel.visibility = View.VISIBLE
|
|
binding.btnCancel.visibility = View.VISIBLE
|
|
binding.btnConfirm.visibility = View.VISIBLE
|
|
binding.btnConfirm.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
@@ -1253,6 +1322,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
CofarSDK.cancel()
|
|
CofarSDK.cancel()
|
|
CofarSDK.devInfo().runningRecipeId = null
|
|
CofarSDK.devInfo().runningRecipeId = null
|
|
CofarSDK.start(modeType)
|
|
CofarSDK.start(modeType)
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1279,6 +1350,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
* 点击确认操作
|
|
* 点击确认操作
|
|
*/
|
|
*/
|
|
private fun confirmClick() {
|
|
private fun confirmClick() {
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
//确认
|
|
//确认
|
|
userChanging = false
|
|
userChanging = false
|
|
//配置
|
|
//配置
|
|
@@ -1297,7 +1370,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
//TODO 崩溃?
|
|
//TODO 崩溃?
|
|
try {
|
|
try {
|
|
FloatWindowManager.hideStepFlowWindow()
|
|
FloatWindowManager.hideStepFlowWindow()
|
|
- }catch (e:Exception) {
|
|
|
|
|
|
+ } catch (e: Exception) {
|
|
print(e)
|
|
print(e)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1315,6 +1388,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
*/
|
|
*/
|
|
private fun weightClick() {
|
|
private fun weightClick() {
|
|
// CofarSDK.stop(false)
|
|
// CofarSDK.stop(false)
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
modeChange = true
|
|
modeChange = true
|
|
modeType = ModesType.WIGHT.name
|
|
modeType = ModesType.WIGHT.name
|
|
initModeData(modeType)
|
|
initModeData(modeType)
|
|
@@ -1322,7 +1397,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
- binding.ivBanner.setBackgroundResource(viewModel.getBanner(modeType))
|
|
|
|
|
|
+ binding.ivBanner.background_drawable = viewModel.getBanner(modeType)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1330,6 +1405,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
*/
|
|
*/
|
|
private fun turboClick() {
|
|
private fun turboClick() {
|
|
CofarSDK.stop(false)
|
|
CofarSDK.stop(false)
|
|
|
|
+ whereIndex = -1
|
|
|
|
+ binding.clSetTime.stopAlphaAnim()
|
|
modeChange = true
|
|
modeChange = true
|
|
modeType = ModesType.TURBO.name
|
|
modeType = ModesType.TURBO.name
|
|
viewModel.changeStep(CookSettingType.TEMP_SETTING)
|
|
viewModel.changeStep(CookSettingType.TEMP_SETTING)
|
|
@@ -1338,7 +1415,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.ivTurbo.visibility = View.GONE
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.ivWeight.visibility = View.GONE
|
|
binding.ivTurboView.visibility = View.VISIBLE
|
|
binding.ivTurboView.visibility = View.VISIBLE
|
|
- binding.ivBanner.setBackgroundResource(viewModel.getBanner(modeType))
|
|
|
|
|
|
+ binding.ivBanner.background_drawable = viewModel.getBanner(modeType)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1362,9 +1439,9 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
if (modeChange) {
|
|
if (modeChange) {
|
|
|
|
|
|
- if(modeType == ModesType.TURBO.name){ //TURBO未停止之前不能退出
|
|
|
|
- CofarSDK.stop(false)
|
|
|
|
- if(DevStatus.STOP != devInfo.status.toByte()){
|
|
|
|
|
|
+ if (modeType == ModesType.TURBO.name) { //TURBO未停止之前不能退出
|
|
|
|
+ CofarSDK.stop(false)
|
|
|
|
+ if (DevStatus.STOP != devInfo.status.toByte()) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1375,15 +1452,18 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
var cm = modeType;
|
|
var cm = modeType;
|
|
modeType = lastModeType
|
|
modeType = lastModeType
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
binding.tvModeName.text = viewModel.getModeTitle(resources, modeType)
|
|
- binding.ivBanner.setBackgroundResource(viewModel.getBanner(modeType))
|
|
|
|
|
|
+ binding.ivBanner.background_drawable = viewModel.getBanner(modeType)
|
|
modeChange = false
|
|
modeChange = false
|
|
binding.ivTurboView.visibility = View.GONE
|
|
binding.ivTurboView.visibility = View.GONE
|
|
- initModeData(modeType,cm == ModesType.WIGHT.name || cm == ModesType.TURBO.name)
|
|
|
|
|
|
+ initModeData(modeType, cm == ModesType.WIGHT.name || cm == ModesType.TURBO.name)
|
|
changeCommonStep()
|
|
changeCommonStep()
|
|
} else if (devInfo.status != DevStatus.STOP.toInt() && modeType != ModesType.WIGHT.name
|
|
} else if (devInfo.status != DevStatus.STOP.toInt() && modeType != ModesType.WIGHT.name
|
|
&& modeType != ModesType.TURBO.name
|
|
&& modeType != ModesType.TURBO.name
|
|
) {
|
|
) {
|
|
- if(CofarSDK.devInfo().runningInstId == modeType) backRequestDialog.showDialog(supportFragmentManager, "backRequestDialog")
|
|
|
|
|
|
+ if (CofarSDK.devInfo().runningInstId == modeType) backRequestDialog.showDialog(
|
|
|
|
+ supportFragmentManager,
|
|
|
|
+ "backRequestDialog"
|
|
|
|
+ )
|
|
else finish()
|
|
else finish()
|
|
} else {
|
|
} else {
|
|
finish()
|
|
finish()
|
|
@@ -1416,17 +1496,21 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
* 点击电机方向事件
|
|
* 点击电机方向事件
|
|
*/
|
|
*/
|
|
private fun motorGearDirectionClick(direction: DirectionView.Direction) {
|
|
private fun motorGearDirectionClick(direction: DirectionView.Direction) {
|
|
- userChanging = true
|
|
|
|
- binding.clCookDirection.updateChangeValue(
|
|
|
|
- getDirectionStr(direction == DirectionView.Direction.LEFT)
|
|
|
|
- )
|
|
|
|
- if (direction != DirectionView.Direction.RIGHT) {
|
|
|
|
- CofarSDK.cfgMotorDirection(MotorDirections.REVERSE);
|
|
|
|
|
|
+ if (isMotorDirectionGearChange){
|
|
|
|
+ userChanging = true
|
|
|
|
+ binding.clCookDirection.updateChangeValue(
|
|
|
|
+ getDirectionStr(direction == DirectionView.Direction.LEFT)
|
|
|
|
+ )
|
|
|
|
|
|
- } else {
|
|
|
|
- CofarSDK.cfgMotorDirection(MotorDirections.FORWARD);
|
|
|
|
|
|
+ if (direction != DirectionView.Direction.RIGHT) {
|
|
|
|
+ CofarSDK.cfgMotorDirection(MotorDirections.REVERSE);
|
|
|
|
+ updateMotorDirectionUI(MotorDirections.REVERSE.toInt(), true);
|
|
|
|
+ } else {
|
|
|
|
+ CofarSDK.cfgMotorDirection(MotorDirections.FORWARD);
|
|
|
|
+ updateMotorDirectionUI(MotorDirections.FORWARD.toInt(), true);
|
|
|
|
+ }
|
|
|
|
+ showConfirmAndCancelBtn()
|
|
}
|
|
}
|
|
- showConfirmAndCancelBtn()
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1467,4 +1551,9 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ companion object {
|
|
|
|
+ var dp83 = (R.dimen.convert_83px).resId2Dimension().toInt()
|
|
|
|
+ var dp25 = (R.dimen.convert_25px).resId2Dimension().toInt()
|
|
|
|
+ }
|
|
}
|
|
}
|