am 2d743fe2: merge from open-source master
Merge commit '2d743fe2f39397d41334001d897eb78da56e94ef' into kraken * commit '2d743fe2f39397d41334001d897eb78da56e94ef': Add better error handling for savePicture and restorePicture
This commit is contained in:
committed by
Android Git Automerger
commit
7c035d8a65
@@ -1380,16 +1380,23 @@ public class WebView extends AbsoluteLayout
|
|||||||
final File temp = new File(dest.getPath() + ".writing");
|
final File temp = new File(dest.getPath() + ".writing");
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
FileOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
FileOutputStream out = new FileOutputStream(temp);
|
out = new FileOutputStream(temp);
|
||||||
p.writeToStream(out);
|
p.writeToStream(out);
|
||||||
out.close();
|
|
||||||
// Writing the picture succeeded, rename the temporary file
|
// Writing the picture succeeded, rename the temporary file
|
||||||
// to the destination.
|
// to the destination.
|
||||||
temp.renameTo(dest);
|
temp.renameTo(dest);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// too late to do anything about it.
|
// too late to do anything about it.
|
||||||
} finally {
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Can't do anything about that
|
||||||
|
}
|
||||||
|
}
|
||||||
temp.delete();
|
temp.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1442,6 +1449,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
final Bundle copy = new Bundle(b);
|
final Bundle copy = new Bundle(b);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
try {
|
||||||
final Picture p = Picture.createFromStream(in);
|
final Picture p = Picture.createFromStream(in);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
// Post a runnable on the main thread to update the
|
// Post a runnable on the main thread to update the
|
||||||
@@ -1452,12 +1460,14 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Nothing we can do now.
|
// Nothing we can do now.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} catch (FileNotFoundException e){
|
} catch (FileNotFoundException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user