2016-06-14 15:13:48 +02:00
|
|
|
package eu.kanade.tachiyomi
|
|
|
|
|
|
|
|
import android.app.Application
|
2021-06-05 23:49:20 +02:00
|
|
|
import androidx.core.content.ContextCompat
|
2016-06-14 15:13:48 +02:00
|
|
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
|
|
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
|
|
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
|
|
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
2017-01-20 21:22:17 +01:00
|
|
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
2018-02-05 22:50:56 +01:00
|
|
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
2017-01-20 21:34:15 +01:00
|
|
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
|
|
|
import eu.kanade.tachiyomi.source.SourceManager
|
2020-11-01 21:12:16 +01:00
|
|
|
import kotlinx.serialization.json.Json
|
2020-02-27 00:12:44 +01:00
|
|
|
import uy.kohesive.injekt.api.InjektModule
|
|
|
|
import uy.kohesive.injekt.api.InjektRegistrar
|
|
|
|
import uy.kohesive.injekt.api.addSingleton
|
|
|
|
import uy.kohesive.injekt.api.addSingletonFactory
|
|
|
|
import uy.kohesive.injekt.api.get
|
2016-06-14 15:13:48 +02:00
|
|
|
|
|
|
|
class AppModule(val app: Application) : InjektModule {
|
|
|
|
|
|
|
|
override fun InjektRegistrar.registerInjectables() {
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingleton(app)
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { PreferencesHelper(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { DatabaseHelper(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { ChapterCache(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { CoverCache(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { NetworkHelper(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { SourceManager(app).also { get<ExtensionManager>().init(it) } }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { ExtensionManager(app) }
|
2016-06-14 15:13:48 +02:00
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
addSingletonFactory { DownloadManager(app) }
|
|
|
|
|
|
|
|
addSingletonFactory { TrackManager(app) }
|
|
|
|
|
2020-11-01 21:12:16 +01:00
|
|
|
addSingletonFactory { Json { ignoreUnknownKeys = true } }
|
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
// Asynchronously init expensive components for a faster cold start
|
2021-06-05 23:49:20 +02:00
|
|
|
ContextCompat.getMainExecutor(app).execute {
|
2021-01-10 17:01:10 +01:00
|
|
|
get<PreferencesHelper>()
|
2018-02-05 22:50:56 +01:00
|
|
|
|
2021-01-10 17:01:10 +01:00
|
|
|
get<NetworkHelper>()
|
2018-02-05 22:50:56 +01:00
|
|
|
|
2021-01-10 17:01:10 +01:00
|
|
|
get<SourceManager>()
|
2018-02-05 22:50:56 +01:00
|
|
|
|
2021-01-10 17:01:10 +01:00
|
|
|
get<DatabaseHelper>()
|
2018-02-05 22:50:56 +01:00
|
|
|
|
2021-01-10 17:01:10 +01:00
|
|
|
get<DownloadManager>()
|
|
|
|
}
|
2016-06-14 15:13:48 +02:00
|
|
|
}
|
2018-02-06 11:42:38 +01:00
|
|
|
}
|