mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-06-05 21:59:17 +02:00
Let saving as .svg exceptions propagate
This commit is contained in:
@ -12,17 +12,12 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Svg {
|
public class Svg {
|
||||||
|
|
||||||
public static boolean saveSvg(File output, MyCanvas canvas) {
|
public static void saveSvg(File output, MyCanvas canvas)
|
||||||
try {
|
throws IOException {
|
||||||
FileOutputStream out = new FileOutputStream(output);
|
FileOutputStream out = new FileOutputStream(output);
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
|
||||||
writeSvg(writer, canvas.getPaths(), canvas.getWidth(), canvas.getHeight());
|
writeSvg(writer, canvas.getPaths(), canvas.getWidth(), canvas.getHeight());
|
||||||
writer.close();
|
writer.close();
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeSvg(Writer writer,
|
private static void writeSvg(Writer writer,
|
||||||
|
@ -218,7 +218,7 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
|
|||||||
MediaScannerConnection.scanFile(getApplicationContext(),
|
MediaScannerConnection.scanFile(getApplicationContext(),
|
||||||
new String[]{file.getAbsolutePath()}, null, null);
|
new String[]{file.getAbsolutePath()}, null, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "MainActivity SaveFile " + e.getMessage());
|
Log.e(TAG, "MainActivity SaveFile (.png) " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@ -226,14 +226,16 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "MainActivity SaveFile 2 " + e.getMessage());
|
Log.e(TAG, "MainActivity SaveFile (.png) 2 " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ".svg":
|
case ".svg":
|
||||||
if (!Svg.saveSvg(file, mMyCanvas)) {
|
try {
|
||||||
Log.e(TAG, "MainActivity SaveFile failed.");
|
Svg.saveSvg(file, mMyCanvas);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "MainActivity SaveFile (.svg) " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user