Fix remaining createScreenshot references
Fixed references to createScreenshot method which was returning a null
bitmap. createScreenshot method was implemented using the older
getViewportBitmap synchronous API which was deprecated. WebView exposes
an asynchronous method getContentBitmapAsync to retrieve a bitmap of the
current view. Modified calls to use the getContentBitmapAsync API.
This also fixes the issue seen where an async task was fired in a loop
to retrieve the bitmap resulting in wasted CPU cycles.
Change-Id: Ic6d8385d41d90c58fdffcebcbca7ebd68381530f
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 861d68f..d4d6cba 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1989,7 +1989,7 @@
/**
* Must be called on the UI thread
*/
- public ContentValues createSnapshotValues() {
+ public ContentValues createSnapshotValues(Bitmap bm) {
WebView web = getWebView();
if (web == null) return null;
ContentValues values = new ContentValues();
@@ -1998,10 +1998,7 @@
values.put(Snapshots.BACKGROUND, web.getPageBackgroundColor());
values.put(Snapshots.DATE_CREATED, System.currentTimeMillis());
values.put(Snapshots.FAVICON, compressBitmap(getFavicon()));
- Bitmap screenshot = Controller.createScreenshot(web,
- Controller.getDesiredThumbnailWidth(mWebViewController.getActivity()),
- Controller.getDesiredThumbnailHeight(mWebViewController.getActivity()));
- values.put(Snapshots.THUMBNAIL, compressBitmap(screenshot));
+ values.put(Snapshots.THUMBNAIL, compressBitmap(bm));
return values;
}