From 311f412c87b7e501bfbce101b8fb65481d36cbd9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 4 Jan 2017 21:24:17 +0100 Subject: [PATCH] fixing a couple crashes --- app/build.gradle | 2 +- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 +- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 2 +- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5eacf3711..559d56d2d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.1.2' + compile 'com.simplemobiletools:commons:2.1.5' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 266cbed2e..f545f14fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -195,7 +195,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { for (delPath in mToBeDeleted) { val dir = File(delPath) if (dir.exists()) { - val files = dir.listFiles() + val files = dir.listFiles() ?: continue files.forEach { if (it.isFile && it.isImageVideoGif()) { updatedFiles.add(it) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 48ec61ff6..fb1e21004 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -244,7 +244,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun deleteDirectoryIfEmpty() { val file = File(mDirectory) - if (file.isDirectory && file.listFiles().isEmpty()) { + if (file.isDirectory && file.listFiles()?.isEmpty() == true) { file.delete() } 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 5d10d9430..dddbcabab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -74,7 +74,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va media.sort() for ((name, path, isVideo, dateModified, dateTaken, size) in media) { - val parentDir = File(path).parent + val parentDir = File(path).parent ?: continue if (directories.containsKey(parentDir)) { val directory: Directory = directories[parentDir]!! val newImageCnt = directory.mediaCnt + 1