Update to coil 2.x API

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-05-20 13:28:47 +02:00
parent 865be74f07
commit 602c197dae
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -46,6 +46,7 @@ import coil.ImageLoader
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.decode.SvgDecoder
import coil.memory.MemoryCache
import com.facebook.cache.disk.DiskCacheConfig
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.core.ImagePipelineConfig
@ -220,15 +221,18 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {
private fun buildDefaultImageLoader(): ImageLoader {
return ImageLoader.Builder(applicationContext)
.availableMemoryPercentage(FIFTY_PERCENT) // Use 50% of the application's available memory.
.memoryCache {
// Use 50% of the application's available memory.
MemoryCache.Builder(applicationContext).maxSizePercent(FIFTY_PERCENT).build()
}
.crossfade(true) // Show a short crossfade when loading images from network or disk into an ImageView.
.componentRegistry {
.components {
if (SDK_INT >= P) {
add(ImageDecoderDecoder(applicationContext))
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder())
add(GifDecoder.Factory())
}
add(SvgDecoder(applicationContext))
add(SvgDecoder.Factory())
}
.okHttpClient(okHttpClient)
.build()