mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 01:19:18 +01:00
21 lines
697 B
Kotlin
21 lines
697 B
Kotlin
package eu.kanade.data
|
|
|
|
import com.squareup.sqldelight.ColumnAdapter
|
|
import java.util.Date
|
|
|
|
val dateAdapter = object : ColumnAdapter<Date, Long> {
|
|
override fun decode(databaseValue: Long): Date = Date(databaseValue)
|
|
override fun encode(value: Date): Long = value.time
|
|
}
|
|
|
|
private const val listOfStringsSeparator = ", "
|
|
val listOfStringsAdapter = object : ColumnAdapter<List<String>, String> {
|
|
override fun decode(databaseValue: String) =
|
|
if (databaseValue.isEmpty()) {
|
|
listOf()
|
|
} else {
|
|
databaseValue.split(listOfStringsSeparator)
|
|
}
|
|
override fun encode(value: List<String>) = value.joinToString(separator = listOfStringsSeparator)
|
|
}
|