properly select the synced calendar at event activity
This commit is contained in:
parent
6d74925a25
commit
41cc9009af
1 changed files with 7 additions and 5 deletions
|
@ -391,13 +391,13 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter {
|
val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter {
|
||||||
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id.toString())
|
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id.toString())
|
||||||
}
|
}
|
||||||
updateCurrentCalendarInfo(getCalendarWithId(calendars))
|
updateCurrentCalendarInfo(getCalendarWithId(calendars, getCalendarId()))
|
||||||
|
|
||||||
event_caldav_calendar_holder.setOnClickListener {
|
event_caldav_calendar_holder.setOnClickListener {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
SelectEventCalendarDialog(this, calendars, config.lastUsedCaldavCalendar) {
|
SelectEventCalendarDialog(this, calendars, getCalendarId()) {
|
||||||
config.lastUsedCaldavCalendar = it
|
config.lastUsedCaldavCalendar = it
|
||||||
updateCurrentCalendarInfo(getCalendarWithId(calendars))
|
updateCurrentCalendarInfo(getCalendarWithId(calendars, it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -405,8 +405,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCalendarWithId(calendars: List<CalDAVCalendar>): CalDAVCalendar? =
|
private fun getCalendarId() = if (mEvent.source == SOURCE_SIMPLE_CALENDAR) config.lastUsedCaldavCalendar else mEvent.getCalDAVCalendarId()
|
||||||
calendars.firstOrNull { it.id == config.lastUsedCaldavCalendar }
|
|
||||||
|
private fun getCalendarWithId(calendars: List<CalDAVCalendar>, calendarId: Int): CalDAVCalendar? =
|
||||||
|
calendars.firstOrNull { it.id == calendarId }
|
||||||
|
|
||||||
private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) {
|
private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) {
|
||||||
event_type_image.beVisibleIf(currentCalendar == null)
|
event_type_image.beVisibleIf(currentCalendar == null)
|
||||||
|
|
Loading…
Reference in a new issue