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) {
|
private fun saveImageFile(path: String) {
|
||||||
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
||||||
getFileOutputStream(fileDirItem, true) {
|
getFileOutputStream(fileDirItem, true) {
|
||||||
writeToOutputStream(path, it!!)
|
if (it != null) {
|
||||||
|
writeToOutputStream(path, it)
|
||||||
toast(R.string.file_saved)
|
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
|
val backgroundColor = (canvas.background as ColorDrawable).color
|
||||||
|
|
||||||
activity.getFileOutputStream(FileDirItem(path, path.getFilenameFromPath()), true) {
|
activity.getFileOutputStream(FileDirItem(path, path.getFilenameFromPath()), true) {
|
||||||
|
if (it != null) {
|
||||||
val writer = BufferedWriter(OutputStreamWriter(it))
|
val writer = BufferedWriter(OutputStreamWriter(it))
|
||||||
writeSvg(writer, backgroundColor, canvas.mPaths, canvas.width, canvas.height)
|
writeSvg(writer, backgroundColor, canvas.mPaths, canvas.width, canvas.height)
|
||||||
writer.close()
|
writer.close()
|
||||||
activity.toast(R.string.file_saved)
|
activity.toast(R.string.file_saved)
|
||||||
|
} else {
|
||||||
|
activity.toast(R.string.unknown_error_occurred)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user