|
@@ -14,6 +14,7 @@ import com.develop.base.ext.isNightTheme
|
|
|
import com.develop.base.ext.setGone
|
|
|
import com.develop.base.scop.safeGlobalScope
|
|
|
import com.develop.base.util.GlobalToast
|
|
|
+import com.develop.base.util.ThreadUtils
|
|
|
import com.develop.common.data_repo.FoodDataProvider
|
|
|
import com.develop.common.data_repo.db.entity.UserTag
|
|
|
import com.develop.common.router.Screens
|
|
@@ -143,27 +144,6 @@ 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)
|
|
@@ -179,10 +159,21 @@ class CookEvaluateActivity : CommonBindingActivity<ActivityCookEvaluateBinding>(
|
|
|
}
|
|
|
EventBus.getDefault().post(RefreshStarDataEvent(starCount, recipeId, useNum))
|
|
|
GlobalToast.showToast(getString(R.string.evaluate_successfully))
|
|
|
+ }
|
|
|
|
|
|
+ ThreadUtils.runOnWorkThread(Runnable {
|
|
|
+ val userTag = FoodDataProvider
|
|
|
+ .getUserDatabase()
|
|
|
+ .userInfoDao()
|
|
|
+ .queryUserTag(CURRENT_USER_ID, recipeId)
|
|
|
+ ?: return@Runnable
|
|
|
+ ThreadUtils.runOnMainThread {
|
|
|
+ val clickStart = starViews.getOrNull(userTag.starCount - 1)
|
|
|
+ clickStart?.performClick()
|
|
|
+ binding.etContent.setText(userTag.daily)
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private fun selectStar(count: Int) {
|
|
@@ -205,29 +196,4 @@ 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)
|
|
|
-
|
|
|
- }
|
|
|
}
|