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
|
|
|
|
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-05-06 18:12:31 +00:00
|
|
|
single { createDatabase(get()) }
|
|
|
|
single { LogDao() }
|
|
|
|
single { PolicyDao(get()) }
|
|
|
|
single { SettingsDao() }
|
2019-05-10 17:13:15 +00:00
|
|
|
single { StringDao() }
|
2019-05-06 18:12:31 +00:00
|
|
|
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()
|