summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-03-15 18:23:25 -0700
committerAdam Powell <adamp@google.com>2010-03-15 18:23:25 -0700
commit22cb2f46fdbb9a904ac394f488278fb47e2d4734 (patch)
treeb182946b3dbeb539097c59999f02d2c85fecd386
parent1a3786a3e34112e3e68e6a9b07ba72802867a002 (diff)
downloadframeworks_base-22cb2f46fdbb9a904ac394f488278fb47e2d4734.zip
frameworks_base-22cb2f46fdbb9a904ac394f488278fb47e2d4734.tar.gz
frameworks_base-22cb2f46fdbb9a904ac394f488278fb47e2d4734.tar.bz2
Fix monkey bug 2512055
Don't blow up when there aren't any menu items to layout in IconMenuView. Change-Id: Ief08f0f8ed89aec4959d4d80cfd066dbe92dc3aa
-rw-r--r--core/java/com/android/internal/view/menu/IconMenuView.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/com/android/internal/view/menu/IconMenuView.java b/core/java/com/android/internal/view/menu/IconMenuView.java
index bba2ee2..beb57ba 100644
--- a/core/java/com/android/internal/view/menu/IconMenuView.java
+++ b/core/java/com/android/internal/view/menu/IconMenuView.java
@@ -179,6 +179,10 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi
*/
private void layoutItems(int width) {
int numItems = getChildCount();
+ if (numItems == 0) {
+ mLayoutNumRows = 0;
+ return;
+ }
// Start with the least possible number of rows
int curNumRows =
@@ -470,15 +474,18 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi
// Get the desired height of the icon menu view (last row of items does
// not have a divider below)
+ final int layoutNumRows = mLayoutNumRows;
final int desiredHeight = (mRowHeight + mHorizontalDividerHeight) *
- mLayoutNumRows - mHorizontalDividerHeight;
+ layoutNumRows - mHorizontalDividerHeight;
// Maximum possible width and desired height
setMeasuredDimension(measuredWidth,
resolveSize(desiredHeight, heightMeasureSpec));
// Position the children
- positionChildren(mMeasuredWidth, mMeasuredHeight);
+ if (layoutNumRows > 0) {
+ positionChildren(mMeasuredWidth, mMeasuredHeight);
+ }
}