25 lines
795 B
Kotlin
25 lines
795 B
Kotlin
package com.racingapp.pitlog
|
|
|
|
import android.app.Application
|
|
import com.racingapp.pitlog.data.AppDatabase
|
|
import com.racingapp.pitlog.data.PitSync
|
|
import com.racingapp.pitlog.data.Repository
|
|
import com.racingapp.pitlog.data.SyncPreferences
|
|
import com.racingapp.pitlog.data.ensureCars
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
open class RacingApp : Application() {
|
|
lateinit var repository: Repository
|
|
private set
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
val dao = AppDatabase.create(this).raceDao()
|
|
val preferences = SyncPreferences(this)
|
|
runBlocking(Dispatchers.IO) { ensureCars(dao, preferences) }
|
|
val sync = PitSync(dao, preferences)
|
|
repository = Repository(dao, sync, preferences)
|
|
}
|
|
}
|