forked from penguin86/luna-tracker
LunaEvent: use enum class for event types
This helps to have compile errors when some case it not handled while adding a new type. The enum class can also be interated over to create a complete drop down list.
This commit is contained in:
@@ -297,7 +297,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
|
|
||||||
val tempSlider = dialogView.findViewById<Slider>(R.id.dialog_temperature_value)
|
val tempSlider = dialogView.findViewById<Slider>(R.id.dialog_temperature_value)
|
||||||
val range = NumericUtils(this).getValidEventQuantityRange(LunaEvent.TYPE_TEMPERATURE)!!
|
val range = NumericUtils(this).getValidEventQuantityRange(LunaEvent.Type.TEMPERATURE)!!
|
||||||
tempSlider.valueFrom = range.first.toFloat()
|
tempSlider.valueFrom = range.first.toFloat()
|
||||||
tempSlider.valueTo = range.second.toFloat()
|
tempSlider.valueTo = range.second.toFloat()
|
||||||
tempSlider.value = if (event.quantity == 0) {
|
tempSlider.value = if (event.quantity == 0) {
|
||||||
@@ -537,7 +537,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun askNotes(event: LunaEvent, showTime: Boolean, onPositive: () -> Unit) {
|
fun askNotes(event: LunaEvent, showTime: Boolean, onPositive: () -> Unit) {
|
||||||
val useQuantity = (event.type != LunaEvent.TYPE_NOTE && event.type != LunaEvent.TYPE_CUSTOM)
|
val useQuantity = (event.type != LunaEvent.Type.NOTE)
|
||||||
|
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_edit_notes, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_edit_notes, null)
|
||||||
@@ -759,7 +759,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val updateValues = {
|
val updateValues = {
|
||||||
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
||||||
notesTextView.text = event.notes
|
notesTextView.text = event.notes
|
||||||
if (event.type == LunaEvent.TYPE_SLEEP && event.quantity > 0) {
|
if (event.type == LunaEvent.Type.SLEEP && event.quantity > 0) {
|
||||||
dateEndTextView.text = DateUtils.formatDateTime(event.time + event.quantity)
|
dateEndTextView.text = DateUtils.formatDateTime(event.time + event.quantity)
|
||||||
dateEndTextView.visibility = View.VISIBLE
|
dateEndTextView.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
@@ -781,22 +781,28 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
quantityTextView.setOnClickListener {
|
quantityTextView.setOnClickListener {
|
||||||
when (event.type) {
|
when (event.type) {
|
||||||
LunaEvent.TYPE_BABY_BOTTLE -> askBabyBottleContent(event, false, updateValues)
|
LunaEvent.Type.BABY_BOTTLE -> askBabyBottleContent(event, false, updateValues)
|
||||||
LunaEvent.TYPE_WEIGHT -> askWeightValue(event, false, updateValues)
|
LunaEvent.Type.WEIGHT -> askWeightValue(event, false, updateValues)
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_POO,
|
LunaEvent.Type.DIAPERCHANGE_POO,
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_PEE,
|
LunaEvent.Type.DIAPERCHANGE_PEE,
|
||||||
LunaEvent.TYPE_PUKE -> askAmountValue(event, false, updateValues)
|
LunaEvent.Type.PUKE -> askAmountValue(event, false, updateValues)
|
||||||
LunaEvent.TYPE_TEMPERATURE -> askTemperatureValue(event, false, updateValues)
|
LunaEvent.Type.TEMPERATURE -> askTemperatureValue(event, false, updateValues)
|
||||||
LunaEvent.TYPE_NOTE -> askNotes(event, false, updateValues)
|
LunaEvent.Type.NOTE -> askNotes(event, false, updateValues)
|
||||||
LunaEvent.TYPE_SLEEP -> askSleepValue(event, updateValues)
|
LunaEvent.Type.SLEEP -> askSleepValue(event, updateValues)
|
||||||
|
else -> {
|
||||||
|
Log.w(TAG, "Unexpected type: ${event.type}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notesTextView.setOnClickListener {
|
notesTextView.setOnClickListener {
|
||||||
when (event.type) {
|
when (event.type) {
|
||||||
LunaEvent.TYPE_FOOD,
|
LunaEvent.Type.FOOD,
|
||||||
LunaEvent.TYPE_MEDICINE,
|
LunaEvent.Type.MEDICINE,
|
||||||
LunaEvent.TYPE_NOTE -> askNotes(event, false, updateValues)
|
LunaEvent.Type.NOTE -> askNotes(event, false, updateValues)
|
||||||
|
else -> {
|
||||||
|
Log.w(TAG, "Unexpected type: ${event.type}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,12 +54,11 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
|
|||||||
// Contents
|
// Contents
|
||||||
holder.type.text = item.getTypeEmoji(context)
|
holder.type.text = item.getTypeEmoji(context)
|
||||||
holder.description.text = when (item.type) {
|
holder.description.text = when (item.type) {
|
||||||
LunaEvent.TYPE_MEDICINE -> item.notes
|
LunaEvent.Type.MEDICINE -> item.notes
|
||||||
LunaEvent.TYPE_NOTE -> item.notes
|
LunaEvent.Type.NOTE -> item.notes
|
||||||
LunaEvent.TYPE_CUSTOM -> item.notes
|
|
||||||
else -> item.getTypeDescription(context)
|
else -> item.getTypeDescription(context)
|
||||||
}
|
}
|
||||||
val endTime = if (item.type == LunaEvent.TYPE_SLEEP) {
|
val endTime = if (item.type == LunaEvent.Type.SLEEP) {
|
||||||
item.quantity + item.time
|
item.quantity + item.time
|
||||||
} else {
|
} else {
|
||||||
item.time
|
item.time
|
||||||
@@ -68,7 +67,7 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
|
|||||||
var quantityText = numericUtils.formatEventQuantity(item)
|
var quantityText = numericUtils.formatEventQuantity(item)
|
||||||
|
|
||||||
// if the event is weight, show difference with the last one
|
// if the event is weight, show difference with the last one
|
||||||
if (item.type == LunaEvent.TYPE_WEIGHT) {
|
if (item.type == LunaEvent.Type.WEIGHT) {
|
||||||
val lastWeight = getPreviousWeightEvent(position)
|
val lastWeight = getPreviousWeightEvent(position)
|
||||||
if (lastWeight != null) {
|
if (lastWeight != null) {
|
||||||
val differenceInWeight = item.quantity - lastWeight.quantity
|
val differenceInWeight = item.quantity - lastWeight.quantity
|
||||||
@@ -99,7 +98,7 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
|
|||||||
return null
|
return null
|
||||||
for (pos in startFromPosition + 1 until items.size) {
|
for (pos in startFromPosition + 1 until items.size) {
|
||||||
val item = items.get(pos)
|
val item = items.get(pos)
|
||||||
if (item.type != LunaEvent.TYPE_WEIGHT)
|
if (item.type != LunaEvent.Type.WEIGHT)
|
||||||
continue
|
continue
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,74 @@ import java.util.Date
|
|||||||
*/
|
*/
|
||||||
class LunaEvent: Comparable<LunaEvent> {
|
class LunaEvent: Comparable<LunaEvent> {
|
||||||
|
|
||||||
|
enum class Type {
|
||||||
|
BABY_BOTTLE,
|
||||||
|
FOOD,
|
||||||
|
BREASTFEEDING_LEFT_NIPPLE,
|
||||||
|
BREASTFEEDING_BOTH_NIPPLE,
|
||||||
|
BREASTFEEDING_RIGHT_NIPPLE,
|
||||||
|
DIAPERCHANGE_POO,
|
||||||
|
DIAPERCHANGE_PEE,
|
||||||
|
SLEEP,
|
||||||
|
WEIGHT,
|
||||||
|
MEDICINE,
|
||||||
|
ENEMA,
|
||||||
|
NOTE,
|
||||||
|
COLIC,
|
||||||
|
TEMPERATURE,
|
||||||
|
PUKE,
|
||||||
|
BATH,
|
||||||
|
UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TYPE_BABY_BOTTLE = "BABY_BOTTLE"
|
fun getTypeEmoji(context: Context, type: Type): String {
|
||||||
const val TYPE_WEIGHT = "WEIGHT"
|
return context.getString(
|
||||||
const val TYPE_BREASTFEEDING_LEFT_NIPPLE = "BREASTFEEDING_LEFT_NIPPLE"
|
when (type) {
|
||||||
const val TYPE_BREASTFEEDING_BOTH_NIPPLE = "BREASTFEEDING_BOTH_NIPPLE"
|
Type.BABY_BOTTLE -> R.string.event_bottle_type
|
||||||
const val TYPE_BREASTFEEDING_RIGHT_NIPPLE = "BREASTFEEDING_RIGHT_NIPPLE"
|
Type.WEIGHT -> R.string.event_weight_type
|
||||||
const val TYPE_DIAPERCHANGE_POO = "DIAPERCHANGE_POO"
|
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
||||||
const val TYPE_DIAPERCHANGE_PEE = "DIAPERCHANGE_PEE"
|
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
||||||
const val TYPE_MEDICINE = "MEDICINE"
|
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
||||||
const val TYPE_ENEMA = "ENEMA"
|
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
||||||
const val TYPE_NOTE = "NOTE"
|
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
||||||
const val TYPE_CUSTOM = "CUSTOM"
|
Type.MEDICINE -> R.string.event_medicine_type
|
||||||
const val TYPE_COLIC = "COLIC"
|
Type.ENEMA -> R.string.event_enema_type
|
||||||
const val TYPE_TEMPERATURE = "TEMPERATURE"
|
Type.NOTE -> R.string.event_note_type
|
||||||
const val TYPE_FOOD = "FOOD"
|
Type.TEMPERATURE -> R.string.event_temperature_type
|
||||||
const val TYPE_PUKE = "PUKE"
|
Type.COLIC -> R.string.event_colic_type
|
||||||
const val TYPE_BATH = "BATH"
|
Type.FOOD -> R.string.event_food_type
|
||||||
const val TYPE_SLEEP = "SLEEP"
|
Type.PUKE -> R.string.event_puke_type
|
||||||
|
Type.BATH -> R.string.event_bath_type
|
||||||
|
Type.SLEEP -> R.string.event_sleep_type
|
||||||
|
Type.UNKNOWN -> R.string.event_unknown_type
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTypeDescription(context: Context, type: Type): String {
|
||||||
|
return context.getString(
|
||||||
|
when (type) {
|
||||||
|
Type.BABY_BOTTLE -> R.string.event_bottle_desc
|
||||||
|
Type.WEIGHT -> R.string.event_weight_desc
|
||||||
|
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
||||||
|
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
||||||
|
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
||||||
|
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
||||||
|
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
||||||
|
Type.MEDICINE -> R.string.event_medicine_desc
|
||||||
|
Type.ENEMA -> R.string.event_enema_desc
|
||||||
|
Type.NOTE -> R.string.event_note_desc
|
||||||
|
Type.TEMPERATURE -> R.string.event_temperature_desc
|
||||||
|
Type.COLIC -> R.string.event_colic_desc
|
||||||
|
Type.FOOD -> R.string.event_food_desc
|
||||||
|
Type.PUKE -> R.string.event_puke_desc
|
||||||
|
Type.BATH -> R.string.event_bath_desc
|
||||||
|
Type.SLEEP -> R.string.event_sleep_desc
|
||||||
|
Type.UNKNOWN -> R.string.event_unknown_desc
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val jo: JSONObject
|
private val jo: JSONObject
|
||||||
@@ -40,10 +90,16 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
set(value) {
|
set(value) {
|
||||||
jo.put("time", value)
|
jo.put("time", value)
|
||||||
}
|
}
|
||||||
var type: String
|
var type: Type
|
||||||
get(): String = jo.getString("type")
|
get(): Type {
|
||||||
|
return try {
|
||||||
|
Type.valueOf(jo.getString("type"))
|
||||||
|
} catch (_: Exception) {
|
||||||
|
Type.UNKNOWN
|
||||||
|
}
|
||||||
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
jo.put("type", value)
|
jo.put("type", value.name)
|
||||||
}
|
}
|
||||||
var quantity: Int
|
var quantity: Int
|
||||||
get() = jo.optInt("quantity")
|
get() = jo.optInt("quantity")
|
||||||
@@ -81,13 +137,13 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
this.signature = event.signature
|
this.signature = event.signature
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(type: String) {
|
constructor(type: Type) {
|
||||||
this.jo = JSONObject()
|
this.jo = JSONObject()
|
||||||
this.time = System.currentTimeMillis() / 1000
|
this.time = System.currentTimeMillis() / 1000
|
||||||
this.type = type
|
this.type = type
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(type: String, quantity: Int) {
|
constructor(type: Type, quantity: Int) {
|
||||||
this.jo = JSONObject()
|
this.jo = JSONObject()
|
||||||
this.time = System.currentTimeMillis() / 1000
|
this.time = System.currentTimeMillis() / 1000
|
||||||
this.type = type
|
this.type = type
|
||||||
@@ -95,64 +151,24 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getTypeEmoji(context: Context): String {
|
fun getTypeEmoji(context: Context): String {
|
||||||
return context.getString(
|
return getTypeEmoji(context, type)
|
||||||
when (type) {
|
|
||||||
TYPE_BABY_BOTTLE -> R.string.event_bottle_type
|
|
||||||
TYPE_WEIGHT -> R.string.event_weight_type
|
|
||||||
TYPE_BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
|
||||||
TYPE_BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
|
||||||
TYPE_BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
|
||||||
TYPE_DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
|
||||||
TYPE_DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
|
||||||
TYPE_MEDICINE -> R.string.event_medicine_type
|
|
||||||
TYPE_ENEMA -> R.string.event_enema_type
|
|
||||||
TYPE_NOTE -> R.string.event_note_type
|
|
||||||
TYPE_TEMPERATURE -> R.string.event_temperature_type
|
|
||||||
TYPE_COLIC -> R.string.event_colic_type
|
|
||||||
TYPE_FOOD -> R.string.event_food_type
|
|
||||||
TYPE_PUKE -> R.string.event_puke_type
|
|
||||||
TYPE_BATH -> R.string.event_bath_type
|
|
||||||
TYPE_SLEEP -> R.string.event_sleep_type
|
|
||||||
else -> R.string.event_unknown_type
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTypeDescription(context: Context): String {
|
fun getTypeDescription(context: Context): String {
|
||||||
return context.getString(
|
return getTypeDescription(context, type)
|
||||||
when (type) {
|
|
||||||
TYPE_BABY_BOTTLE -> R.string.event_bottle_desc
|
|
||||||
TYPE_WEIGHT -> R.string.event_weight_desc
|
|
||||||
TYPE_BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
|
||||||
TYPE_BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
|
||||||
TYPE_BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
|
||||||
TYPE_DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
|
||||||
TYPE_DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
|
||||||
TYPE_MEDICINE -> R.string.event_medicine_desc
|
|
||||||
TYPE_ENEMA -> R.string.event_enema_desc
|
|
||||||
TYPE_NOTE -> R.string.event_note_desc
|
|
||||||
TYPE_TEMPERATURE -> R.string.event_temperature_desc
|
|
||||||
TYPE_COLIC -> R.string.event_colic_desc
|
|
||||||
TYPE_FOOD -> R.string.event_food_desc
|
|
||||||
TYPE_PUKE -> R.string.event_puke_desc
|
|
||||||
TYPE_BATH -> R.string.event_bath_desc
|
|
||||||
TYPE_SLEEP -> R.string.event_sleep_desc
|
|
||||||
else -> R.string.event_unknown_desc
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDialogMessage(context: Context): String? {
|
fun getDialogMessage(context: Context): String? {
|
||||||
return context.getString(
|
return context.getString(
|
||||||
when(type) {
|
when(type) {
|
||||||
TYPE_BABY_BOTTLE -> R.string.log_bottle_dialog_description
|
Type.BABY_BOTTLE -> R.string.log_bottle_dialog_description
|
||||||
TYPE_MEDICINE -> R.string.log_medicine_dialog_description
|
Type.MEDICINE -> R.string.log_medicine_dialog_description
|
||||||
TYPE_TEMPERATURE -> R.string.log_temperature_dialog_description
|
Type.TEMPERATURE -> R.string.log_temperature_dialog_description
|
||||||
TYPE_DIAPERCHANGE_POO,
|
Type.DIAPERCHANGE_POO,
|
||||||
TYPE_DIAPERCHANGE_PEE,
|
Type.DIAPERCHANGE_PEE,
|
||||||
TYPE_PUKE -> R.string.log_amount_dialog_description
|
Type.PUKE -> R.string.log_amount_dialog_description
|
||||||
TYPE_WEIGHT -> R.string.log_weight_dialog_description
|
Type.WEIGHT -> R.string.log_weight_dialog_description
|
||||||
TYPE_SLEEP -> R.string.log_sleep_dialog_description
|
Type.SLEEP -> R.string.log_sleep_dialog_description
|
||||||
else -> R.string.log_unknown_dialog_description
|
else -> R.string.log_unknown_dialog_description
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -66,38 +66,38 @@ class NumericUtils (val context: Context) {
|
|||||||
return formatEventQuantity(event.type, event.quantity)
|
return formatEventQuantity(event.type, event.quantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun formatEventQuantity(type: String, quantity: Int): String {
|
fun formatEventQuantity(type: LunaEvent.Type, quantity: Int): String {
|
||||||
val formatted = StringBuilder()
|
val formatted = StringBuilder()
|
||||||
if (quantity > 0) {
|
if (quantity > 0) {
|
||||||
formatted.append(when (type) {
|
formatted.append(when (type) {
|
||||||
LunaEvent.TYPE_TEMPERATURE ->
|
LunaEvent.Type.TEMPERATURE ->
|
||||||
(quantity / 10.0f).toString()
|
(quantity / 10.0f).toString()
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_POO,
|
LunaEvent.Type.DIAPERCHANGE_POO,
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_PEE,
|
LunaEvent.Type.DIAPERCHANGE_PEE,
|
||||||
LunaEvent.TYPE_PUKE -> {
|
LunaEvent.Type.PUKE -> {
|
||||||
val array = context.resources.getStringArray(R.array.AmountLabels)
|
val array = context.resources.getStringArray(R.array.AmountLabels)
|
||||||
return array.getOrElse(quantity) {
|
return array.getOrElse(quantity) {
|
||||||
Log.e("NumericUtils", "Invalid index $quantity")
|
Log.e("NumericUtils", "Invalid index $quantity")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LunaEvent.TYPE_SLEEP -> formatTimeDuration(context, quantity.toLong())
|
LunaEvent.Type.SLEEP -> formatTimeDuration(context, quantity.toLong())
|
||||||
else -> quantity
|
else -> quantity
|
||||||
})
|
})
|
||||||
|
|
||||||
formatted.append(" ")
|
formatted.append(" ")
|
||||||
formatted.append(
|
formatted.append(
|
||||||
when (type) {
|
when (type) {
|
||||||
LunaEvent.TYPE_BABY_BOTTLE -> measurement_unit_liquid_base
|
LunaEvent.Type.BABY_BOTTLE -> measurement_unit_liquid_base
|
||||||
LunaEvent.TYPE_WEIGHT -> measurement_unit_weight_base
|
LunaEvent.Type.WEIGHT -> measurement_unit_weight_base
|
||||||
LunaEvent.TYPE_MEDICINE -> measurement_unit_weight_tiny
|
LunaEvent.Type.MEDICINE -> measurement_unit_weight_tiny
|
||||||
LunaEvent.TYPE_TEMPERATURE -> measurement_unit_temperature_base
|
LunaEvent.Type.TEMPERATURE -> measurement_unit_temperature_base
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
formatted.append(when (type) {
|
formatted.append(when (type) {
|
||||||
LunaEvent.TYPE_SLEEP -> "💤" // baby is sleeping
|
LunaEvent.Type.SLEEP -> "💤" // baby is sleeping
|
||||||
else -> ""
|
else -> ""
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -108,9 +108,9 @@ class NumericUtils (val context: Context) {
|
|||||||
* Returns a valid quantity range for the event type.
|
* Returns a valid quantity range for the event type.
|
||||||
* @return min, max, normal
|
* @return min, max, normal
|
||||||
*/
|
*/
|
||||||
fun getValidEventQuantityRange(lunaEventType: String): Triple<Int, Int, Int>? {
|
fun getValidEventQuantityRange(lunaEventType: LunaEvent.Type): Triple<Int, Int, Int>? {
|
||||||
return when (lunaEventType) {
|
return when (lunaEventType) {
|
||||||
LunaEvent.TYPE_TEMPERATURE -> {
|
LunaEvent.Type.TEMPERATURE -> {
|
||||||
if (isMetricSystem())
|
if (isMetricSystem())
|
||||||
Triple(
|
Triple(
|
||||||
context.resources.getInteger(R.integer.human_body_temp_min_metric),
|
context.resources.getInteger(R.integer.human_body_temp_min_metric),
|
||||||
|
|||||||
Reference in New Issue
Block a user