Bug 889564 - ANR: LightweightTheme.handleMessage can block the Gecko thread r=sriram

This commit is contained in:
Mark Finkle 2013-07-12 00:07:55 -04:00
parent 35e27da6d6
commit 5bcb85c6db

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.ThreadUtils;
import org.json.JSONObject;
@ -75,17 +76,25 @@ public class LightweightTheme implements GeckoEventListener {
try {
if (event.equals("LightweightTheme:Update")) {
JSONObject lightweightTheme = message.getJSONObject("data");
String headerURL = lightweightTheme.getString("headerURL");
int mark = headerURL.indexOf('?');
if (mark != -1)
headerURL = headerURL.substring(0, mark);
final String headerURL = lightweightTheme.getString("headerURL");
// Get the image and convert it to a bitmap.
final Bitmap bitmap = BitmapUtils.decodeUrl(headerURL);
mHandler.post(new Runnable() {
// Move any heavy lifting off the Gecko thread
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
setLightweightTheme(bitmap);
String croppedURL = headerURL;
int mark = croppedURL.indexOf('?');
if (mark != -1)
croppedURL = croppedURL.substring(0, mark);
// Get the image and convert it to a bitmap.
final Bitmap bitmap = BitmapUtils.decodeUrl(croppedURL);
mHandler.post(new Runnable() {
@Override
public void run() {
setLightweightTheme(bitmap);
}
});
}
});
} else if (event.equals("LightweightTheme:Disable")) {