move the events Color field in an inline property, do not store it in db

This commit is contained in:
tibbi 2018-11-13 11:41:11 +01:00
parent fe31ba5622
commit 7dae374b4d
2 changed files with 12 additions and 3 deletions

View File

@ -651,6 +651,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (isOnProperWeek(event, startTimes)) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -658,6 +659,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
} else {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -669,6 +671,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (isOnProperWeek(event, startTimes)) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -679,6 +682,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (dayCode == endDayCode) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -699,6 +703,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (event.endTS >= fromTS) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -709,6 +714,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (event.endTS >= fromTS) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
} else if (event.getIsAllDay()) {
@ -717,6 +723,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (dayCode == endDayCode) {
event.copy().apply {
updateIsPastEvent()
color = event.color
events.add(this)
}
}
@ -871,15 +878,15 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
val eventType = cursor.getLongValue(COL_EVENT_TYPE)
val lastUpdated = cursor.getLongValue(COL_LAST_UPDATED)
val source = cursor.getStringValue(COL_EVENT_SOURCE)
val color = eventTypeColors.get(eventType)!!
if (repeatInterval > 0 && repeatRule == 0 && (repeatInterval % MONTH == 0 || repeatInterval % YEAR == 0)) {
repeatRule = REPEAT_SAME_DAY
}
val event = Event(id, startTS, endTS, title, location, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, 0, lastUpdated, source, color)
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, 0, lastUpdated, source)
event.updateIsPastEvent()
event.color = eventTypeColors.get(eventType)!!
events.add(event)
} while (cursor.moveToNext())

View File

@ -11,7 +11,7 @@ data class Event(var id: Long?, var startTS: Int = 0, var endTS: Int = 0, var ti
var reminder1Minutes: Int = -1, var reminder2Minutes: Int = -1, var reminder3Minutes: Int = -1, var repeatInterval: Int = 0,
var importId: String = "", var flags: Int = 0, var repeatLimit: Int = 0, var repeatRule: Int = 0,
var eventType: Long = DBHelper.REGULAR_EVENT_TYPE_ID, var parentId: Long = 0, var lastUpdated: Long = 0L,
var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0)
var source: String = SOURCE_SIMPLE_CALENDAR)
: Serializable {
companion object {
@ -134,4 +134,6 @@ data class Event(var id: Long?, var startTS: Int = 0, var endTS: Int = 0, var ti
flags.removeBit(FLAG_IS_PAST_EVENT)
}
}
var color: Int = 0
}