Add some cache to Coil

This commit is contained in:
Shinokuni 2024-07-31 16:01:11 +02:00
parent c932022fe6
commit 70d66f3200
1 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import android.app.NotificationManager
import android.os.Build import android.os.Build
import coil.ImageLoader import coil.ImageLoader
import coil.ImageLoaderFactory import coil.ImageLoaderFactory
import coil.disk.DiskCache
import com.readrops.api.apiModule import com.readrops.api.apiModule
import com.readrops.db.dbModule import com.readrops.db.dbModule
import org.koin.android.ext.koin.androidContext import org.koin.android.ext.koin.androidContext
@ -33,6 +34,12 @@ open class ReadropsApp : Application(), KoinComponent, ImageLoaderFactory {
override fun newImageLoader(): ImageLoader { override fun newImageLoader(): ImageLoader {
return ImageLoader.Builder(this) return ImageLoader.Builder(this)
.okHttpClient { get() } .okHttpClient { get() }
.diskCache {
DiskCache.Builder()
.directory(this.cacheDir.resolve("image_cache"))
.maxSizePercent(0.05)
.build()
}
.crossfade(true) .crossfade(true)
.build() .build()
} }