mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-27 16:55:03 +01:00
save the images on a background thread
This commit is contained in:
parent
972916f6b2
commit
4786fc7c54
@ -232,27 +232,29 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
private fun saveImageAs() {
|
||||
val currPath = getCurrentPath()
|
||||
SaveAsDialog(this, currPath) {
|
||||
val selectedFile = File(it)
|
||||
val tmpFile = File(selectedFile.parent, "tmp_${it.getFilenameFromPath()}")
|
||||
try {
|
||||
val bitmap = BitmapFactory.decodeFile(currPath)
|
||||
getFileOutputStream(tmpFile) {
|
||||
saveFile(tmpFile, bitmap, it)
|
||||
if (needsStupidWritePermissions(selectedFile.absolutePath)) {
|
||||
deleteFile(selectedFile) {}
|
||||
}
|
||||
Thread({
|
||||
val selectedFile = File(it)
|
||||
val tmpFile = File(selectedFile.parent, "tmp_${it.getFilenameFromPath()}")
|
||||
try {
|
||||
val bitmap = BitmapFactory.decodeFile(currPath)
|
||||
getFileOutputStream(tmpFile) {
|
||||
saveFile(tmpFile, bitmap, it)
|
||||
if (needsStupidWritePermissions(selectedFile.absolutePath)) {
|
||||
deleteFile(selectedFile) {}
|
||||
}
|
||||
|
||||
renameFile(tmpFile, selectedFile) {
|
||||
deleteFile(tmpFile) {}
|
||||
renameFile(tmpFile, selectedFile) {
|
||||
deleteFile(tmpFile) {}
|
||||
}
|
||||
}
|
||||
} catch (e: OutOfMemoryError) {
|
||||
toast(R.string.out_of_memory_error)
|
||||
deleteFile(tmpFile) {}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
deleteFile(tmpFile) {}
|
||||
}
|
||||
} catch (e: OutOfMemoryError) {
|
||||
toast(R.string.out_of_memory_error)
|
||||
deleteFile(tmpFile) {}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
deleteFile(tmpFile) {}
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user