From 9bc7f9ac1166b94b15f0082451ce3b1a74500d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 2 Dec 2019 19:04:30 +0100 Subject: [PATCH] [UI/Event] Make use of default values in event manual dialog. --- .../ui/dialogs/event/EventManualV2Dialog.kt | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualV2Dialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualV2Dialog.kt index 1fea20ce..c8b9839c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualV2Dialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventManualV2Dialog.kt @@ -88,19 +88,12 @@ class EventManualV2Dialog( show() } + defaultType?.let { + event.type = it + } + event = editingEvent?.clone() ?: Event().also { event -> event.profileId = profileId - /*defaultDate?.let { - event.eventDate = it - b.date = it - } - defaultTime?.let { - event.startTime = it - b.time = it - } - defaultType?.let { - event.type = it - }*/ b.shareSwitch.isChecked = event.sharedBy != null } @@ -304,6 +297,16 @@ class EventManualV2Dialog( val dates = deferred.await() b.dateDropdown.clear().append(dates) + defaultDate?.let { + event.eventDate = it + if (b.dateDropdown.select(it) == null) + b.dateDropdown.select(TextInputDropDown.Item( + it.value.toLong(), + it.formattedString, + tag = it + )) + } + editingEvent?.eventDate?.let { b.dateDropdown.select(TextInputDropDown.Item( it.value.toLong(), @@ -441,6 +444,16 @@ class EventManualV2Dialog( b.teacherDropdown.deselect() } else { + defaultTime?.let { + event.startTime = it + if (b.timeDropdown.select(it) == null) + b.timeDropdown.select(TextInputDropDown.Item( + it.value.toLong(), + it.stringHM, + tag = it + )) + } + editingEvent?.let { b.timeDropdown.select(it.startTime?.value?.toLong()) }