From fcb9e7144e58614f5ae0e9b272fb7ce040848c67 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 2 Oct 2009 16:06:52 -0700 Subject: [PATCH] Prevent Home from crashing because of wrongly generated ids. Change-Id: I51afba418291e8c909d1b2b0396e7c0c55b23631 --- src/com/android/launcher2/CellLayout.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 84e3766d70..63e01bb5ab 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -124,8 +124,7 @@ public class CellLayout extends ViewGroup { // Generate an id for each view, this assumes we have at most 256x256 cells // per workspace screen final LayoutParams cellParams = (LayoutParams) params; - child.setId(((getId() & 0xFF) << 16) | - (cellParams.cellX & 0xFF) << 8 | (cellParams.cellY & 0xFF)); + cellParams.regenerateId = true; super.addView(child, index, params); } @@ -497,6 +496,11 @@ public class CellLayout extends ViewGroup { lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, longAxisStartPadding, shortAxisStartPadding); } + + if (lp.regenerateId) { + child.setId(((getId() & 0xFF) << 16) | (lp.cellX & 0xFF) << 8 | (lp.cellY & 0xFF)); + lp.regenerateId = false; + } int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); int childheightMeasureSpec = @@ -835,6 +839,8 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) { @ViewDebug.ExportedProperty int y; + boolean regenerateId; + public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); cellHSpan = 1;