Bug 905685 - Clear favicon until the new image finishes loading in TwoLinePageRow. r=sriram, a=lsblakk
authorLucas Rocha <lucasr@mozilla.com>
Wed, 18 Sep 2013 12:58:58 -0400
changeset 160425 bd33971cc395946b127cde8c7923884c5b921f42
parent 160424 3fde1bdc6d01658db541466d83ca3888d4fcd682
child 160426 8739bac221a5d441fa6b04ecea543650a84946a5
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram, lsblakk
bugs905685
milestone26.0a2
Bug 905685 - Clear favicon until the new image finishes loading in TwoLinePageRow. r=sriram, a=lsblakk
mobile/android/base/home/TwoLinePageRow.java
mobile/android/base/widget/FaviconView.java
--- a/mobile/android/base/home/TwoLinePageRow.java
+++ b/mobile/android/base/home/TwoLinePageRow.java
@@ -192,16 +192,19 @@ public class TwoLinePageRow extends Line
         cancelLoadFaviconTask();
 
         // First, try to find the favicon in the memory cache. If it's not
         // cached yet, try to load it from the database, off main thread.
         final Bitmap favicon = Favicons.getFaviconFromMemCache(url);
         if (favicon != null) {
             setFaviconWithUrl(favicon, url);
         } else {
+            // Show blank image until the new favicon finishes loading
+            mFavicon.clearImage();
+
             mLoadFaviconTask = new LoadFaviconTask(url);
 
             // Try to use a thread pool instead of serial execution of tasks
             // to add more throughput to the favicon loading routines.
             if (Build.VERSION.SDK_INT >= 11) {
                 mLoadFaviconTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
             } else {
                 mLoadFaviconTask.execute();
--- a/mobile/android/base/widget/FaviconView.java
+++ b/mobile/android/base/widget/FaviconView.java
@@ -151,16 +151,24 @@ public class FaviconView extends ImageVi
         mIconKey = key;
         mScalingExpected = allowScaling;
 
         // Possibly update the display.
         formatImage();
     }
 
     /**
+     * Clear image and background shown by this view.
+     */
+    public void clearImage() {
+        setImageResource(0);
+        hideBackground();
+    }
+
+    /**
      * Update the displayed image and apply the scaling logic.
      * The scaling logic will attempt to resize the image to fit correctly inside the view in a way
      * that avoids unreasonable levels of loss of quality.
      * Scaling is necessary only when the icon being provided is not drawn from the Favicon cache
      * introduced in Bug 914296.
      *
      * Due to Bug 913746, icons bundled for search engines are not available to the cache, so must
      * always have the scaling logic applied here. At the time of writing, this is the only case in