fixing a couple crashes

This commit is contained in:
tibbi 2017-01-04 21:24:17 +01:00
parent f76a0cf0ce
commit 311f412c87
4 changed files with 4 additions and 4 deletions

View File

@ -32,7 +32,7 @@ android {
} }
dependencies { 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.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1' compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View File

@ -195,7 +195,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
for (delPath in mToBeDeleted) { for (delPath in mToBeDeleted) {
val dir = File(delPath) val dir = File(delPath)
if (dir.exists()) { if (dir.exists()) {
val files = dir.listFiles() val files = dir.listFiles() ?: continue
files.forEach { files.forEach {
if (it.isFile && it.isImageVideoGif()) { if (it.isFile && it.isImageVideoGif()) {
updatedFiles.add(it) updatedFiles.add(it)

View File

@ -244,7 +244,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun deleteDirectoryIfEmpty() { private fun deleteDirectoryIfEmpty() {
val file = File(mDirectory) val file = File(mDirectory)
if (file.isDirectory && file.listFiles().isEmpty()) { if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
file.delete() file.delete()
} }

View File

@ -74,7 +74,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
media.sort() media.sort()
for ((name, path, isVideo, dateModified, dateTaken, size) in media) { for ((name, path, isVideo, dateModified, dateTaken, size) in media) {
val parentDir = File(path).parent val parentDir = File(path).parent ?: continue
if (directories.containsKey(parentDir)) { if (directories.containsKey(parentDir)) {
val directory: Directory = directories[parentDir]!! val directory: Directory = directories[parentDir]!!
val newImageCnt = directory.mediaCnt + 1 val newImageCnt = directory.mediaCnt + 1