mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-08 07:58:51 +01:00
adding some code style updates to EventActivity
This commit is contained in:
parent
54787e42bd
commit
c4824419da
@ -231,6 +231,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
menu.findItem(R.id.share).isVisible = mEvent.id != null
|
menu.findItem(R.id.share).isVisible = mEvent.id != null
|
||||||
menu.findItem(R.id.duplicate).isVisible = mEvent.id != null
|
menu.findItem(R.id.duplicate).isVisible = mEvent.id != null
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMenuItemColors(menu)
|
updateMenuItemColors(menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -290,6 +291,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
mEventTypeId != mEvent.eventType) {
|
mEventTypeId != mEvent.eventType) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,8 +365,8 @@ class EventActivity : SimpleActivity() {
|
|||||||
mRepeatRule = getInt(REPEAT_RULE)
|
mRepeatRule = getInt(REPEAT_RULE)
|
||||||
mRepeatLimit = getLong(REPEAT_LIMIT)
|
mRepeatLimit = getLong(REPEAT_LIMIT)
|
||||||
|
|
||||||
mAttendees = Gson().fromJson<ArrayList<Attendee>>(getString(ATTENDEES), object : TypeToken<List<Attendee>>() {}.type)
|
val token = object : TypeToken<List<Attendee>>() {}.type
|
||||||
?: ArrayList()
|
mAttendees = Gson().fromJson<ArrayList<Attendee>>(getString(ATTENDEES), token) ?: ArrayList()
|
||||||
|
|
||||||
mEventTypeId = getLong(EVENT_TYPE_ID)
|
mEventTypeId = getLong(EVENT_TYPE_ID)
|
||||||
mEventCalendarId = getInt(EVENT_CALENDAR_ID)
|
mEventCalendarId = getInt(EVENT_CALENDAR_ID)
|
||||||
@ -396,7 +398,6 @@ class EventActivity : SimpleActivity() {
|
|||||||
updateAttendeesVisibility()
|
updateAttendeesVisibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun setupEditEvent() {
|
private fun setupEditEvent() {
|
||||||
val realStart = if (mEventOccurrenceTS == 0L) mEvent.startTS else mEventOccurrenceTS
|
val realStart = if (mEventOccurrenceTS == 0L) mEvent.startTS else mEventOccurrenceTS
|
||||||
val duration = mEvent.endTS - mEvent.startTS
|
val duration = mEvent.endTS - mEvent.startTS
|
||||||
@ -432,8 +433,10 @@ class EventActivity : SimpleActivity() {
|
|||||||
mRepeatRule = mEvent.repeatRule
|
mRepeatRule = mEvent.repeatRule
|
||||||
mEventTypeId = mEvent.eventType
|
mEventTypeId = mEvent.eventType
|
||||||
mEventCalendarId = mEvent.getCalDAVCalendarId()
|
mEventCalendarId = mEvent.getCalDAVCalendarId()
|
||||||
mAttendees = Gson().fromJson<ArrayList<Attendee>>(mEvent.attendees, object : TypeToken<List<Attendee>>() {}.type)
|
|
||||||
?: ArrayList()
|
val token = object : TypeToken<List<Attendee>>() {}.type
|
||||||
|
mAttendees = Gson().fromJson<ArrayList<Attendee>>(mEvent.attendees, token) ?: ArrayList()
|
||||||
|
|
||||||
checkRepeatTexts(mRepeatInterval)
|
checkRepeatTexts(mRepeatInterval)
|
||||||
checkAttendees()
|
checkAttendees()
|
||||||
}
|
}
|
||||||
@ -464,8 +467,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_title.requestFocus()
|
event_title.requestFocus()
|
||||||
updateActionBarTitle(getString(R.string.new_event))
|
updateActionBarTitle(getString(R.string.new_event))
|
||||||
if (config.defaultEventTypeId != -1L) {
|
if (config.defaultEventTypeId != -1L) {
|
||||||
config.lastUsedCaldavCalendarId = mStoredEventTypes.firstOrNull { it.id == config.defaultEventTypeId }?.caldavCalendarId
|
config.lastUsedCaldavCalendarId = mStoredEventTypes.firstOrNull { it.id == config.defaultEventTypeId }?.caldavCalendarId ?: 0
|
||||||
?: 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
|
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
|
||||||
@ -894,8 +896,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun getCalendarId() = if (mEvent.source == SOURCE_SIMPLE_CALENDAR) config.lastUsedCaldavCalendarId else mEvent.getCalDAVCalendarId()
|
private fun getCalendarId() = if (mEvent.source == SOURCE_SIMPLE_CALENDAR) config.lastUsedCaldavCalendarId else mEvent.getCalDAVCalendarId()
|
||||||
|
|
||||||
private fun getCalendarWithId(calendars: List<CalDAVCalendar>, calendarId: Int): CalDAVCalendar? =
|
private fun getCalendarWithId(calendars: List<CalDAVCalendar>, calendarId: Int) = calendars.firstOrNull { it.id == calendarId }
|
||||||
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)
|
||||||
@ -919,8 +920,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_caldav_calendar_email.text = currentCalendar.accountName
|
event_caldav_calendar_email.text = currentCalendar.accountName
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val calendarColor = eventsHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color
|
val calendarColor = eventsHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color ?: currentCalendar.color
|
||||||
?: currentCalendar.color
|
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
event_caldav_calendar_color.setFillWithStroke(calendarColor, config.backgroundColor)
|
event_caldav_calendar_color.setFillWithStroke(calendarColor, config.backgroundColor)
|
||||||
@ -1005,8 +1005,8 @@ class EventActivity : SimpleActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var newStartTS = 0L
|
var newStartTS: Long
|
||||||
var newEndTS = 0L
|
var newEndTS: Long
|
||||||
getStartEndTimes().apply {
|
getStartEndTimes().apply {
|
||||||
newStartTS = first
|
newStartTS = first
|
||||||
newEndTS = second
|
newEndTS = second
|
||||||
@ -1019,7 +1019,11 @@ class EventActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val wasRepeatable = mEvent.repeatInterval > 0
|
val wasRepeatable = mEvent.repeatInterval > 0
|
||||||
val oldSource = mEvent.source
|
val oldSource = mEvent.source
|
||||||
val newImportId = if (mEvent.id != null) mEvent.importId else UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
val newImportId = if (mEvent.id != null) {
|
||||||
|
mEvent.importId
|
||||||
|
} else {
|
||||||
|
UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
||||||
|
}
|
||||||
|
|
||||||
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||||
mEventTypeId
|
mEventTypeId
|
||||||
@ -1033,8 +1037,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eventsHelper.getEventTypeWithCalDAVCalendarId(mEventCalendarId)?.id
|
eventsHelper.getEventTypeWithCalDAVCalendarId(mEventCalendarId)?.id ?: config.lastUsedLocalEventTypeId
|
||||||
?: config.lastUsedLocalEventTypeId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val newSource = if (!config.caldavSync || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
val newSource = if (!config.caldavSync || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user