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