From 5b42f5adf358042c2f18f1a32b4b63efbec79da5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 7 Aug 2019 18:12:56 +0200 Subject: [PATCH] fix #951, fix some glitch related to setting a default --- .../calendar/pro/activities/EventActivity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 48aec00bb..9b6baf9df 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -80,6 +80,7 @@ class EventActivity : SimpleActivity() { private var mAttendeeAutoCompleteViews = ArrayList() private var mAvailableContacts = ArrayList() private var mSelectedContacts = ArrayList() + private var mStoredEventTypes = ArrayList() private lateinit var mAttendeePlaceholder: Drawable private lateinit var mEventStartDateTime: DateTime @@ -103,13 +104,14 @@ class EventActivity : SimpleActivity() { val eventId = intent.getLongExtra(EVENT_ID, 0L) ensureBackgroundThread { + mStoredEventTypes = eventTypesDB.getEventTypes().toMutableList() as ArrayList val event = eventsDB.getEventWithId(eventId) if (eventId != 0L && event == null) { finish() return@ensureBackgroundThread } - val localEventType = eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) + val localEventType = mStoredEventTypes.firstOrNull { it.id == config.lastUsedLocalEventTypeId } runOnUiThread { gotEvent(savedInstanceState, localEventType, event) } @@ -342,6 +344,10 @@ class EventActivity : SimpleActivity() { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) event_title.requestFocus() updateActionBarTitle(getString(R.string.new_event)) + if (config.defaultEventTypeId != -1L) { + config.lastUsedCaldavCalendarId = mStoredEventTypes.firstOrNull { it.id == config.defaultEventTypeId }?.caldavCalendarId ?: 0 + } + val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId) mEventCalendarId = if (isLastCaldavCalendarOK) config.lastUsedCaldavCalendarId else STORED_LOCALLY_ONLY