From ff79038efaf462976d2efc15030a99f93ed7983b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 30 Sep 2019 15:04:55 +0200 Subject: [PATCH] avoid concurrent arraylist modification at portrait fetching --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 0412fd4ba..9d4201e3a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -620,12 +620,14 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag } if (config.filterMedia and TYPE_PORTRAITS != 0) { + val foldersToAdd = ArrayList() for (folder in foldersToScan) { val allFiles = File(folder).listFiles() ?: continue allFiles.filter { it.isDirectory && it.name.startsWith("img_", true) }.forEach { - foldersToScan.add(it.absolutePath) + foldersToAdd.add(it.absolutePath) } } + foldersToScan.addAll(foldersToAdd) } val shouldShowHidden = config.shouldShowHidden