2022-03-01 18:40:53 +01:00
|
|
|
package me.ash.reader
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
import dagger.hilt.android.HiltAndroidApp
|
|
|
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.launch
|
2022-03-17 17:15:53 +01:00
|
|
|
import me.ash.reader.data.repository.*
|
2022-03-01 18:40:53 +01:00
|
|
|
import me.ash.reader.data.source.OpmlLocalDataSource
|
|
|
|
import me.ash.reader.data.source.ReaderDatabase
|
|
|
|
import me.ash.reader.data.source.RssNetworkDataSource
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
@DelicateCoroutinesApi
|
|
|
|
@HiltAndroidApp
|
|
|
|
class App : Application() {
|
|
|
|
@Inject
|
|
|
|
lateinit var readerDatabase: ReaderDatabase
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var opmlLocalDataSource: OpmlLocalDataSource
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var rssNetworkDataSource: RssNetworkDataSource
|
|
|
|
|
2022-03-17 17:15:53 +01:00
|
|
|
@Inject
|
|
|
|
lateinit var rssHelper: RssHelper
|
|
|
|
|
2022-03-20 17:07:45 +01:00
|
|
|
@Inject
|
|
|
|
lateinit var stringsRepository: StringsRepository
|
|
|
|
|
2022-03-01 18:40:53 +01:00
|
|
|
@Inject
|
|
|
|
lateinit var accountRepository: AccountRepository
|
|
|
|
|
|
|
|
@Inject
|
2022-03-17 17:15:53 +01:00
|
|
|
lateinit var localRssRepository: LocalRssRepository
|
2022-03-01 18:40:53 +01:00
|
|
|
|
2022-03-17 19:11:52 +01:00
|
|
|
@Inject
|
|
|
|
lateinit var feverRssRepository: FeverRssRepository
|
|
|
|
|
2022-03-01 18:40:53 +01:00
|
|
|
@Inject
|
|
|
|
lateinit var opmlRepository: OpmlRepository
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var rssRepository: RssRepository
|
|
|
|
|
|
|
|
override fun onCreate() {
|
|
|
|
super.onCreate()
|
|
|
|
GlobalScope.launch {
|
|
|
|
if (accountRepository.isNoAccount()) {
|
2022-03-17 17:15:53 +01:00
|
|
|
val account = accountRepository.addDefaultAccount()
|
|
|
|
applicationContext.dataStore.put(DataStoreKeys.CurrentAccountId, account.id!!)
|
|
|
|
applicationContext.dataStore.put(DataStoreKeys.CurrentAccountType, account.type)
|
2022-03-01 18:40:53 +01:00
|
|
|
}
|
2022-03-17 17:15:53 +01:00
|
|
|
rssRepository.get().doSync(true)
|
2022-03-01 18:40:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|