mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
Minor code improvements
This commit is contained in:
parent
e2d0767cc3
commit
46533e4b45
1 changed files with 6 additions and 8 deletions
|
@ -373,18 +373,16 @@ fun Context.rescanFolderMedia(path: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.rescanFolderMediaSync(path: String) {
|
fun Context.rescanFolderMediaSync(path: String) {
|
||||||
getCachedMedia(path) {
|
getCachedMedia(path) { cached ->
|
||||||
val cached = it
|
GetMediaAsynctask(applicationContext, path, isPickImage = false, isPickVideo = false, showAll = false) { newMedia ->
|
||||||
GetMediaAsynctask(applicationContext, path, false, false, false) {
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val newMedia = it
|
val media = newMedia.filterIsInstance<Medium>() as ArrayList<Medium>
|
||||||
val media = newMedia.filter { it is Medium } as ArrayList<Medium>
|
|
||||||
try {
|
try {
|
||||||
mediaDB.insertAll(media)
|
mediaDB.insertAll(media)
|
||||||
|
|
||||||
cached.forEach {
|
cached.forEach { thumbnailItem ->
|
||||||
if (!newMedia.contains(it)) {
|
if (!newMedia.contains(thumbnailItem)) {
|
||||||
val mediumPath = (it as? Medium)?.path
|
val mediumPath = (thumbnailItem as? Medium)?.path
|
||||||
if (mediumPath != null) {
|
if (mediumPath != null) {
|
||||||
deleteDBPath(mediumPath)
|
deleteDBPath(mediumPath)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue