mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-06-05 21:59:17 +02:00
fix some crashes related to saving files
This commit is contained in:
@ -326,8 +326,12 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
||||
private fun saveImageFile(path: String) {
|
||||
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
||||
getFileOutputStream(fileDirItem, true) {
|
||||
writeToOutputStream(path, it!!)
|
||||
toast(R.string.file_saved)
|
||||
if (it != null) {
|
||||
writeToOutputStream(path, it)
|
||||
toast(R.string.file_saved)
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,14 @@ object Svg {
|
||||
val backgroundColor = (canvas.background as ColorDrawable).color
|
||||
|
||||
activity.getFileOutputStream(FileDirItem(path, path.getFilenameFromPath()), true) {
|
||||
val writer = BufferedWriter(OutputStreamWriter(it))
|
||||
writeSvg(writer, backgroundColor, canvas.mPaths, canvas.width, canvas.height)
|
||||
writer.close()
|
||||
activity.toast(R.string.file_saved)
|
||||
if (it != null) {
|
||||
val writer = BufferedWriter(OutputStreamWriter(it))
|
||||
writeSvg(writer, backgroundColor, canvas.mPaths, canvas.width, canvas.height)
|
||||
writer.close()
|
||||
activity.toast(R.string.file_saved)
|
||||
} else {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user