LunaEvent: allow quantity of 0

This is helpful for storing an index
This commit is contained in:
2025-11-12 22:42:52 +01:00
parent 4492b36b23
commit 0a8ca7f9d1
2 changed files with 3 additions and 3 deletions

View File

@@ -45,9 +45,9 @@ class LunaEvent: Comparable<LunaEvent> {
jo.put("type", value)
}
var quantity: Int
get() = jo.optInt("quantity")
get() = jo.optInt("quantity", -1)
set(value) {
if (value > 0)
if (value >= 0)
jo.put("quantity", value)
}
var notes: String

View File

@@ -62,7 +62,7 @@ class NumericUtils (val context: Context) {
fun formatEventQuantity(event: LunaEvent): String {
val formatted = StringBuilder()
if (event.quantity > 0) {
if (event.quantity >= 0) {
formatted.append(when (event.type) {
LunaEvent.TYPE_TEMPERATURE ->
(event.quantity / 10.0f).toString()