mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Bug 785945 - Add API to get multiple favicons at once from DB (r=mfinkle)
This commit is contained in:
parent
af2ef6a1b1
commit
52bfd3537a
@ -12,6 +12,8 @@ import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BrowserDB {
|
||||
public static String ABOUT_PAGES_URL_FILTER = "about:%";
|
||||
|
||||
@ -73,6 +75,8 @@ public class BrowserDB {
|
||||
|
||||
public BitmapDrawable getFaviconForUrl(ContentResolver cr, String uri);
|
||||
|
||||
public Cursor getFaviconsForUrls(ContentResolver cr, List<String> urls);
|
||||
|
||||
public void updateFaviconForUrl(ContentResolver cr, String uri, BitmapDrawable favicon);
|
||||
|
||||
public void updateThumbnailForUrl(ContentResolver cr, String uri, BitmapDrawable thumbnail);
|
||||
@ -186,6 +190,10 @@ public class BrowserDB {
|
||||
return sDb.getFaviconForUrl(cr, uri);
|
||||
}
|
||||
|
||||
public static Cursor getFaviconsForUrls(ContentResolver cr, List<String> urls) {
|
||||
return sDb.getFaviconsForUrls(cr, urls);
|
||||
}
|
||||
|
||||
public static void updateFaviconForUrl(ContentResolver cr, String uri, BitmapDrawable favicon) {
|
||||
sDb.updateFaviconForUrl(cr, uri, favicon);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import android.util.Log;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
// Calculate these once, at initialization. isLoggable is too expensive to
|
||||
@ -619,6 +620,27 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
return new BitmapDrawable(bitmap);
|
||||
}
|
||||
|
||||
public Cursor getFaviconsForUrls(ContentResolver cr, List<String> urls) {
|
||||
StringBuffer selection = new StringBuffer();
|
||||
String[] selectionArgs = new String[urls.size()];
|
||||
|
||||
for (int i = 0; i < urls.size(); i++) {
|
||||
final String url = urls.get(i);
|
||||
|
||||
if (i > 0)
|
||||
selection.append(" OR ");
|
||||
|
||||
selection.append(Images.URL + " = ?");
|
||||
selectionArgs[i] = url;
|
||||
}
|
||||
|
||||
return cr.query(mImagesUriWithProfile,
|
||||
new String[] { Images.URL, Images.FAVICON },
|
||||
selection.toString(),
|
||||
selectionArgs,
|
||||
null);
|
||||
}
|
||||
|
||||
public void updateFaviconForUrl(ContentResolver cr, String uri,
|
||||
BitmapDrawable favicon) {
|
||||
Bitmap bitmap = favicon.getBitmap();
|
||||
|
Loading…
Reference in New Issue
Block a user