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