对采样列表、制作类别菜品重量进行格式化保留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.databinding.ListItemDishBinding
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
import com.shuwei.dish.match.utils.ext.visible
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class DishShowAdapter(list: MutableList<FoodRecord>) :
|
class DishShowAdapter(list: MutableList<FoodRecord>) :
|
||||||
BaseQuickAdapter<FoodRecord, DishShowAdapter.VH>(list) {
|
BaseQuickAdapter<FoodRecord, DishShowAdapter.VH>(list) {
|
||||||
@@ -43,8 +44,8 @@ class DishShowAdapter(list: MutableList<FoodRecord>) :
|
|||||||
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
||||||
tvDishCount.visible()
|
tvDishCount.visible()
|
||||||
tvDishCount.text =
|
tvDishCount.text =
|
||||||
"累计统计:${totalWeight / 1000.0F}kg(${item.count}次)"
|
"累计统计:${df.format(totalWeight / 1000.0F)}kg(${item.count}次)"
|
||||||
tvShowState.text = "${(item.foodWeight ?: 0.toDouble()) / 1000.0F}kg"
|
tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg"
|
||||||
} else {
|
} else {
|
||||||
tvDishName.setTextColor(
|
tvDishName.setTextColor(
|
||||||
ContextCompat.getColor(holder.itemView.context, R.color.black999)
|
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.databinding.ListItemDishBinding
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
import com.shuwei.dish.match.utils.ext.visible
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class SamplingAdapter(list: MutableList<FoodRecord>) :
|
class SamplingAdapter(list: MutableList<FoodRecord>) :
|
||||||
BaseQuickAdapter<FoodRecord, SamplingAdapter.VH>(list) {
|
BaseQuickAdapter<FoodRecord, SamplingAdapter.VH>(list) {
|
||||||
@@ -43,10 +44,11 @@ class SamplingAdapter(list: MutableList<FoodRecord>) :
|
|||||||
tvShowState.text = "烹饪中"
|
tvShowState.text = "烹饪中"
|
||||||
} else {
|
} else {
|
||||||
val useWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight ?: 0.toDouble())
|
val useWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight ?: 0.toDouble())
|
||||||
tvDishCount.text = "累计统计:${useWeight / 1000.0F}kg(${item.count}次)"
|
tvDishCount.text = "累计统计:${df.format(useWeight / 1000.0F)}kg(${item.count}次)"
|
||||||
tvShowState.text = "${(item.foodWeight ?: 0.toDouble()) / 1000.0F}kg"
|
tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val df = DecimalFormat("0.000")
|
||||||
}
|
}
|
||||||
@@ -196,8 +196,9 @@ class DishSamplingActivity : BaseActivity() {
|
|||||||
toast("请选择主辅材类型")
|
toast("请选择主辅材类型")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
if (tempDishEntity!!.useWeight == null) {
|
val realWeight = tempDishEntity!!.useWeight ?: 0.0
|
||||||
toast("请将食材放在称上称重")
|
if (realWeight < 0.toDouble()) {
|
||||||
|
toast("食材用量需要大于0")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
tempDishEntity!!.apply {
|
tempDishEntity!!.apply {
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class HomeActivity : BaseActivity() {
|
|||||||
// appViewModel.clearAllSeasoning(){}
|
// appViewModel.clearAllSeasoning(){}
|
||||||
|
|
||||||
|
|
||||||
binding.btnDeviceConfig.setOnClickListener {
|
// binding.btnDeviceConfig.setOnClickListener {
|
||||||
startActivity<SubmitFoodActivity>{}
|
// startActivity<SubmitFoodActivity>{}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initRecyclerView() {
|
private fun initRecyclerView() {
|
||||||
|
|||||||
Reference in New Issue
Block a user