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 224918 724b56b852ef40e11cf9fd2c204cd40138cd8e4b
parent 224917 46ddbee26635ab23a6f62d9b2dcee51681473e74
child 224919 8199e1f796a5163bace71916e785291e136d8783
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr, sledru
bugs1063896
milestone34.0a2
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
@@ -668,16 +668,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 {
@@ -714,32 +718,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);