close the inputStream after using at the editor activity

This commit is contained in:
tibbi 2018-12-17 21:14:28 +01:00
parent a909e70794
commit 555c18ae4f
1 changed files with 4 additions and 1 deletions

View File

@ -593,14 +593,17 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out) bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
} }
var inputStream: InputStream? = null
try { try {
if (isNougatPlus()) { if (isNougatPlus()) {
val inputStream = contentResolver.openInputStream(uri) inputStream = contentResolver.openInputStream(uri)
val oldExif = ExifInterface(inputStream) val oldExif = ExifInterface(inputStream)
val newExif = ExifInterface(file.absolutePath) val newExif = ExifInterface(file.absolutePath)
oldExif.copyTo(newExif, false) oldExif.copyTo(newExif, false)
} }
} catch (e: Exception) { } catch (e: Exception) {
} finally {
inputStream?.close()
} }
setResult(Activity.RESULT_OK, intent) setResult(Activity.RESULT_OK, intent)