Bug 1063896 - Loop over all url list, not just ones with metadata. r=lucasr, a=sledru
authorWes Johnston <wjohnston@mozilla.com>
Tue, 16 Sep 2014 17:16:42 -0700
changeset 216783 792d0824a8f0
parent 216782 1e3320340bd2
child 216784 01411f43df67
push id3910
push userryanvm@gmail.com
push date2014-09-18 14:48 +0000
treeherdermozilla-beta@af1dbe183e3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr, sledru
bugs1063896
milestone33.0
Bug 1063896 - Loop over all url list, not just ones with metadata. r=lucasr, a=sledru
mobile/android/base/home/TopSitesPanel.java
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -705,16 +705,20 @@ public class TopSitesPanel extends HomeF
 
         public ThumbnailInfo(final String imageUrl, final int bgColor) {
             this.bitmap = null;
             this.imageUrl = imageUrl;
             this.bgColor = bgColor;
         }
 
         public static ThumbnailInfo fromMetadata(final Map<String, Object> data) {
+            if (data == null) {
+                return null;
+            }
+
             final String imageUrl = (String) data.get(TILE_IMAGE_URL_COLUMN);
             if (imageUrl == null) {
                 return null;
             }
 
             int bgColor = Color.WHITE;
             final String colorString = (String) data.get(TILE_COLOR_COLUMN);
             try {
@@ -751,32 +755,26 @@ public class TopSitesPanel extends HomeF
                 return thumbnails;
             }
 
             // Query the DB for tile images.
             final ContentResolver cr = getContext().getContentResolver();
             final Map<String, Map<String, Object>> metadata = URLMetadata.getForUrls(cr, mUrls, COLUMNS);
 
             // Keep a list of urls that don't have tiles images. We'll use thumbnails for them instead.
-            final List<String> thumbnailUrls;
-            if (metadata != null) {
-                thumbnailUrls = new ArrayList<String>();
+            final List<String> thumbnailUrls = new ArrayList<String>();
+            for (String url : mUrls) {
+                ThumbnailInfo info = ThumbnailInfo.fromMetadata(metadata.get(url));
+                if (info == null) {
+                    // If we didn't find metadata, we'll look for a thumbnail for this url.
+                    thumbnailUrls.add(url);
+                    continue;
+                }
 
-                for (String url : metadata.keySet()) {
-                    ThumbnailInfo info = ThumbnailInfo.fromMetadata(metadata.get(url));
-                    if (info == null) {
-                        // If we didn't find metadata, we'll look for a thumbnail for this url.
-                        thumbnailUrls.add(url);
-                        continue;
-                    }
-
-                    thumbnails.put(url, info);
-                }
-            } else {
-                thumbnailUrls = new ArrayList<String>(mUrls);
+                thumbnails.put(url, info);
             }
 
             if (thumbnailUrls.size() == 0) {
                 return thumbnails;
             }
 
             // Query the DB for tile thumbnails.
             final Cursor cursor = BrowserDB.getThumbnailsForUrls(cr, thumbnailUrls);