|
@@ -6,7 +6,9 @@ import android.view.View
|
|
|
import com.alibaba.android.arouter.facade.annotation.Autowired
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
+import com.blankj.utilcode.util.GsonUtils
|
|
|
import com.blankj.utilcode.util.KeyboardUtils
|
|
|
+import com.develop.base.ext.getNewTuya
|
|
|
import com.develop.base.ext.getSN
|
|
|
import com.develop.base.ext.isNightTheme
|
|
|
import com.develop.base.ext.setGone
|
|
@@ -18,11 +20,15 @@ import com.develop.common.router.Screens
|
|
|
import com.develop.common.tag.CURRENT_USER_ID
|
|
|
import com.develop.common.ui.CommonBindingActivity
|
|
|
import com.develop.common.R
|
|
|
+import com.develop.common.data_repo.db.entity.DevRecipeCookingStep
|
|
|
import com.develop.common.event.RefreshDataEvent
|
|
|
import com.develop.common.event.RefreshStarDataEvent
|
|
|
+import com.develop.common.tuya_bean.RecipesBean
|
|
|
+import com.develop.common.utils.CommonUtils
|
|
|
|
|
|
import com.develop.step.databinding.ActivityCookEvaluateBinding
|
|
|
import com.drake.net.utils.withMain
|
|
|
+import com.google.gson.Gson
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.launch
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
@@ -137,6 +143,28 @@ class CookEvaluateActivity : CommonBindingActivity<ActivityCookEvaluateBinding>(
|
|
|
binding.tvOk.setOnClickListener {
|
|
|
KeyboardUtils.hideSoftInput(this)
|
|
|
evaluateContent = binding.etContent.text.toString()
|
|
|
+// if (getNewTuya()){
|
|
|
+//
|
|
|
+// getAddTuyaScore()
|
|
|
+// }else{
|
|
|
+// FoodDataProvider.getUserDatabase().runInTransaction {
|
|
|
+// val userTag = UserTag(CURRENT_USER_ID, recipeId, starCount, evaluateContent)
|
|
|
+// FoodDataProvider.getUserDatabase().userInfoDao().updateUserTag(userTag)
|
|
|
+// val result = FoodDataProvider.getDatabase().recipeDao().queryRecipe(recipeId)
|
|
|
+// result?.score = starCount.toDouble()
|
|
|
+// result?.useNum = result?.useNum?.plus(1)
|
|
|
+// useNum = result?.useNum ?: 0L
|
|
|
+// result?.apply {
|
|
|
+// FoodDataProvider.getDatabase().recipeDao().updateRecipe(this)
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// EventBus.getDefault().post(RefreshStarDataEvent(starCount, recipeId, useNum))
|
|
|
+// GlobalToast.showToast(getString(R.string.evaluate_successfully))
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
FoodDataProvider.getUserDatabase().runInTransaction {
|
|
|
val userTag = UserTag(CURRENT_USER_ID, recipeId, starCount, evaluateContent)
|
|
|
FoodDataProvider.getUserDatabase().userInfoDao().updateUserTag(userTag)
|
|
@@ -152,6 +180,8 @@ class CookEvaluateActivity : CommonBindingActivity<ActivityCookEvaluateBinding>(
|
|
|
EventBus.getDefault().post(RefreshStarDataEvent(starCount, recipeId, useNum))
|
|
|
GlobalToast.showToast(getString(R.string.evaluate_successfully))
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -175,4 +205,29 @@ class CookEvaluateActivity : CommonBindingActivity<ActivityCookEvaluateBinding>(
|
|
|
starViews[index].isSelected = index + 1 <= count
|
|
|
}
|
|
|
}
|
|
|
+ fun getAddTuyaScore(){
|
|
|
+ var allMap = HashMap<String, Any>()
|
|
|
+ var map = HashMap<String, Any>()
|
|
|
+ map["menuId"] = recipeId
|
|
|
+ map["score"] = starCount.toByte()
|
|
|
+ allMap["scoreJson"] = map
|
|
|
+
|
|
|
+ var gson = Gson()
|
|
|
+ var json = gson.toJson(map)
|
|
|
+
|
|
|
+
|
|
|
+ CommonUtils.getTuyaBean<RecipesBean>("tuya.device.menu.score.add", "1.0",
|
|
|
+ json, RecipesBean::class.java, object : CommonUtils.TuyaHttp<RecipesBean> {
|
|
|
+ override fun bean(t: RecipesBean) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun fail() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },0)
|
|
|
+
|
|
|
+ }
|
|
|
}
|