Let saving as .svg exceptions propagate
This commit is contained in:
parent
1acc5e2498
commit
eea21a185c
|
@ -12,17 +12,12 @@ import java.util.Map;
|
|||
|
||||
public class Svg {
|
||||
|
||||
public static boolean saveSvg(File output, MyCanvas canvas) {
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(output);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
|
||||
writeSvg(writer, canvas.getPaths(), canvas.getWidth(), canvas.getHeight());
|
||||
writer.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
public static void saveSvg(File output, MyCanvas canvas)
|
||||
throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(output);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
|
||||
writeSvg(writer, canvas.getPaths(), canvas.getWidth(), canvas.getHeight());
|
||||
writer.close();
|
||||
}
|
||||
|
||||
private static void writeSvg(Writer writer,
|
||||
|
|
|
@ -218,7 +218,7 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
|
|||
MediaScannerConnection.scanFile(getApplicationContext(),
|
||||
new String[]{file.getAbsolutePath()}, null, null);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "MainActivity SaveFile " + e.getMessage());
|
||||
Log.e(TAG, "MainActivity SaveFile (.png) " + e.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
|
@ -226,14 +226,16 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
|
|||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "MainActivity SaveFile 2 " + e.getMessage());
|
||||
Log.e(TAG, "MainActivity SaveFile (.png) 2 " + e.getMessage());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ".svg":
|
||||
if (!Svg.saveSvg(file, mMyCanvas)) {
|
||||
Log.e(TAG, "MainActivity SaveFile failed.");
|
||||
try {
|
||||
Svg.saveSvg(file, mMyCanvas);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "MainActivity SaveFile (.svg) " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue