change the default lastUsedCaldavCalendar at creating events

This commit is contained in:
tibbi 2017-08-17 21:54:30 +02:00
parent ed9b0caa7b
commit 82d18556bf
2 changed files with 3 additions and 3 deletions

View File

@ -61,14 +61,14 @@ class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) :
} }
private fun confirmSelection() { private fun confirmSelection() {
val calendarIDs = ArrayList<Long>() val calendarIDs = ArrayList<Int>()
val childCnt = view.dialog_select_calendars_holder.childCount val childCnt = view.dialog_select_calendars_holder.childCount
for (i in 0..childCnt) { for (i in 0..childCnt) {
val child = view.dialog_select_calendars_holder.getChildAt(i) val child = view.dialog_select_calendars_holder.getChildAt(i)
if (child is RelativeLayout) { if (child is RelativeLayout) {
val check = child.getChildAt(0) val check = child.getChildAt(0)
if (check is SwitchCompat && check.isChecked) { if (check is SwitchCompat && check.isChecked) {
calendarIDs.add(check.tag as Long) calendarIDs.add(check.tag as Int)
} }
} }
} }

View File

@ -79,7 +79,7 @@ class Config(context: Context) : BaseConfig(context) {
set(calendarIDs) = prefs.edit().putString(CALDAV_SYNCED_CALENDAR_IDS, calendarIDs).apply() set(calendarIDs) = prefs.edit().putString(CALDAV_SYNCED_CALENDAR_IDS, calendarIDs).apply()
var lastUsedCaldavCalendar: Int 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() set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply()
fun getCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String> fun getCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>