diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index e9d25e99e..19f73ddde 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -38,7 +38,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val firstItem = curMedia.first() val lastItem = curMedia.last() - val parentDir = if (hasOTG && firstItem.path.startsWith(OTG_PATH)) firstItem.path.getParentPath() else File(firstItem.path).parent + val parentDir = if (hasOTG && firstItem.path.startsWith(OTG_PATH)) firstItem.path.getParentPath() else File(firstItem.path).parent ?: continue var thumbnail = curMedia.firstOrNull { context.getDoesFilePathExist(it.path) }?.path ?: "" if (thumbnail.startsWith(OTG_PATH)) { thumbnail = thumbnail.getOTGPublicPath(context) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index b212851f3..61e88604b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -113,7 +113,7 @@ class MediaFetcher(val context: Context) { if (cursor.moveToFirst()) { do { val path = cursor.getStringValue(MediaStore.Images.Media.DATA).trim() - val parentPath = File(path).parent.trimEnd('/') + val parentPath = File(path).parent?.trimEnd('/') ?: continue if (!includedFolders.contains(parentPath)) { foldersToScan.add(parentPath) }