clear coil memory cache when clearing non library covers

This commit is contained in:
Carlos 2021-07-05 12:43:15 -04:00 committed by Jays2Kings
parent 91498139da
commit 9ac99023d9
2 changed files with 4 additions and 3 deletions

View File

@ -99,8 +99,6 @@ class CoverCache(val context: Context) {
fun deleteAllCachedCovers() { fun deleteAllCachedCovers() {
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
val directory = onlineCoverDirectory val directory = onlineCoverDirectory
val size = DiskUtil.getDirectorySize(directory)
var deletedSize = 0L var deletedSize = 0L
val files = val files =
directory.listFiles()?.sortedBy { it.lastModified() }?.iterator() ?: return@launch directory.listFiles()?.sortedBy { it.lastModified() }?.iterator() ?: return@launch
@ -117,7 +115,10 @@ class CoverCache(val context: Context) {
) )
) )
} }
context.imageLoader.memoryCache.clear()
} }
lastClean = System.currentTimeMillis() lastClean = System.currentTimeMillis()
} }

View File

@ -19,7 +19,7 @@ class CoilSetup(context: Context) {
.allowHardware(false) .allowHardware(false)
.componentRegistry { .componentRegistry {
if (Build.VERSION.SDK_INT >= 28) { if (Build.VERSION.SDK_INT >= 28) {
add(ImageDecoderDecoder()) add(ImageDecoderDecoder(context))
} else { } else {
add(GifDecoder()) add(GifDecoder())
} }