adding a null check at photo saving

This commit is contained in:
tibbi 2018-03-31 23:33:47 +02:00
parent 43ff590e64
commit 2f08c2b59e
1 changed files with 8 additions and 2 deletions

View File

@ -51,7 +51,12 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
var document = activity.getDocumentFile(path.getParentPath()) var document = activity.getDocumentFile(path.getParentPath())
document = document?.createFile("", path.substring(path.lastIndexOf('/') + 1)) 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 { } else {
fos = if (uri == null) { fos = if (uri == null) {
FileOutputStream(photoFile) FileOutputStream(photoFile)
@ -100,8 +105,9 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
exifOrientation = getExifOrientation(totalRotation) exifOrientation = getExifOrientation(totalRotation)
} }
if (activity.config.savePhotoMetadata) if (activity.config.savePhotoMetadata) {
tempExif.copyTo(fileExif) tempExif.copyTo(fileExif)
}
fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation) fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation)
try { try {