LunaEvent: reorganize event text getters

Use method names that better reflect
the use of the returned text.
This commit is contained in:
2025-12-12 14:59:00 +01:00
parent dc0cd6353c
commit f5bd345e23
3 changed files with 23 additions and 32 deletions

View File

@@ -12,7 +12,6 @@ import java.util.Date
* release, it is simply ignored by previous ones).
*/
class LunaEvent: Comparable<LunaEvent> {
enum class Type {
BABY_BOTTLE,
FOOD,
@@ -100,24 +99,16 @@ class LunaEvent: Comparable<LunaEvent> {
this.quantity = quantity
}
fun getStartTime(): Long {
return time
fun getHeaderEmoji(context: Context): String {
return getHeaderEmoji(context, type)
}
fun getEndTime(): Long {
return if (type == TYPE_SLEEP) {
time + quantity
} else {
time
}
fun getDialogTitle(context: Context): String {
return getDialogTitle(context, type)
}
fun getTypeEmoji(context: Context): String {
return getTypeEmoji(context, type)
}
fun getTypeDescription(context: Context): String {
return getTypeDescription(context, type)
fun getRowItemTitle(context: Context): String {
return getPopupItemTitle(context, type).split(" ", limit = 2).last() // remove emoji
}
fun getDialogMessage(context: Context): String {
@@ -137,7 +128,7 @@ class LunaEvent: Comparable<LunaEvent> {
}
companion object {
fun getTypeEmoji(context: Context, type: Type): String {
fun getHeaderEmoji(context: Context, type: Type): String {
return context.getString(
when (type) {
Type.BABY_BOTTLE -> R.string.event_bottle_type
@@ -177,7 +168,7 @@ class LunaEvent: Comparable<LunaEvent> {
)
}
fun getTypeDescription(context: Context, type: Type): String {
fun getDialogTitle(context: Context, type: Type): String {
return context.getString(
when (type) {
Type.BABY_BOTTLE -> R.string.event_bottle_desc