chore: Some more effort moving widget to its own module

This commit is contained in:
Ahmad Ansori Palembani 2024-06-17 13:21:27 +07:00
parent 79b5494307
commit 4a9a7813e0
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
34 changed files with 205 additions and 64 deletions

24
data/build.gradle.kts Normal file
View 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"
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />

View file

@ -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
}