Bug 884075 - Add a method to get drawables from urls in BitmapUtils. r=margaret

This commit is contained in:
Wes Johnston 2013-07-16 01:33:05 -07:00
parent 57ecfb5bd8
commit df030b6d15

View File

@ -1442,31 +1442,17 @@ abstract public class BrowserApp extends GeckoApp
});
if (info.icon != null) {
if (info.icon.startsWith("data")) {
BitmapDrawable drawable = new BitmapDrawable(BitmapUtils.getBitmapFromDataURI(info.icon));
item.setIcon(drawable);
}
else if (info.icon.startsWith("jar:") || info.icon.startsWith("file://")) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(info.icon);
InputStream is = (InputStream) url.getContent();
try {
Drawable drawable = Drawable.createFromStream(is, "src");
item.setIcon(drawable);
} finally {
is.close();
}
} catch (Exception e) {
Log.w(LOGTAG, "Unable to set icon", e);
}
BitmapUtils.getDrawable(this, info.icon, new BitmapUtils.BitmapLoader() {
@Override
public void onBitmapFound(Drawable d) {
if (d == null) {
item.setIcon(R.drawable.ic_menu_addons_filler);
return;
}
});
} else {
item.setIcon(R.drawable.ic_menu_addons_filler);
}
item.setIcon(d);
}
});
} else {
item.setIcon(R.drawable.ic_menu_addons_filler);
}