diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index ad6fa2e1b..2ab0e4113 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -231,7 +231,7 @@ fun Context.launchNewEventIntent(startNewTask: Boolean = false, today: Boolean = } } -fun Context.getCalDAVCalendars(): List { +fun Context.getCalDAVCalendars(ids: String = ""): List { val calendars = ArrayList() if (!hasCalendarPermission()) { return calendars @@ -244,10 +244,11 @@ fun Context.getCalDAVCalendars(): List { CalendarContract.Calendars.ACCOUNT_NAME, CalendarContract.Calendars.OWNER_ACCOUNT, CalendarContract.Calendars.CALENDAR_COLOR) + val selection = if (ids.trim().isNotEmpty()) "${CalendarContract.Calendars._ID} IN ($ids)" else null var cursor: Cursor? = null try { - cursor = contentResolver.query(uri, projection, null, null, null) + cursor = contentResolver.query(uri, projection, selection, null, null) while (cursor.moveToNext()) { val id = cursor.getLongValue(CalendarContract.Calendars._ID) val displayName = cursor.getStringValue(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME)