mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 06:57:34 +01:00
Adjustments to the lazy initialization of the app
This commit is contained in:
@@ -248,7 +248,7 @@ class AppModules(
|
||||
fun contentResolverFn(): ContentResolver = appContext.contentResolver
|
||||
|
||||
fun setImageLoader() {
|
||||
ImageLoaderSetup.setup(appContext, diskCache, memoryCache) { url ->
|
||||
ImageLoaderSetup.setup(appContext, { diskCache }, { memoryCache }) { url ->
|
||||
okHttpClients.getHttpClient(roleBasedHttpClientBuilder.shouldUseTorForImageDownload(url))
|
||||
}
|
||||
}
|
||||
@@ -270,15 +270,12 @@ class AppModules(
|
||||
applicationIOScope.launch {
|
||||
// preloads tor preferences
|
||||
torPrefs
|
||||
}
|
||||
|
||||
// initializes diskcache on an IO thread.
|
||||
applicationIOScope.launch {
|
||||
// Sets Coil - Tor - OkHttp link
|
||||
setImageLoader()
|
||||
|
||||
// prepares coil's disk cache
|
||||
diskCache
|
||||
|
||||
// prepares exoplayer's disk cache
|
||||
videoCache
|
||||
}
|
||||
|
||||
// registers to receive events
|
||||
|
||||
@@ -59,15 +59,15 @@ class ImageLoaderSetup {
|
||||
@OptIn(DelicateCoilApi::class)
|
||||
fun setup(
|
||||
app: Context,
|
||||
diskCache: DiskCache,
|
||||
memoryCache: MemoryCache,
|
||||
diskCache: () -> DiskCache,
|
||||
memoryCache: () -> MemoryCache,
|
||||
callFactory: (url: String) -> Call.Factory,
|
||||
) {
|
||||
SingletonImageLoader.setUnsafe(
|
||||
ImageLoader
|
||||
.Builder(app)
|
||||
.diskCache { diskCache }
|
||||
.memoryCache { memoryCache }
|
||||
.diskCache(diskCache)
|
||||
.memoryCache(memoryCache)
|
||||
.precision(Precision.INEXACT)
|
||||
.logger(debugLogger)
|
||||
.components {
|
||||
|
||||
Reference in New Issue
Block a user