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