mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
use a different thread for doing database things at folder thumbnails view
This commit is contained in:
@ -604,23 +604,25 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||||||
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
||||||
val OTGPath = config.OTGPath
|
val OTGPath = config.OTGPath
|
||||||
|
|
||||||
val mediaToDelete = ArrayList<Medium>()
|
|
||||||
media.filter { !getDoesFilePathExist(it.path, OTGPath) }.forEach {
|
|
||||||
if (it.path.startsWith(recycleBinPath)) {
|
|
||||||
deleteDBPath(it.path)
|
|
||||||
} else {
|
|
||||||
mediaToDelete.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mediaToDelete.isNotEmpty()) {
|
val mediaToDelete = ArrayList<Medium>()
|
||||||
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
Thread {
|
||||||
|
media.filter { !getDoesFilePathExist(it.path, OTGPath) }.forEach {
|
||||||
mediaToDelete.filter { it.isFavorite }.forEach {
|
if (it.path.startsWith(recycleBinPath)) {
|
||||||
favoritesDB.deleteFavoritePath(it.path)
|
deleteDBPath(it.path)
|
||||||
|
} else {
|
||||||
|
mediaToDelete.add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (mediaToDelete.isNotEmpty()) {
|
||||||
|
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
||||||
|
|
||||||
|
mediaToDelete.filter { it.isFavorite }.forEach {
|
||||||
|
favoritesDB.deleteFavoritePath(it.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user