Bug 901064: Size 0 for initial TopBookmarksView. [r=margaret]
authorSriram Ramasubramanian <sriram@mozilla.com>
Fri, 02 Aug 2013 16:01:49 -0700
changeset 143494 d51f4bd67608654c1a271065773736600d3a0409
parent 143493 b0e8ef08abae03a7a99b3199db198fe7b4f1bfcf
child 143495 4c3421eb1d4358150b151a9f3b74bddf1d8a0e7d
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs901064
milestone25.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 901064: Size 0 for initial TopBookmarksView. [r=margaret]
mobile/android/base/home/TopBookmarksView.java
--- a/mobile/android/base/home/TopBookmarksView.java
+++ b/mobile/android/base/home/TopBookmarksView.java
@@ -138,37 +138,41 @@ public class TopBookmarksView extends Gr
         final int childWidth = getColumnWidth();
         int childHeight = 0;
 
         // Set the column width as the thumbnail width.
         ThumbnailHelper.getInstance().setThumbnailWidth(childWidth);
 
         // If there's an adapter, use it to calculate the height of this view.
         final TopBookmarksAdapter adapter = (TopBookmarksAdapter) getAdapter();
-        final int count = (adapter == null ? 0 : adapter.getCount());
+        final int count;
+
+        // There shouldn't be any inherent size (due to padding) if there are no child views.
+        if (adapter == null || (count = adapter.getCount()) == 0) {
+            setMeasuredDimension(0, 0);
+            return;
+        }
 
-        if (adapter != null && count > 0) {
-            // Get the first child from the adapter.
-            final View child = adapter.getView(0, null, this);
-            if (child != null) {
-                // Set a default LayoutParams on the child, if it doesn't have one on its own.
-                AbsListView.LayoutParams params = (AbsListView.LayoutParams) child.getLayoutParams();
-                if (params == null) {
-                    params = new AbsListView.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT,
-                                                          AbsListView.LayoutParams.WRAP_CONTENT);
-                    child.setLayoutParams(params);
-                }
+        // Get the first child from the adapter.
+        final View child = adapter.getView(0, null, this);
+        if (child != null) {
+            // Set a default LayoutParams on the child, if it doesn't have one on its own.
+            AbsListView.LayoutParams params = (AbsListView.LayoutParams) child.getLayoutParams();
+            if (params == null) {
+                params = new AbsListView.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT,
+                                                      AbsListView.LayoutParams.WRAP_CONTENT);
+                child.setLayoutParams(params);
+            }
 
-                // Measure the exact width of the child, and the height based on the width.
-                // Note: the child (and BookmarkThumbnailView) takes care of calculating its height.
-                int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
-                int childHeightSpec = MeasureSpec.makeMeasureSpec(0,  MeasureSpec.UNSPECIFIED);
-                child.measure(childWidthSpec, childHeightSpec);
-                childHeight = child.getMeasuredHeight();
-            }
+            // Measure the exact width of the child, and the height based on the width.
+            // Note: the child (and BookmarkThumbnailView) takes care of calculating its height.
+            int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
+            int childHeightSpec = MeasureSpec.makeMeasureSpec(0,  MeasureSpec.UNSPECIFIED);
+            child.measure(childWidthSpec, childHeightSpec);
+            childHeight = child.getMeasuredHeight();
         }
 
         // Find the minimum of bookmarks we need to show, and the one given by the cursor.
         final int total = Math.min(count > 0 ? count : Integer.MAX_VALUE, mMaxBookmarks);
 
         // Number of rows required to show these bookmarks.
         final int rows = (int) Math.ceil((double) total / mNumColumns);
         final int childrenHeight = childHeight * rows;