mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2024-12-12 08:36:30 +01:00
Minor code formatting
This commit is contained in:
parent
61d246985d
commit
833735a96b
@ -18,6 +18,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALENDAR
|
|||||||
import org.joda.time.DateTimeZone
|
import org.joda.time.DateTimeZone
|
||||||
import org.joda.time.format.DateTimeFormat
|
import org.joda.time.format.DateTimeFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
class CalDAVHelper(val context: Context) {
|
class CalDAVHelper(val context: Context) {
|
||||||
@ -245,11 +246,11 @@ class CalDAVHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
event.parentId = parentEvent.id!!
|
event.parentId = parentEvent.id!!
|
||||||
parentEvent.addRepetitionException(originalDayCode)
|
parentEvent.addRepetitionException(originalDayCode)
|
||||||
eventsHelper.insertEvent(parentEvent, false, false)
|
eventsHelper.insertEvent(parentEvent, addToCalDAV = false, showToasts = false)
|
||||||
|
|
||||||
event.parentId = parentEvent.id!!
|
event.parentId = parentEvent.id!!
|
||||||
event.addRepetitionException(originalDayCode)
|
event.addRepetitionException(originalDayCode)
|
||||||
eventsHelper.insertEvent(event, false, false)
|
eventsHelper.insertEvent(event, addToCalDAV = false, showToasts = false)
|
||||||
return@queryCursor
|
return@queryCursor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +271,7 @@ class CalDAVHelper(val context: Context) {
|
|||||||
val daycode = Formatter.getDayCodeFromDateTime(dt)
|
val daycode = Formatter.getDayCodeFromDateTime(dt)
|
||||||
event.repetitionExceptions.add(daycode)
|
event.repetitionExceptions.add(daycode)
|
||||||
} else {
|
} else {
|
||||||
var potentialTS = it.substring(0, 8)
|
val potentialTS = it.substring(0, 8)
|
||||||
if (potentialTS.areDigitsOnly()) {
|
if (potentialTS.areDigitsOnly()) {
|
||||||
event.repetitionExceptions.add(potentialTS)
|
event.repetitionExceptions.add(potentialTS)
|
||||||
}
|
}
|
||||||
@ -292,12 +293,12 @@ class CalDAVHelper(val context: Context) {
|
|||||||
|
|
||||||
if (existingEvent.hashCode() != event.hashCode() && title.isNotEmpty()) {
|
if (existingEvent.hashCode() != event.hashCode() && title.isNotEmpty()) {
|
||||||
event.id = originalEventId
|
event.id = originalEventId
|
||||||
eventsHelper.updateEvent(event, false, false)
|
eventsHelper.updateEvent(event, updateAtCalDAV = false, showToasts = false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (title.isNotEmpty()) {
|
if (title.isNotEmpty()) {
|
||||||
importIdsMap[event.importId] = event
|
importIdsMap[event.importId] = event
|
||||||
eventsHelper.insertEvent(event, false, false)
|
eventsHelper.insertEvent(event, addToCalDAV = false, showToasts = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,9 +306,9 @@ class CalDAVHelper(val context: Context) {
|
|||||||
val eventIdsToDelete = ArrayList<Long>()
|
val eventIdsToDelete = ArrayList<Long>()
|
||||||
importIdsMap.keys.filter { !fetchedEventIds.contains(it) }.forEach {
|
importIdsMap.keys.filter { !fetchedEventIds.contains(it) }.forEach {
|
||||||
val caldavEventId = it
|
val caldavEventId = it
|
||||||
existingEvents.forEach {
|
existingEvents.forEach { event ->
|
||||||
if (it.importId == caldavEventId) {
|
if (event.importId == caldavEventId) {
|
||||||
eventIdsToDelete.add(it.id!!)
|
eventIdsToDelete.add(event.id!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,7 +434,7 @@ class CalDAVHelper(val context: Context) {
|
|||||||
|
|
||||||
private fun getDurationCode(event: Event): String {
|
private fun getDurationCode(event: Event): String {
|
||||||
return if (event.getIsAllDay()) {
|
return if (event.getIsAllDay()) {
|
||||||
val dur = Math.max(1, (event.endTS - event.startTS) / DAY)
|
val dur = max(1, (event.endTS - event.startTS) / DAY)
|
||||||
"P${dur}D"
|
"P${dur}D"
|
||||||
} else {
|
} else {
|
||||||
Parser().getDurationCode((event.endTS - event.startTS) / 60L)
|
Parser().getDurationCode((event.endTS - event.startTS) / 60L)
|
||||||
|
Loading…
Reference in New Issue
Block a user