Prevent Home from crashing because of wrongly generated ids.

Change-Id: I51afba418291e8c909d1b2b0396e7c0c55b23631
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 84e3766..63e01bb 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -124,8 +124,7 @@
         // 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 @@
                 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 @@
         @ViewDebug.ExportedProperty
         int y;
 
+        boolean regenerateId;
+
         public LayoutParams(Context c, AttributeSet attrs) {
             super(c, attrs);
             cellHSpan = 1;