2019-04-11 18:01:49 +00:00
|
|
|
package com.topjohnwu.magisk.di
|
|
|
|
|
2019-05-06 18:12:31 +00:00
|
|
|
import android.content.Context
|
|
|
|
import androidx.room.Room
|
2019-04-17 16:27:03 +00:00
|
|
|
import com.topjohnwu.magisk.App
|
2019-05-06 18:12:31 +00:00
|
|
|
import com.topjohnwu.magisk.data.database.*
|
2019-04-11 18:01:49 +00:00
|
|
|
import org.koin.dsl.module
|
|
|
|
|
|
|
|
|
2019-04-17 16:27:03 +00:00
|
|
|
val databaseModule = module {
|
2019-04-27 09:27:42 +00:00
|
|
|
single { MagiskDB(get<App>().protectedContext) }
|
2019-05-06 18:12:31 +00:00
|
|
|
single { createDatabase(get()) }
|
|
|
|
single { LogDao() }
|
|
|
|
single { PolicyDao(get()) }
|
|
|
|
single { SettingsDao() }
|
|
|
|
single { StringsDao() }
|
|
|
|
single { createRepositoryDao(get()) }
|
2019-04-17 16:27:03 +00:00
|
|
|
}
|
2019-05-06 18:12:31 +00:00
|
|
|
|
|
|
|
fun createDatabase(context: Context): AppDatabase =
|
|
|
|
Room.databaseBuilder(context, AppDatabase::class.java, AppDatabase.NAME).build()
|
|
|
|
|
|
|
|
fun createRepositoryDao(db: AppDatabase) = db.repoDao()
|