Bug 808296 - Update top sites thumbnails from adapter, not from gridview (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Mon, 12 Nov 2012 15:58:40 +0000
changeset 112995 edc00669b8e13aada1969ab0d37ff26246bb1b43
parent 112994 27ba1cfc0b30ceddbbf1c9258ec042d88a03beb1
child 112996 7493a7ad3f37280ca2d90952d7f6ed2593014d13
push id23847
push userphilringnalda@gmail.com
push dateTue, 13 Nov 2012 05:07:25 +0000
treeherdermozilla-central@1b0226622e94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs808296
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 808296 - Update top sites thumbnails from adapter, not from gridview (r=mfinkle)
mobile/android/base/AboutHomeContent.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -322,20 +322,25 @@ public class AboutHomeContent extends Sc
                 Log.e(LOGTAG, "Unable to load thumbnail bitmap", oom);
                 thumbnailView.setImageResource(R.drawable.abouthome_thumbnail_bg);
                 thumbnailView.setScaleType(ImageView.ScaleType.FIT_CENTER);
             }
         }
     }
 
     private void updateTopSitesThumbnails(Map<String, Bitmap> thumbnails) {
-        for (int i = 0; i < mTopSitesGrid.getChildCount(); i++) {
+        for (int i = 0; i < mTopSitesAdapter.getCount(); i++) {
             final View view = mTopSitesGrid.getChildAt(i);
 
-            Cursor c = (Cursor) mTopSitesGrid.getItemAtPosition(i);
+            // The grid view might get temporarily out of sync with the
+            // adapter refreshes (e.g. on device rotation)
+            if (view == null)
+                continue;
+
+            Cursor c = (Cursor) mTopSitesAdapter.getItem(i);
             final String url = c.getString(c.getColumnIndex(URLColumns.URL));
 
             displayThumbnail(view, thumbnails.get(url));
         }
 
         mTopSitesGrid.invalidate();
     }