diff --git a/app/src/main/java/com/shuwei/dish/match/adapter/DishShowAdapter.kt b/app/src/main/java/com/shuwei/dish/match/adapter/DishShowAdapter.kt index 62df657..7fd7dab 100644 --- a/app/src/main/java/com/shuwei/dish/match/adapter/DishShowAdapter.kt +++ b/app/src/main/java/com/shuwei/dish/match/adapter/DishShowAdapter.kt @@ -11,6 +11,7 @@ import com.shuwei.dish.match.entity.FoodRecord import com.shuwei.dish.match.databinding.ListItemDishBinding import com.shuwei.dish.match.utils.ext.gone import com.shuwei.dish.match.utils.ext.visible +import java.text.DecimalFormat class DishShowAdapter(list: MutableList) : BaseQuickAdapter(list) { @@ -43,8 +44,8 @@ class DishShowAdapter(list: MutableList) : clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners) tvDishCount.visible() tvDishCount.text = - "累计统计:${totalWeight / 1000.0F}kg(${item.count}次)" - tvShowState.text = "${(item.foodWeight ?: 0.toDouble()) / 1000.0F}kg" + "累计统计:${df.format(totalWeight / 1000.0F)}kg(${item.count}次)" + tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg" } else { tvDishName.setTextColor( ContextCompat.getColor(holder.itemView.context, R.color.black999) @@ -56,4 +57,6 @@ class DishShowAdapter(list: MutableList) : } } + val df = DecimalFormat("0.000") + } \ No newline at end of file diff --git a/app/src/main/java/com/shuwei/dish/match/adapter/SamplingAdapter.kt b/app/src/main/java/com/shuwei/dish/match/adapter/SamplingAdapter.kt index ce5aef9..3ae27b6 100644 --- a/app/src/main/java/com/shuwei/dish/match/adapter/SamplingAdapter.kt +++ b/app/src/main/java/com/shuwei/dish/match/adapter/SamplingAdapter.kt @@ -11,6 +11,7 @@ import com.shuwei.dish.match.entity.FoodRecord import com.shuwei.dish.match.databinding.ListItemDishBinding import com.shuwei.dish.match.utils.ext.gone import com.shuwei.dish.match.utils.ext.visible +import java.text.DecimalFormat class SamplingAdapter(list: MutableList) : BaseQuickAdapter(list) { @@ -43,10 +44,11 @@ class SamplingAdapter(list: MutableList) : tvShowState.text = "烹饪中" } else { val useWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight ?: 0.toDouble()) - tvDishCount.text = "累计统计:${useWeight / 1000.0F}kg(${item.count}次)" - tvShowState.text = "${(item.foodWeight ?: 0.toDouble()) / 1000.0F}kg" + tvDishCount.text = "累计统计:${df.format(useWeight / 1000.0F)}kg(${item.count}次)" + tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg" } } } + val df = DecimalFormat("0.000") } \ No newline at end of file diff --git a/app/src/main/java/com/shuwei/dish/match/ui/DishSamplingActivity.kt b/app/src/main/java/com/shuwei/dish/match/ui/DishSamplingActivity.kt index 9ab38ce..a3a78a4 100644 --- a/app/src/main/java/com/shuwei/dish/match/ui/DishSamplingActivity.kt +++ b/app/src/main/java/com/shuwei/dish/match/ui/DishSamplingActivity.kt @@ -196,8 +196,9 @@ class DishSamplingActivity : BaseActivity() { toast("请选择主辅材类型") return@setOnClickListener } - if (tempDishEntity!!.useWeight == null) { - toast("请将食材放在称上称重") + val realWeight = tempDishEntity!!.useWeight ?: 0.0 + if (realWeight < 0.toDouble()) { + toast("食材用量需要大于0") return@setOnClickListener } tempDishEntity!!.apply { diff --git a/app/src/main/java/com/shuwei/dish/match/ui/HomeActivity.kt b/app/src/main/java/com/shuwei/dish/match/ui/HomeActivity.kt index 780910d..fda3431 100644 --- a/app/src/main/java/com/shuwei/dish/match/ui/HomeActivity.kt +++ b/app/src/main/java/com/shuwei/dish/match/ui/HomeActivity.kt @@ -74,9 +74,9 @@ class HomeActivity : BaseActivity() { // appViewModel.clearAllSeasoning(){} - binding.btnDeviceConfig.setOnClickListener { - startActivity{} - } +// binding.btnDeviceConfig.setOnClickListener { +// startActivity{} +// } } private fun initRecyclerView() {