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,7 +604,9 @@ 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
|
||||||
|
|
||||||
|
try {
|
||||||
val mediaToDelete = ArrayList<Medium>()
|
val mediaToDelete = ArrayList<Medium>()
|
||||||
|
Thread {
|
||||||
media.filter { !getDoesFilePathExist(it.path, OTGPath) }.forEach {
|
media.filter { !getDoesFilePathExist(it.path, OTGPath) }.forEach {
|
||||||
if (it.path.startsWith(recycleBinPath)) {
|
if (it.path.startsWith(recycleBinPath)) {
|
||||||
deleteDBPath(it.path)
|
deleteDBPath(it.path)
|
||||||
@ -613,7 +615,6 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (mediaToDelete.isNotEmpty()) {
|
if (mediaToDelete.isNotEmpty()) {
|
||||||
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
||||||
|
|
||||||
@ -621,6 +622,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||||||
favoritesDB.deleteFavoritePath(it.path)
|
favoritesDB.deleteFavoritePath(it.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.start()
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user