Improvements as suggested
This commit is contained in:
parent
63d39b589a
commit
598eeb154d
1 changed files with 3 additions and 7 deletions
|
@ -477,7 +477,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
copyFile(tmpFile, selectedFile)
|
copyFile(tmpFile, selectedFile)
|
||||||
scanPath(selectedFile.absolutePath) {}
|
scanPath(selectedFile.absolutePath) {}
|
||||||
deleteFile(tmpFile) {} // Not necessary?
|
|
||||||
toast(R.string.file_saved)
|
toast(R.string.file_saved)
|
||||||
|
|
||||||
it.flush()
|
it.flush()
|
||||||
|
@ -487,9 +486,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
toast(R.string.out_of_memory_error)
|
toast(R.string.out_of_memory_error)
|
||||||
deleteFile(tmpFile) {}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
|
} finally {
|
||||||
deleteFile(tmpFile) {}
|
deleteFile(tmpFile) {}
|
||||||
}
|
}
|
||||||
}).start()
|
}).start()
|
||||||
|
@ -500,9 +499,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
var inputStream: InputStream? = null
|
var inputStream: InputStream? = null
|
||||||
var out: OutputStream? = null
|
var out: OutputStream? = null
|
||||||
try {
|
try {
|
||||||
if (needsStupidWritePermissions(destination.absolutePath)) {
|
|
||||||
getFileDocument(destination.parent)
|
|
||||||
}
|
|
||||||
out = getFileOutputStreamSync(destination.absolutePath, source.getMimeType(), getFileDocument(destination.parent))
|
out = getFileOutputStreamSync(destination.absolutePath, source.getMimeType(), getFileDocument(destination.parent))
|
||||||
inputStream = FileInputStream(source)
|
inputStream = FileInputStream(source)
|
||||||
inputStream.copyTo(out!!)
|
inputStream.copyTo(out!!)
|
||||||
|
@ -522,8 +518,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun saveRotation(input: File, output: File) {
|
private fun saveRotation(input: File, output: File) {
|
||||||
copyFile(input, output)
|
copyFile(input, output)
|
||||||
val exif = ExifInterface(output.absolutePath)
|
val exif = ExifInterface(output.absolutePath)
|
||||||
var orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
||||||
var orientationDegrees = (degreesForRotation(orientation) + mRotationDegrees) % 360
|
val orientationDegrees = (degreesForRotation(orientation) + mRotationDegrees) % 360
|
||||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, rotationFromDegrees(orientationDegrees))
|
exif.setAttribute(ExifInterface.TAG_ORIENTATION, rotationFromDegrees(orientationDegrees))
|
||||||
exif.saveAttributes()
|
exif.saveAttributes()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue