Bug 931843 - Part 3: Don't retain thumbnails. r=bnicholson, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Mon, 04 Nov 2013 11:48:58 -0800
changeset 167375 5437dcd8200e6a7d1f55dc1bd6d7174d2e026da6
parent 167374 644c588e3e36cf653fc06a09fb20ccef148e1856
child 167376 fed7434e96fba56fca75b323dd9b82b6ac5f79fc
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson, bajaj
bugs931843
milestone27.0a2
Bug 931843 - Part 3: Don't retain thumbnails. r=bnicholson, a=bajaj
mobile/android/base/home/TopSitesGridItemView.java
mobile/android/base/home/TwoLinePageRow.java
--- a/mobile/android/base/home/TopSitesGridItemView.java
+++ b/mobile/android/base/home/TopSitesGridItemView.java
@@ -38,17 +38,17 @@ public class TopSitesGridItemView extend
     private final TextView mTitleView;
     private final ImageView mThumbnailView;
 
     // Data backing this view.
     private String mTitle;
     private String mUrl;
     private String mFaviconURL;
 
-    private Bitmap mThumbnail;
+    private boolean mThumbnailSet;
 
     // Pinned state.
     private boolean mIsPinned = false;
 
     // Empty state.
     private boolean mIsEmpty = true;
     private int mLoadId = Favicons.NOT_LOADING;
 
@@ -165,17 +165,17 @@ public class TopSitesGridItemView extend
             changed = true;
         }
 
         if (thumbnail != null) {
             displayThumbnail(thumbnail);
         } else if (changed) {
             // Because we'll have a new favicon or thumbnail arriving shortly, and
             // we need to not reject it because we already had a thumbnail.
-            mThumbnail = null;
+            mThumbnailSet = false;
         }
 
         if (changed) {
             updateTitleView();
             setLoadId(Favicons.NOT_LOADING);
         }
 
         if (mIsPinned != pinned) {
@@ -191,30 +191,31 @@ public class TopSitesGridItemView extend
      * Display the thumbnail from a resource.
      *
      * @param resId Resource ID of the drawable to show.
      */
     public void displayThumbnail(int resId) {
         mThumbnailView.setScaleType(SCALE_TYPE_RESOURCE);
         mThumbnailView.setImageResource(resId);
         mThumbnailView.setBackgroundColor(0x0);
+        mThumbnailSet = false;
     }
 
     /**
      * Display the thumbnail from a bitmap.
      *
      * @param thumbnail The bitmap to show as thumbnail.
      */
     public void displayThumbnail(Bitmap thumbnail) {
         if (thumbnail == null) {
             // Show a favicon based view instead.
             displayThumbnail(R.drawable.favicon);
             return;
         }
-        mThumbnail = thumbnail;
+        mThumbnailSet = true;
         Favicons.cancelFaviconLoad(mLoadId);
 
         mThumbnailView.setScaleType(SCALE_TYPE_THUMBNAIL);
         mThumbnailView.setImageBitmap(thumbnail);
         mThumbnailView.setBackgroundDrawable(null);
     }
 
     public void displayFavicon(Bitmap favicon, String faviconURL, int expectedLoadId) {
@@ -229,17 +230,17 @@ public class TopSitesGridItemView extend
     }
 
     /**
      * Display the thumbnail from a favicon.
      *
      * @param favicon The favicon to show as thumbnail.
      */
     public void displayFavicon(Bitmap favicon, String faviconURL) {
-        if (mThumbnail != null) {
+        if (mThumbnailSet) {
             // Already showing a thumbnail; do nothing.
             return;
         }
 
         if (favicon == null) {
             // Should show default favicon.
             displayThumbnail(R.drawable.favicon);
             return;
--- a/mobile/android/base/home/TwoLinePageRow.java
+++ b/mobile/android/base/home/TwoLinePageRow.java
@@ -136,24 +136,16 @@ public class TwoLinePageRow extends Line
         if (mUrlIconId == urlIconId) {
             return;
         }
 
         mUrlIconId = urlIconId;
         mUrl.setCompoundDrawablesWithIntrinsicBounds(mUrlIconId, 0, mBookmarkIconId, 0);
     }
 
-    private void setFaviconWithUrl(Bitmap favicon, String url) {
-        if (favicon == null) {
-            mFavicon.showDefaultFavicon();
-        } else {
-            mFavicon.updateImage(favicon, url);
-        }
-    }
-
     private void setBookmarkIcon(int bookmarkIconId) {
         if (mBookmarkIconId == bookmarkIconId) {
             return;
         }
 
         mBookmarkIconId = bookmarkIconId;
         mUrl.setCompoundDrawablesWithIntrinsicBounds(mUrlIconId, 0, mBookmarkIconId, 0);
     }