fix some crashes related to saving files
This commit is contained in:
parent
73637c6305
commit
3249e9b2bc
|
@ -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!!)
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue