From 2f08c2b59e860fd61d7cb8625a16fc807561872d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 31 Mar 2018 23:33:47 +0200 Subject: [PATCH] adding a null check at photo saving --- .../simplemobiletools/camera/helpers/PhotoProcessor.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/PhotoProcessor.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/PhotoProcessor.kt index 7da596c7..fa00253a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/PhotoProcessor.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/PhotoProcessor.kt @@ -51,7 +51,12 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId var document = activity.getDocumentFile(path.getParentPath()) document = document?.createFile("", path.substring(path.lastIndexOf('/') + 1)) - fos = activity.contentResolver.openOutputStream(document?.uri) + if (document == null) { + activity.toast(R.string.save_error_internal_storage) + return "" + } + + fos = activity.contentResolver.openOutputStream(document.uri) } else { fos = if (uri == null) { FileOutputStream(photoFile) @@ -100,8 +105,9 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId exifOrientation = getExifOrientation(totalRotation) } - if (activity.config.savePhotoMetadata) + if (activity.config.savePhotoMetadata) { tempExif.copyTo(fileExif) + } fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation) try {