mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2024-12-24 15:31:05 +01:00
transforming RepeatRule into a database table
This commit is contained in:
parent
0d7d4efc97
commit
d9fae609ac
@ -5,21 +5,18 @@ import com.simplemobiletools.calendar.pro.extensions.isXWeeklyRepetition
|
||||
import com.simplemobiletools.calendar.pro.extensions.isXYearlyRepetition
|
||||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.RepeatRule
|
||||
import com.simplemobiletools.calendar.pro.models.EventRepetition
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import org.joda.time.DateTimeZone
|
||||
import org.joda.time.format.DateTimeFormat
|
||||
|
||||
class Parser {
|
||||
// from RRULE:FREQ=DAILY;COUNT=5 to Daily, 5x...
|
||||
fun parseRepeatInterval(fullString: String, startTS: Int): RepeatRule {
|
||||
val parts = fullString.split(";")
|
||||
fun parseRepeatInterval(fullString: String, startTS: Int): EventRepetition {
|
||||
val parts = fullString.split(";").filter { it.isNotEmpty() }
|
||||
var repeatInterval = 0
|
||||
var repeatRule = 0
|
||||
var repeatLimit = 0
|
||||
if (fullString.isEmpty()) {
|
||||
return RepeatRule(repeatInterval, repeatRule, repeatLimit)
|
||||
}
|
||||
|
||||
for (part in parts) {
|
||||
val keyValue = part.split("=")
|
||||
@ -49,7 +46,7 @@ class Parser {
|
||||
repeatRule = REPEAT_LAST_DAY
|
||||
}
|
||||
}
|
||||
return RepeatRule(repeatInterval, repeatRule, repeatLimit)
|
||||
return EventRepetition(null, repeatInterval, repeatRule, repeatLimit)
|
||||
}
|
||||
|
||||
private fun getFrequencySeconds(interval: String) = when (interval) {
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.simplemobiletools.calendar.pro.models
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "event_repetitions", indices = [(Index(value = ["id"], unique = true))])
|
||||
data class EventRepetition(
|
||||
@PrimaryKey(autoGenerate = true) var id: Long?,
|
||||
@ColumnInfo(name = "repeat_interval") val repeatInterval: Int,
|
||||
@ColumnInfo(name = "repeat_rule") val repeatRule: Int,
|
||||
@ColumnInfo(name = "repeat_limit") val repeatLimit: Int)
|
@ -1,3 +0,0 @@
|
||||
package com.simplemobiletools.calendar.pro.models
|
||||
|
||||
data class RepeatRule(val repeatInterval: Int, val repeatRule: Int, val repeatLimit: Int)
|
Loading…
Reference in New Issue
Block a user