mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Some more effort moving widget to its own module
This commit is contained in:
parent
79b5494307
commit
4a9a7813e0
34 changed files with 205 additions and 64 deletions
24
data/build.gradle.kts
Normal file
24
data/build.gradle.kts
Normal file
|
@ -0,0 +1,24 @@
|
|||
plugins {
|
||||
kotlin("multiplatform")
|
||||
kotlin("plugin.serialization")
|
||||
id("com.android.library")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
androidTarget()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
val androidMain by getting {
|
||||
dependencies {
|
||||
implementation(projects.sourceApi)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "yokai.data"
|
||||
}
|
2
data/src/androidMain/AndroidManifest.xml
Normal file
2
data/src/androidMain/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
|
@ -0,0 +1,26 @@
|
|||
package eu.kanade.tachiyomi.data.database
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
|
||||
// TODO: Move to yokai.data.DatabaseAdapter
|
||||
|
||||
val updateStrategyAdapter = object : ColumnAdapter<UpdateStrategy, Int> {
|
||||
private val enumValues by lazy { UpdateStrategy.entries }
|
||||
|
||||
override fun decode(databaseValue: Int): UpdateStrategy =
|
||||
enumValues.getOrElse(databaseValue) { UpdateStrategy.ALWAYS_UPDATE }
|
||||
|
||||
override fun encode(value: UpdateStrategy): Int = value.ordinal
|
||||
}
|
||||
|
||||
interface ColumnAdapter<T : Any, S> {
|
||||
/**
|
||||
* @return [databaseValue] decoded as type [T].
|
||||
*/
|
||||
fun decode(databaseValue: S): T
|
||||
|
||||
/**
|
||||
* @return [value] encoded as database type [S].
|
||||
*/
|
||||
fun encode(value: T): S
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue