updating some event repetition exceptions handling
This commit is contained in:
parent
b008b43dfa
commit
3a2967a146
4 changed files with 15 additions and 6 deletions
|
@ -62,7 +62,7 @@ dependencies {
|
|||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
||||
|
||||
kapt 'androidx.room:room-compiler:2.0.0'
|
||||
implementation 'androidx.room:room-runtime:2.0.0'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.0.0'
|
||||
kapt 'androidx.room:room-compiler:2.1.0'
|
||||
implementation 'androidx.room:room-runtime:2.1.0'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.1.0'
|
||||
}
|
||||
|
|
|
@ -9,7 +9,15 @@ class Converters {
|
|||
private val stringType = object : TypeToken<List<String>>() {}.type
|
||||
|
||||
@TypeConverter
|
||||
fun jsonToStringList(value: String) = gson.fromJson<ArrayList<String>>(value, stringType)
|
||||
fun jsonToStringList(value: String): ArrayList<String> {
|
||||
val newValue = if (value.isNotEmpty() && !value.startsWith("[")) {
|
||||
"[$value]"
|
||||
} else {
|
||||
value
|
||||
}
|
||||
|
||||
return gson.fromJson(newValue, stringType)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun stringListToJson(list: ArrayList<String>) = gson.toJson(list)
|
||||
|
|
|
@ -214,7 +214,8 @@ class EventsHelper(val context: Context) {
|
|||
var repetitionExceptions = parentEvent.repetitionExceptions
|
||||
repetitionExceptions.add(Formatter.getDayCodeFromTS(occurrenceTS))
|
||||
repetitionExceptions = repetitionExceptions.distinct().toMutableList() as ArrayList<String>
|
||||
eventsDB.updateEventRepetitionExceptions(repetitionExceptions, parentEventId)
|
||||
|
||||
eventsDB.updateEventRepetitionExceptions(repetitionExceptions.toString(), parentEventId)
|
||||
context.scheduleNextEventReminder(parentEvent, false)
|
||||
|
||||
if (addToCalDAV && config.caldavSync) {
|
||||
|
|
|
@ -103,7 +103,7 @@ interface EventsDao {
|
|||
fun updateEventRepetitionLimit(repeatLimit: Long, id: Long)
|
||||
|
||||
@Query("UPDATE events SET repetition_exceptions = :repetitionExceptions WHERE id = :id")
|
||||
fun updateEventRepetitionExceptions(repetitionExceptions: ArrayList<String>, id: Long)
|
||||
fun updateEventRepetitionExceptions(repetitionExceptions: String, id: Long)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrUpdate(event: Event): Long
|
||||
|
|
Loading…
Reference in a new issue