重量显示优化
This commit is contained in:
@@ -33,6 +33,8 @@ import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
|
||||
import com.shuwei.dish.match.utils.ext.appendText
|
||||
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
||||
import com.shuwei.dish.match.utils.ext.dp
|
||||
import com.shuwei.dish.match.utils.ext.roundedDecimalPlace
|
||||
import com.shuwei.dish.match.utils.ext.roundedOneDecimalPlace
|
||||
import com.shuwei.dish.match.utils.ext.toJsonString
|
||||
import com.shuwei.dish.match.utils.ext.toObject
|
||||
import com.shuwei.dish.match.utils.ext.toast
|
||||
@@ -229,7 +231,7 @@ class BottomDialog2(
|
||||
var topWeight = "$weight"
|
||||
var bottomUnit = "克"
|
||||
if (weight >= 1000) {
|
||||
topWeight = "$weight"
|
||||
topWeight = "${(weight/1000).roundedDecimalPlace(3)}"
|
||||
bottomUnit = "千克"
|
||||
}
|
||||
return buildSpannableString {
|
||||
|
||||
@@ -175,7 +175,9 @@ fun View.clickWithDebounce(delay: Long = 300, action: () -> Unit) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Double.roundedDecimalPlace(num: Int): Double {
|
||||
return BigDecimal(this).setScale(num, RoundingMode.HALF_UP).toDouble()
|
||||
}
|
||||
fun Double.roundedOneDecimalPlace(): Double {
|
||||
return BigDecimal(this).setScale(1, RoundingMode.HALF_UP).toDouble()
|
||||
return this.roundedDecimalPlace(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user