@@ -11,7 +11,6 @@ import androidx.room.RoomDatabase
1111import androidx.room.TypeConverters
1212import androidx.room.migration.Migration
1313import androidx.sqlite.db.SupportSQLiteDatabase
14- import xyz.aprildown.timer.data.R
1514import xyz.aprildown.timer.data.datas.FolderData
1615import xyz.aprildown.timer.data.datas.SchedulerData
1716import xyz.aprildown.timer.data.datas.StepData
@@ -49,42 +48,43 @@ abstract class MachineDatabase : RoomDatabase() {
4948
5049 const val DB_VERSION = 8
5150
52- private fun Builder<MachineDatabase>.addMyMigrations (context : Context ): Builder <MachineDatabase > {
51+ private fun Builder<MachineDatabase>.addMyMigrations (): Builder <MachineDatabase > {
5352 addMigrations(getMigration1to2())
5453 addMigrations(getMigration2to3())
5554 addMigrations(getMigration3to4())
5655 addMigrations(getMigration4to5())
5756 addMigrations(getMigration5to6())
5857 addMigrations(getMigration6to7())
59- addMigrations(getMigration7to8(context ))
58+ addMigrations(getMigration7to8())
6059 return this
6160 }
6261
63- private fun Builder<MachineDatabase>.addCallback (context : Context ): Builder <MachineDatabase > {
62+ private fun Builder<MachineDatabase>.addCallback (): Builder <MachineDatabase > {
6463 return addCallback(
6564 object : Callback () {
6665 override fun onCreate (db : SupportSQLiteDatabase ) {
67- addHostFolders(context, db)
66+ addHostFolders(db)
6867 }
6968 }
7069 )
7170 }
7271
73- private fun addHostFolders (context : Context , db : SupportSQLiteDatabase ) {
72+ private fun addHostFolders (db : SupportSQLiteDatabase ) {
73+ // Names are empty because we populate them at runtime.
7474 db.insert(
7575 " Folder" ,
7676 SQLiteDatabase .CONFLICT_IGNORE ,
7777 contentValuesOf(
7878 " id" to FolderEntity .FOLDER_DEFAULT ,
79- " name" to context.getString( R .string.folder_default) ,
79+ " name" to " " ,
8080 )
8181 )
8282 db.insert(
8383 " Folder" ,
8484 SQLiteDatabase .CONFLICT_IGNORE ,
8585 contentValuesOf(
8686 " id" to FolderEntity .FOLDER_TRASH ,
87- " name" to context.getString( R .string.folder_trash) ,
87+ " name" to " " ,
8888 )
8989 )
9090 }
@@ -93,8 +93,8 @@ abstract class MachineDatabase : RoomDatabase() {
9393 fun createInMemoryDatabase (context : Context ): MachineDatabase {
9494 return Room .inMemoryDatabaseBuilder(context, MachineDatabase ::class .java)
9595 .allowMainThreadQueries()
96- .addMyMigrations(context )
97- .addCallback(context )
96+ .addMyMigrations()
97+ .addCallback()
9898 .build()
9999 }
100100
@@ -104,8 +104,8 @@ abstract class MachineDatabase : RoomDatabase() {
104104 MachineDatabase ::class .java,
105105 DB_NAME
106106 )
107- .addMyMigrations(context )
108- .addCallback(context )
107+ .addMyMigrations()
108+ .addCallback()
109109 .build()
110110 }
111111
@@ -209,7 +209,7 @@ abstract class MachineDatabase : RoomDatabase() {
209209 * Add [FolderData] and [TimerData.folderId].
210210 */
211211 @VisibleForTesting(otherwise = VisibleForTesting .PRIVATE )
212- fun getMigration7to8 (context : Context ): Migration = object : Migration (7 , 8 ) {
212+ fun getMigration7to8 (): Migration = object : Migration (7 , 8 ) {
213213 override fun migrate (database : SupportSQLiteDatabase ) {
214214 database.execSQL(
215215 " ALTER TABLE TimerItem " +
@@ -219,7 +219,7 @@ abstract class MachineDatabase : RoomDatabase() {
219219 " CREATE TABLE IF NOT EXISTS `Folder` " +
220220 " (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)"
221221 )
222- addHostFolders(context, database)
222+ addHostFolders(database)
223223 }
224224 }
225225 }
0 commit comments