From 70d66f320082a1b255658e295da37d9d7ae20ab9 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Wed, 31 Jul 2024 16:01:11 +0200 Subject: [PATCH] Add some cache to Coil --- app/src/main/java/com/readrops/app/ReadropsApp.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/readrops/app/ReadropsApp.kt b/app/src/main/java/com/readrops/app/ReadropsApp.kt index 706e244e..4c317dea 100644 --- a/app/src/main/java/com/readrops/app/ReadropsApp.kt +++ b/app/src/main/java/com/readrops/app/ReadropsApp.kt @@ -6,6 +6,7 @@ import android.app.NotificationManager import android.os.Build import coil.ImageLoader import coil.ImageLoaderFactory +import coil.disk.DiskCache import com.readrops.api.apiModule import com.readrops.db.dbModule import org.koin.android.ext.koin.androidContext @@ -33,6 +34,12 @@ open class ReadropsApp : Application(), KoinComponent, ImageLoaderFactory { override fun newImageLoader(): ImageLoader { return ImageLoader.Builder(this) .okHttpClient { get() } + .diskCache { + DiskCache.Builder() + .directory(this.cacheDir.resolve("image_cache")) + .maxSizePercent(0.05) + .build() + } .crossfade(true) .build() }