Updated on 2026-08-14
This commit is contained in:
parent
509d1ffd3c
commit
df39526354
11 changed files with 241 additions and 20 deletions
|
|
@ -3,12 +3,14 @@ package com.tangem.tap.common.images
|
|||
import android.content.Context
|
||||
import android.util.Log
|
||||
import coil.ImageLoader
|
||||
import coil.memory.MemoryCache
|
||||
import coil.util.Logger
|
||||
import com.tangem.datasource.api.common.createNetworkLoggingInterceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import timber.log.Timber
|
||||
|
||||
private const val COIL_LOG_TAG = "COIL"
|
||||
private const val COIL_MEMORY_CACHE_SIZE = 0.25
|
||||
|
||||
fun createCoilImageLoader(context: Context, logEnabled: Boolean = false): ImageLoader {
|
||||
return ImageLoader.Builder(context)
|
||||
|
|
@ -22,6 +24,11 @@ fun createCoilImageLoader(context: Context, logEnabled: Boolean = false): ImageL
|
|||
.build()
|
||||
}
|
||||
}
|
||||
.memoryCache {
|
||||
MemoryCache.Builder(context)
|
||||
.maxSizePercent(COIL_MEMORY_CACHE_SIZE)
|
||||
.build()
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.tangem.tap.common.images
|
||||
|
||||
import android.content.Context
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import com.tangem.core.ui.coil.ImagePreloader
|
||||
|
||||
internal class DefaultImagePreloader(
|
||||
private val appContext: Context,
|
||||
) : ImagePreloader {
|
||||
override fun preload(url: String) {
|
||||
appContext.imageLoader.enqueue(
|
||||
ImageRequest.Builder(appContext)
|
||||
.data(url)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue