|
@@ -27,6 +27,7 @@ import com.develop.common.tag.CURRENT_USER_ID
|
|
|
import com.develop.common.ui.CommonBVMActivity
|
|
|
import com.develop.common.utils.Resource
|
|
|
import com.develop.common.dialog.DownloadFailedDialog
|
|
|
+import com.develop.common.dialog.PlainDialogView
|
|
|
import com.develop.common.dialog.ShareQRCodeDialog
|
|
|
import com.develop.common.event.RefreshDataEvent
|
|
|
import com.develop.common.event.RefreshLikeDataEvent
|
|
@@ -34,6 +35,7 @@ import com.develop.common.food_sdk.FloatWindowManager
|
|
|
import com.develop.common.tag.CURRENT_LANGUAGE
|
|
|
import com.develop.common.tag.LOGIN_TAG
|
|
|
import com.develop.common.tag.MODE_TYPE
|
|
|
+import com.develop.common.utils.StringUtils
|
|
|
import com.develop.common.utils.setLeftDrawable
|
|
|
import com.develop.step.databinding.ActivityCookDetailBinding
|
|
|
import com.develop.step.viewmodel.CookDetailViewModel
|
|
@@ -92,6 +94,11 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
|
|
|
DownloadFailedDialog()
|
|
|
}
|
|
|
|
|
|
+ private val loadingDialog by lazy {
|
|
|
+ PlainDialogView(this, com.develop.common.R.layout.dialog_wifi_loading)
|
|
|
+ }
|
|
|
+
|
|
|
+ private var isLoadingDialog = false //判断是否显示了loading,主要用在在线食谱
|
|
|
|
|
|
override fun createViewModel(): CookDetailViewModel {
|
|
|
return getViewModel(CookDetailViewModel::class.java)
|
|
@@ -117,6 +124,10 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
|
|
|
viewModel.getRecipeLiveData().observe(this) {
|
|
|
cookDetailJson = Json.encodeToString(it)
|
|
|
updateCookDetail(it)
|
|
|
+ if (cookSource == "remote" &&isLoadingDialog){
|
|
|
+ dismissloadingDialog()
|
|
|
+ startCookStep()
|
|
|
+ }
|
|
|
}
|
|
|
viewModel.getErrorCodeLiveData().observe(this) {
|
|
|
if (it == CookDetailViewModel.ERR_NO_RECIPE_MATCH) {
|
|
@@ -312,26 +323,14 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
|
|
|
binding.clStartCooking.setOnClickListener {
|
|
|
if (cookSource == "remote") {
|
|
|
if (viewModel.isDownloadSuccess()) {
|
|
|
- var step = 0
|
|
|
- if (FloatWindowManager.isStepShow()){
|
|
|
- var runingId = CofarSDK.devInfo().runningInstId
|
|
|
- if (runingId.contains(":")) {
|
|
|
- var (numbers, steps) = runingId.split(":")
|
|
|
- if (recipeNumber == numbers) {
|
|
|
- step = steps.toInt()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- navigateTo(Screens.Cook.COOK_STEP2) {
|
|
|
- withString("number", recipeNumber)
|
|
|
- withBoolean("isLike", isLike)
|
|
|
- withString("cook_step_detail", cookDetailJson)
|
|
|
- withString("portionSizelJson", portionSizelJson)
|
|
|
- withInt("stepIndex", step)
|
|
|
+// recipeLiveData
|
|
|
+ //处理在线食谱存在数据还没返回,但可以点击进去到食谱步骤
|
|
|
+ if (StringUtils.isEmpty(cookDetailJson)){
|
|
|
+ isLoadingDialog = true
|
|
|
+ showloadingDialog()
|
|
|
+ return@setOnClickListener
|
|
|
}
|
|
|
+ startCookStep()
|
|
|
} else if (!viewModel.isDownloading()) {
|
|
|
binding.tvDownload.setText(com.develop.common.R.string.downloading)
|
|
|
viewModel.downloadRecipe()
|
|
@@ -467,6 +466,26 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun startCookStep(){
|
|
|
+ var step = 0
|
|
|
+ if (FloatWindowManager.isStepShow()){
|
|
|
+ var runingId = CofarSDK.devInfo().runningInstId
|
|
|
+ if (runingId.contains(":")) {
|
|
|
+ var (numbers, steps) = runingId.split(":")
|
|
|
+ if (recipeNumber == numbers) {
|
|
|
+ step = steps.toInt()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ navigateTo(Screens.Cook.COOK_STEP2) {
|
|
|
+ withString("number", recipeNumber)
|
|
|
+ withBoolean("isLike", isLike)
|
|
|
+ withString("cook_step_detail", cookDetailJson)
|
|
|
+ withString("portionSizelJson", portionSizelJson)
|
|
|
+ withInt("stepIndex", step)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
fun onDevStateEvent(event: DevStatusEvent) {
|
|
@@ -754,6 +773,15 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
|
|
|
dialog.showDialog(supportFragmentManager, "RecipeDeleteConfirmDialog")
|
|
|
}
|
|
|
|
|
|
+ fun showloadingDialog(cancelable: Boolean = false) {
|
|
|
+ loadingDialog.showDialog(cancelable)
|
|
|
+ }
|
|
|
+
|
|
|
+ fun dismissloadingDialog() {
|
|
|
+ loadingDialog.hideDialog()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Subscribe
|
|
|
fun refreshLikeRecipes(event: RefreshLikeDataEvent) {
|
|
|
if (event.isLike) {
|