1 Commits

Author SHA1 Message Date
cbba6b7a90 use creation dialog as edit dialog 2025-11-09 23:22:07 +01:00

View File

@@ -204,6 +204,7 @@ class MainActivity : AppCompatActivity() {
fun askBabyBottleContent(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) { fun askBabyBottleContent(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) {
val isNewEvent = (existingEvent != null) val isNewEvent = (existingEvent != null)
// Show number picker dialog
val event = if (existingEvent == null) { val event = if (existingEvent == null) {
LunaEvent(TYPE_BABY_BOTTLE) LunaEvent(TYPE_BABY_BOTTLE)
} else { } else {
@@ -312,14 +313,7 @@ class MainActivity : AppCompatActivity() {
alertDialog.show() alertDialog.show()
} }
fun askPukeValue(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) { fun askPukeValue() {
val isNewEvent = (existingEvent != null)
val event = if (existingEvent == null) {
LunaEvent(LunaEvent.TYPE_PUKE)
} else {
existingEvent
}
val d = AlertDialog.Builder(this) val d = AlertDialog.Builder(this)
val dialogView = layoutInflater.inflate(R.layout.puke_dialog, null) val dialogView = layoutInflater.inflate(R.layout.puke_dialog, null)
d.setTitle(R.string.log_puke_dialog_title) d.setTitle(R.string.log_puke_dialog_title)
@@ -331,11 +325,8 @@ class MainActivity : AppCompatActivity() {
spinner.setSelection(1) spinner.setSelection(1)
d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
event.quantity = spinner.selectedItemPosition val pos = spinner.selectedItemPosition
if (isNewEvent) { logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos))
logEvent(event)
}
onEnd?.invoke()
} }
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() } d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
val alertDialog = d.create() val alertDialog = d.create()
@@ -344,8 +335,9 @@ class MainActivity : AppCompatActivity() {
fun askNotes(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) { fun askNotes(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) {
val isNewEvent = (existingEvent != null) val isNewEvent = (existingEvent != null)
// Show number picker dialog
val event = if (existingEvent == null) { val event = if (existingEvent == null) {
LunaEvent(LunaEvent.TYPE_NOTE) LunaEvent(TYPE_BABY_BOTTLE)
} else { } else {
existingEvent existingEvent
} }
@@ -535,8 +527,8 @@ class MainActivity : AppCompatActivity() {
LunaEvent.TYPE_NOTE -> askNotes(event, { showEventDetailDialog(event) }) LunaEvent.TYPE_NOTE -> askNotes(event, { showEventDetailDialog(event) })
LunaEvent.TYPE_TEMPERATURE, LunaEvent.TYPE_TEMPERATURE,
LunaEvent.TYPE_COLIC, LunaEvent.TYPE_COLIC,
LunaEvent.TYPE_FOOD -> {} LunaEvent.TYPE_FOOD,
LunaEvent.TYPE_PUKE -> askPukeValue(event, { showEventDetailDialog(event) }) LunaEvent.TYPE_PUKE,
LunaEvent.TYPE_BATH, LunaEvent.TYPE_BATH,
LunaEvent.TYPE_CUSTOM -> {} LunaEvent.TYPE_CUSTOM -> {}
else -> {} else -> {}