1234567891011121314151617181920212223242526272829 |
- package com.flacksta.chef.journeygpstracker
- import android.app.Application
- import android.util.Log
- import com.flacksta.chef.journeygpstracker.database.GpsData
- import com.flacksta.chef.journeygpstracker.database.GpsPosRepository
- import com.flacksta.chef.journeygpstracker.database.GpsPosRoomDatabase
- import kotlinx.coroutines.*
- class JourneyGpsTrackerApplication : Application() {
- val applicationScope = CoroutineScope(SupervisorJob())
- val database by lazy { GpsPosRoomDatabase.getDatabase(this, applicationScope) }
- val repository by lazy { GpsPosRepository(database.gpsDataDao()) }
- override fun onCreate() {
- super.onCreate()
- Log.i("JourneyGpsTrackerApplication","onCreate()")
- initStuff()
- }
- fun initStuff() = runBlocking { // this: CoroutineScope
- launch {
- repository.deleteAll()
- }
- }
- }
|