Selaa lähdekoodia

Update to coil 2.x API

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 vuotta sitten
vanhempi
commit
602c197dae

+ 9 - 5
app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt

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