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 {
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'

View file

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

View file

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

View file

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