|
@@ -10,10 +10,12 @@ import android.view.View
|
|
|
import android.view.animation.LinearInterpolator
|
|
|
import android.widget.TextView
|
|
|
import androidx.activity.viewModels
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Autowired
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
import com.develop.food.base.data.ModesType
|
|
|
import com.develop.food.base.data.model.CookSettingType
|
|
|
+import com.develop.food.base.repo.entity.DevRecipePortionSize
|
|
|
import com.develop.food.base.ui.BaseActivity
|
|
|
import com.develop.food.base.utils.ThreadUtils
|
|
|
import com.develop.food.base.utils.updateText
|
|
@@ -21,13 +23,18 @@ import com.develop.food.base.widgets.BCustomerLinearLayout
|
|
|
import com.develop.food.base.widgets.CancelConfirmDialog
|
|
|
import com.develop.food.base.widgets.CookProgressDrawable
|
|
|
import com.develop.step.databinding.ActivityFoodStep2Binding
|
|
|
+import com.develop.step.details.CookDetailSourceAdapter
|
|
|
+import com.develop.step.details.CookSourceItem
|
|
|
+import com.develop.step.model.CookDetailInfo
|
|
|
import com.develop.step.viewmodel.CookStepViewModel
|
|
|
import com.develop.step.widgets.NoteEditDialog
|
|
|
import com.develop.step.widgets.RingControlView
|
|
|
+import com.google.gson.Gson
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.core.DevInfo
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevStatusEvent
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
+import java.math.BigDecimal
|
|
|
import java.util.*
|
|
|
|
|
|
abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
@@ -56,9 +63,19 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
protected var whereIndex = -1
|
|
|
|
|
|
private var isCookDetailDialogShow = false
|
|
|
+ private var isCookStepDialogShow = false
|
|
|
private var rotateAnimator: ObjectAnimator? = null
|
|
|
private var rotateAnimDir = -1
|
|
|
|
|
|
+ @JvmField
|
|
|
+ @Autowired(name = "cook_step_detail")
|
|
|
+ var cookStepDetail: String? = null
|
|
|
+
|
|
|
+
|
|
|
+ @JvmField
|
|
|
+ @Autowired(name = "portionSizelJson")
|
|
|
+ var portionSizelJson: String? = null
|
|
|
+
|
|
|
abstract fun clickNextStep()
|
|
|
|
|
|
abstract fun clickPrevStep()
|
|
@@ -89,10 +106,10 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
// EventBus.getDefault().register(this)
|
|
|
binding.viewProgress.background = cookProgressDrawable
|
|
|
binding.tvTitleStep.setOnClickListener {
|
|
|
- showCookDetailDialog()
|
|
|
+ //showCookDetailDialog()
|
|
|
}
|
|
|
binding.tvStepName.setOnClickListener {
|
|
|
- showCookDetailDialog()
|
|
|
+ showCookStepDetailDialog()
|
|
|
}
|
|
|
binding.viewRemark.setOnClickListener {
|
|
|
NoteEditDialog().showDialog(supportFragmentManager, "NoteEditDialog")
|
|
@@ -131,6 +148,15 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
finish()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ binding.viewSource.setOnClickListener {
|
|
|
+ showCookSourceDialog()
|
|
|
+ }
|
|
|
+
|
|
|
+ binding.viewStepMark.setOnClickListener {
|
|
|
+ showCookStepDetailDialog()
|
|
|
+ }
|
|
|
+
|
|
|
binding.controller.btnStart.setOnClickListener {
|
|
|
clickFirstButton((it.tag as? String) ?: BUTTON_TAG_START)
|
|
|
viewModel.stepUiData.doingModify = false
|
|
@@ -166,6 +192,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
MotionEvent.ACTION_DOWN -> {
|
|
|
turboDownEvent()
|
|
|
}
|
|
|
+
|
|
|
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
|
|
|
turboUpEvent()
|
|
|
}
|
|
@@ -223,7 +250,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
binding.controller.ivDirection.rotationY = 0f
|
|
|
binding.controller.tvTurnRight.setTextColor(0xffE60012.toInt())
|
|
|
binding.controller.tvTurnLeft.setTextColor(0xffE5E5E5.toInt())
|
|
|
- binding.controller.tvSetDirection.updateText(getString(R.string.turn_left ))
|
|
|
+ binding.controller.tvSetDirection.updateText(getString(R.string.turn_left))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -233,7 +260,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
binding.ivTurboView.visibility = View.GONE
|
|
|
}
|
|
|
|
|
|
- fun changeDescription(){
|
|
|
+ fun changeDescription() {
|
|
|
binding.controller.root.visibility = View.GONE
|
|
|
binding.llWeightView.visibility = View.GONE
|
|
|
binding.ivTurboView.visibility = View.GONE
|
|
@@ -258,12 +285,12 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
}
|
|
|
|
|
|
//蒸汽模式特殊处理
|
|
|
- if(viewModel.displayStep()?.workMode == ModesType.STEAM.name){
|
|
|
+ if (viewModel.displayStep()?.workMode == ModesType.STEAM.name) {
|
|
|
binding.controller.steamFire.visibility = View.VISIBLE;
|
|
|
binding.controller.tvRingTempText.visibility = View.GONE;
|
|
|
binding.controller.steamFireSmall.visibility = View.VISIBLE;
|
|
|
binding.controller.tvCookingTempTarget.visibility = View.GONE;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
binding.controller.steamFire.visibility = View.GONE;
|
|
|
binding.controller.tvRingTempText.visibility = View.VISIBLE;
|
|
|
binding.controller.steamFireSmall.visibility = View.GONE;
|
|
@@ -355,6 +382,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
viewBackgroundTemp.isSelected = true
|
|
|
viewIconTemp.isSelected = true
|
|
|
}
|
|
|
+
|
|
|
CookSettingType.TIME_SETTING -> {
|
|
|
viewSelectTime.visibility = View.VISIBLE
|
|
|
tvSetTime.isSelected = true
|
|
@@ -362,6 +390,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
viewBackgroundTime.isSelected = true
|
|
|
viewIconTime.isSelected = true
|
|
|
}
|
|
|
+
|
|
|
CookSettingType.SPEED_SETTING -> {
|
|
|
viewSelectSpeed.visibility = View.VISIBLE
|
|
|
tvSetSpeed.isSelected = true
|
|
@@ -369,6 +398,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
viewBackgroundSpeed.isSelected = true
|
|
|
viewIconSpeed.isSelected = true
|
|
|
}
|
|
|
+
|
|
|
CookSettingType.DIRECTION_SETTING -> {
|
|
|
viewSelectDirection.visibility = View.VISIBLE
|
|
|
tvSetDirection.isSelected = true
|
|
@@ -376,6 +406,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
viewBackgroundDirection.isSelected = true
|
|
|
viewIconDirection.isSelected = true
|
|
|
}
|
|
|
+
|
|
|
else -> {}
|
|
|
}
|
|
|
}
|
|
@@ -385,7 +416,7 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
return binding.controller.root.tag as? CookSettingType ?: CookSettingType.TEMP_SETTING
|
|
|
}
|
|
|
|
|
|
- private fun showCookDetailDialog() {
|
|
|
+ private fun showCookStepDetailDialog() {
|
|
|
if (!isCookDetailDialogShow) {
|
|
|
val dialogView = layoutInflater.inflate(
|
|
|
R.layout.item_cook_details, binding.flCookDetails, true
|
|
@@ -401,6 +432,50 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private val adapter = CookDetailSourceAdapter()
|
|
|
+
|
|
|
+ private fun showCookSourceDialog() {
|
|
|
+ if (!isCookStepDialogShow) {
|
|
|
+ adapter.colorResId = R.color.color_333333
|
|
|
+ val dialogView = layoutInflater.inflate(
|
|
|
+ R.layout.item_cook_source_1, binding.flCookDetails, true
|
|
|
+ )
|
|
|
+ val rlView = dialogView.findViewById<RecyclerView>(R.id.rv_list)
|
|
|
+ rlView.adapter = adapter
|
|
|
+
|
|
|
+ val cookDetailInfo = Gson().fromJson(cookStepDetail, CookDetailInfo::class.java)
|
|
|
+ val portionSize = Gson().fromJson(portionSizelJson, DevRecipePortionSize::class.java)
|
|
|
+
|
|
|
+ val sourceItems = mutableListOf<CookSourceItem>()
|
|
|
+ val originalList = mutableListOf<CookSourceItem>()
|
|
|
+ for (recipeFood in cookDetailInfo.material) {
|
|
|
+ val sourceItem = CookSourceItem(
|
|
|
+ recipeFood.foodName ?: "",
|
|
|
+ "${
|
|
|
+ BigDecimal.valueOf(recipeFood.amount ?: 0f.toDouble()).stripTrailingZeros()
|
|
|
+ .toPlainString()
|
|
|
+ } ${recipeFood.unit}"
|
|
|
+ )
|
|
|
+ if (recipeFood.recipePortionSizeNumber == portionSize.portionSize) {
|
|
|
+ sourceItems.add(sourceItem)
|
|
|
+ }
|
|
|
+ originalList.add(sourceItem)
|
|
|
+ }
|
|
|
+ if (sourceItems.isEmpty()) {
|
|
|
+ // 防止没有任何数据显示
|
|
|
+ sourceItems.addAll(originalList)
|
|
|
+ }
|
|
|
+ adapter.setNewInstance(sourceItems)
|
|
|
+ val closeView = dialogView.findViewById<View>(R.id.iv_close)
|
|
|
+ isCookStepDialogShow = true
|
|
|
+ closeView.setOnClickListener {
|
|
|
+ isCookStepDialogShow = false
|
|
|
+ binding.flCookDetails.removeAllViews()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Subscribe
|
|
|
fun onDevStateEvent(event: DevStatusEvent) {
|
|
|
ThreadUtils.runOnMainThread {
|
|
@@ -422,13 +497,13 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
if (rotateAnimator!!.isRunning) {
|
|
|
if (direction == rotateAnimDir) {
|
|
|
return
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
rotateAnimator?.cancel()
|
|
|
}
|
|
|
}
|
|
|
if (direction != 0) {
|
|
|
rotateAnimator?.reverse()
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
rotateAnimator?.start()
|
|
|
}
|
|
|
rotateAnimDir = direction
|
|
@@ -477,5 +552,6 @@ abstract class CookStepToolActivity : BaseActivity<ActivityFoodStep2Binding>() {
|
|
|
const val BUTTON_TAG_RESET = "reset"
|
|
|
const val BUTTON_TAG_CONFIRM = "confirm"
|
|
|
const val BUTTON_TAG_CANCEL = "cancel"
|
|
|
+ const val BUTTON_TAG_NEXT_STEP = "next"
|
|
|
}
|
|
|
}
|