use of android.graphics.Picture in project XobotOS by xamarin.
the class WebView method restorePicture.
/**
* Restore the display data that was save in {@link #savePicture}. Used in
* conjunction with {@link #restoreState}.
*
* Note that this will not work if the WebView is hardware accelerated.
* @param b A Bundle containing the saved display data.
* @param src The file where the picture data was stored.
* @return True if the picture was successfully restored.
* @deprecated This method is now obsolete.
*/
@Deprecated
public boolean restorePicture(Bundle b, File src) {
checkThread();
if (src == null || b == null) {
return false;
}
if (!src.exists()) {
return false;
}
try {
final FileInputStream in = new FileInputStream(src);
final Bundle copy = new Bundle(b);
new Thread(new Runnable() {
public void run() {
try {
final Picture p = Picture.createFromStream(in);
if (p != null) {
// Post a runnable on the main thread to update the
// history picture fields.
mPrivateHandler.post(new Runnable() {
public void run() {
restoreHistoryPictureFields(p, copy);
}
});
}
} finally {
try {
in.close();
} catch (Exception e) {
// Nothing we can do now.
}
}
}
}).start();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return true;
}
use of android.graphics.Picture in project XobotOS by xamarin.
the class WebView method capturePicture.
/**
* Return a new picture that captures the current display of the webview.
* This is a copy of the display, and will be unaffected if the webview
* later loads a different URL.
*
* @return a picture containing the current contents of the view. Note this
* picture is of the entire document, and is not restricted to the
* bounds of the view.
*/
public Picture capturePicture() {
checkThread();
if (mNativeClass == 0)
return null;
Picture result = new Picture();
nativeCopyBaseContentToPicture(result);
return result;
}
use of android.graphics.Picture in project XobotOS by xamarin.
the class WebView method savePicture.
/**
* Save the current display data to the Bundle given. Used in conjunction
* with {@link #saveState}.
* @param b A Bundle to store the display data.
* @param dest The file to store the serialized picture data. Will be
* overwritten with this WebView's picture data.
* @return True if the picture was successfully saved.
* @deprecated This method is now obsolete.
*/
@Deprecated
public boolean savePicture(Bundle b, final File dest) {
checkThread();
if (dest == null || b == null) {
return false;
}
final Picture p = capturePicture();
// Use a temporary file while writing to ensure the destination file
// contains valid data.
final File temp = new File(dest.getPath() + ".writing");
new Thread(new Runnable() {
public void run() {
FileOutputStream out = null;
try {
out = new FileOutputStream(temp);
p.writeToStream(out);
// Writing the picture succeeded, rename the temporary file
// to the destination.
temp.renameTo(dest);
} catch (Exception e) {
// too late to do anything about it.
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e) {
// Can't do anything about that
}
}
temp.delete();
}
}
}).start();
// now update the bundle
b.putInt("scrollX", mScrollX);
b.putInt("scrollY", mScrollY);
mZoomManager.saveZoomState(b);
return true;
}
use of android.graphics.Picture in project iosched by google.
the class SVGParser method parse.
static SVG parse(InputSource data, SVGHandler handler) throws SVGParseException {
try {
final Picture picture = new Picture();
handler.setPicture(picture);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.setContentHandler(handler);
xr.setFeature("http://xml.org/sax/features/validation", false);
if (DISALLOW_DOCTYPE_DECL) {
try {
xr.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (SAXNotRecognizedException e) {
DISALLOW_DOCTYPE_DECL = false;
}
}
xr.parse(data);
SVG result = new SVG(picture, handler.bounds);
// Skip bounds if it was an empty pic
if (!Float.isInfinite(handler.limits.top)) {
result.setLimits(handler.limits);
}
return result;
} catch (Exception e) {
Log.e(TAG, "Failed to parse SVG.", e);
throw new SVGParseException(e);
}
}
use of android.graphics.Picture in project SmartAndroidSource by jaychou2012.
the class WebImage method delaySetup.
private void delaySetup() {
wv.setPictureListener(new PictureListener() {
@Override
public void onNewPicture(WebView view, Picture picture) {
wv.setPictureListener(null);
setup();
}
});
//wv.setInitialScale(100);
wv.loadData("<html></html>", "text/html", "utf-8");
wv.setBackgroundColor(color);
}
Aggregations