Adjustments to the lazy initialization of the app

This commit is contained in:
Vitor Pamplona
2025-10-20 18:41:00 -04:00
parent fabec35593
commit a163c4188f
2 changed files with 8 additions and 11 deletions

View File

@@ -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

View File

@@ -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 {