This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun shouldPrepopulateDatabase(databaseName: String): Boolean = | |
| !context.getDatabasePath(databaseName).exists() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| actual class DriverFactory { | |
| actual fun createDriver(): SqlDriver { | |
| return NativeSqliteDriver(Database.Schema, "todo.db") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| actual class DriverFactory(private val context: Context) { | |
| actual fun createDriver(): SqlDriver { | |
| return AndroidSqliteDriver(Database.Schema, context, "todo.db") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val alarmIntervalAdapter = object : ColumnAdapter<AlarmInterval, Long> { | |
| override fun decode(databaseValue: Long): AlarmInterval = | |
| AlarmInterval.values().find { it.id == databaseValue.toInt() }!! | |
| override fun encode(value: AlarmInterval): Long = | |
| value.id.toLong() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @TypeConverter | |
| fun toAlarmInterval(id: Int?): AlarmInterval? = | |
| AlarmInterval.values().find { it.id == id } | |
| @TypeConverter | |
| fun toId(alarmInterval: AlarmInterval?): Int? = | |
| alarmInterval?.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| data class Category( | |
| @PrimaryKey(autoGenerate = true) | |
| @ColumnInfo(name = "category_id") | |
| var id: Long = 0, | |
| @ColumnInfo(name = "category_name") var name: String, | |
| @ColumnInfo(name = "category_color") var color: String, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE IF NOT EXISTS Category ( | |
| `category_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | |
| `category_name` TEXT NOT NULL, | |
| `category_color` TEXT NOT NULL | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| id("com.android.library") | |
| } | |
| // Manually get the reference for "libs" | |
| val libs: VersionCatalog = | |
| extensions.getByType<VersionCatalogsExtension>().named("libs") | |
| dependencies { | |
| // Use the extension function to access the dependency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enableFeaturePreview("VERSION_CATALOGS") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| `kotlin-dsl` | |
| } | |
| repositories { | |
| mavenCentral() | |
| google() | |
| } |