From 82d18556bf84dc2de7aa00d3c049c9965e5d3f94 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 17 Aug 2017 21:54:30 +0200 Subject: [PATCH] change the default lastUsedCaldavCalendar at creating events --- .../calendar/dialogs/SelectCalendarsDialog.kt | 4 ++-- .../kotlin/com/simplemobiletools/calendar/helpers/Config.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt index 374f4e8ce..95d984372 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt @@ -61,14 +61,14 @@ class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) : } private fun confirmSelection() { - val calendarIDs = ArrayList() + val calendarIDs = ArrayList() val childCnt = view.dialog_select_calendars_holder.childCount for (i in 0..childCnt) { val child = view.dialog_select_calendars_holder.getChildAt(i) if (child is RelativeLayout) { val check = child.getChildAt(0) if (check is SwitchCompat && check.isChecked) { - calendarIDs.add(check.tag as Long) + calendarIDs.add(check.tag as Int) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt index d34e0f259..8b55d0fc5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt @@ -79,7 +79,7 @@ class Config(context: Context) : BaseConfig(context) { set(calendarIDs) = prefs.edit().putString(CALDAV_SYNCED_CALENDAR_IDS, calendarIDs).apply() var lastUsedCaldavCalendar: Int - get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, 1) + get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, getCalendarIdsAsList().first().toInt()) set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply() fun getCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList