对采样列表、制作类别菜品重量进行格式化保留3位小数,采样添加食材增加非零判断
This commit is contained in:
@@ -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<FoodRecord>) :
|
||||
BaseQuickAdapter<FoodRecord, DishShowAdapter.VH>(list) {
|
||||
@@ -43,8 +44,8 @@ class DishShowAdapter(list: MutableList<FoodRecord>) :
|
||||
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<FoodRecord>) :
|
||||
}
|
||||
}
|
||||
|
||||
val df = DecimalFormat("0.000")
|
||||
|
||||
}
|
||||
@@ -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<FoodRecord>) :
|
||||
BaseQuickAdapter<FoodRecord, SamplingAdapter.VH>(list) {
|
||||
@@ -43,10 +44,11 @@ class SamplingAdapter(list: MutableList<FoodRecord>) :
|
||||
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")
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -74,9 +74,9 @@ class HomeActivity : BaseActivity() {
|
||||
// appViewModel.clearAllSeasoning(){}
|
||||
|
||||
|
||||
binding.btnDeviceConfig.setOnClickListener {
|
||||
startActivity<SubmitFoodActivity>{}
|
||||
}
|
||||
// binding.btnDeviceConfig.setOnClickListener {
|
||||
// startActivity<SubmitFoodActivity>{}
|
||||
// }
|
||||
}
|
||||
|
||||
private fun initRecyclerView() {
|
||||
|
||||
Reference in New Issue
Block a user