forked from agzam/vyatsu-schedule
46 lines
1.4 KiB
Kotlin
46 lines
1.4 KiB
Kotlin
package agzam.vyatsu.di
|
|||
|
|
|
||
|
|
import agzam.vyatsu.data.local.AppDatabase
|
||
|
|
import agzam.vyatsu.data.local.ScheduleCodec
|
||
|
|
import agzam.vyatsu.data.remote.GroupsParser
|
||
|
|
import agzam.vyatsu.data.remote.VyatsuHttpClient
|
||
|
|
import agzam.vyatsu.data.repository.GroupRepositoryImpl
|
||
|
|
import agzam.vyatsu.data.repository.PreferencesRepositoryImpl
|
||
|
|
import agzam.vyatsu.data.repository.ScheduleRepositoryImpl
|
||
|
|
import agzam.vyatsu.domain.repository.GroupRepository
|
||
|
|
import agzam.vyatsu.domain.repository.PreferencesRepository
|
||
|
|
import agzam.vyatsu.domain.repository.ScheduleRepository
|
||
|
|
import android.content.Context
|
||
|
|
import androidx.room.Room
|
||
|
|
import com.squareup.moshi.Moshi
|
||
|
|
|
||
|
|
class AppContainer(context: Context) {
|
||
|
|
private val moshi: Moshi = Moshi.Builder().build()
|
||
|
|
|
||
|
|
private val database: AppDatabase = Room.databaseBuilder(
|
||
|
|
context.applicationContext,
|
||
|
|
AppDatabase::class.java,
|
||
|
|
"vyatsu_schedule.db"
|
||
|
|
).build()
|
||
|
|
|
||
|
|
private val codec: ScheduleCodec = ScheduleCodec(moshi)
|
||
|
|
|
||
|
|
val groupRepository: GroupRepository by lazy {
|
||
|
|
GroupRepositoryImpl(
|
||
|
|
groupDao = database.groupDao(),
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
val scheduleRepository: ScheduleRepository by lazy {
|
||
|
|
ScheduleRepositoryImpl(
|
||
|
|
scheduleDao = database.scheduleDao(),
|
||
|
|
groupDao = database.groupDao(),
|
||
|
|
codec = codec
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
val preferencesRepository: PreferencesRepository by lazy {
|
||
|
|
PreferencesRepositoryImpl(database.preferencesDao())
|
||
|
|
}
|
||
|
|
}
|