handle null file parent in some cases

This commit is contained in:
tibbi 2018-04-12 19:21:23 +02:00
parent 22df8edfda
commit e67517dd4c
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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)
}