Merge "Fix 3300849: Illegal state exception during dragging." into honeycomb
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 4568562..c9c069f 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -332,6 +332,8 @@
             final int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
             if (index < 0) {
                 mApps.add(-(index + 1), info);
+            } else {
+                mApps.add(index, info);
             }
         }
         mFilteredApps = rebuildFilteredApps(mApps);
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 9f0e5fb..f3aa342 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -37,7 +37,7 @@
  * because we want to make the bubble taller than the text and TextView's clip is
  * too aggressive.
  */
-public class BubbleTextView extends CacheableTextView implements VisibilityChangedBroadcaster {
+public class BubbleTextView extends CachedTextView implements VisibilityChangedBroadcaster {
     static final float CORNER_RADIUS = 4.0f;
     static final float SHADOW_LARGE_RADIUS = 4.0f;
     static final float SHADOW_SMALL_RADIUS = 1.75f;
diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CachedTextView.java
similarity index 93%
rename from src/com/android/launcher2/CacheableTextView.java
rename to src/com/android/launcher2/CachedTextView.java
index 167133d..eaa6636 100644
--- a/src/com/android/launcher2/CacheableTextView.java
+++ b/src/com/android/launcher2/CachedTextView.java
@@ -21,6 +21,7 @@
 import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.Bitmap.Config;
+import android.graphics.PorterDuff.Mode;
 import android.text.Layout;
 import android.util.AttributeSet;
 import android.widget.TextView;
@@ -31,7 +32,7 @@
  * rendering. Marquee scrolling is not currently supported.
  *
  */
-public class CacheableTextView extends TextView {
+public class CachedTextView extends TextView {
     private Bitmap mCache;
     private final Paint mCachePaint = new Paint();
     private final Canvas mCacheCanvas = new Canvas();
@@ -47,15 +48,15 @@
     private float mPaddingV = 0;
     private CharSequence mText;
 
-    public CacheableTextView(Context context) {
+    public CachedTextView(Context context) {
         super(context);
     }
 
-    public CacheableTextView(Context context, AttributeSet attrs) {
+    public CachedTextView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
-    public CacheableTextView(Context context, AttributeSet attrs, int defStyle) {
+    public CachedTextView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
 
@@ -111,7 +112,7 @@
                 mCache = Bitmap.createBitmap(width, height, Config.ARGB_8888);
                 mCacheCanvas.setBitmap(mCache);
             } else {
-                mCacheCanvas.drawColor(0x00000000);
+                mCacheCanvas.drawColor(0, Mode.CLEAR);
             }
 
             mCacheCanvas.save();
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 19e775b..45de630 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -417,7 +417,7 @@
     }
 
     public void updateCache() {
-        mCacheCanvas.drawColor(0x00000000, Mode.CLEAR);
+        mCacheCanvas.drawColor(0, Mode.CLEAR);
 
         float alpha = getAlpha();
         setAlpha(1.0f);
@@ -1390,7 +1390,9 @@
             lp.isDragging = false;
             lp.dropped = true;
             lp.animateDrop = animate;
-            child.setVisibility(View.INVISIBLE);
+            if (animate) {
+                child.setVisibility(View.INVISIBLE);
+            }
             child.requestLayout();
         }
     }
diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/android/launcher2/HolographicOutlineHelper.java
index 6d0899d..1efc123 100644
--- a/src/com/android/launcher2/HolographicOutlineHelper.java
+++ b/src/com/android/launcher2/HolographicOutlineHelper.java
@@ -184,7 +184,7 @@
 
         // draw the inner and outer blur
         srcDstCanvas.setBitmap(srcDst);
-        srcDstCanvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
+        srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
         mHolographicPaint.setColor(color);
         srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1],
                 mHolographicPaint);
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 90cff97..0af7b8a 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -39,7 +39,7 @@
  * An icon on a PagedView, specifically for items in the launcher's paged view (with compound
  * drawables on the top).
  */
-public class PagedViewIcon extends CacheableTextView implements Checkable {
+public class PagedViewIcon extends CachedTextView implements Checkable {
     private static final String TAG = "PagedViewIcon";
 
     // holographic outline
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c628977..3f3088f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -616,7 +616,7 @@
         Display display = mLauncher.getWindowManager().getDefaultDisplay();
         int wallpaperTravelHeight = (int) (display.getHeight() *
                 wallpaperTravelToScreenHeightRatio(display.getWidth(), display.getHeight()));
-        float offsetFromCenter = (wallpaperTravelHeight / mWallpaperHeight) / 2f;
+        float offsetFromCenter = (wallpaperTravelHeight / (float) mWallpaperHeight) / 2f;
         switch (offsetPosition) {
             case TOP:
                 offset = 0.5f - offsetFromCenter;