Reduce unnecessary layout passes

- Also delete unused code
diff --git a/res/layout/apps_customize_widget.xml b/res/layout/apps_customize_widget.xml
index 704401a..90883c5 100644
--- a/res/layout/apps_customize_widget.xml
+++ b/res/layout/apps_customize_widget.xml
@@ -63,7 +63,7 @@
     </LinearLayout>
 
     <!-- The icon of the widget. -->
-    <ImageView
+    <com.android.launcher2.PagedViewWidgetImageView
         android:id="@+id/widget_preview"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 6667f7c..fa47a15 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -977,7 +977,6 @@
 
         // Generate a preview image if we couldn't load one
         if (drawable == null) {
-            Resources resources = mLauncher.getResources();
             // TODO: This actually uses the apps customize cell layout params, where as we make want
             // the Workspace params for more accuracy.
             int targetWidth = mWidgetSpacingLayout.estimateCellWidth(cellHSpan);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 9ffc1d0..2d75493 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -102,9 +102,6 @@
     private Drawable mOverScrollRight;
     private Rect mBackgroundRect;
     private Rect mForegroundRect;
-    private Rect mGlowBackgroundRect;
-    private float mGlowBackgroundScale;
-    private float mGlowBackgroundAlpha;
     private int mForegroundPadding;
 
     // If we're actively dragging something over this screen, mIsDragOverlapping is true
@@ -258,9 +255,6 @@
 
         mBackgroundRect = new Rect();
         mForegroundRect = new Rect();
-        mGlowBackgroundRect = new Rect();
-        setHoverScale(1.0f);
-        setHoverAlpha(1.0f);
 
         mChildren = new CellLayoutChildren(context);
         mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
@@ -351,68 +345,6 @@
         return mIsDragOverlapping;
     }
 
-    private void updateGlowRect() {
-        float marginFraction = (mGlowBackgroundScale - 1.0f) / 2.0f;
-        int marginX = (int) (marginFraction * (mBackgroundRect.right - mBackgroundRect.left));
-        int marginY = (int) (marginFraction * (mBackgroundRect.bottom - mBackgroundRect.top));
-        mGlowBackgroundRect.set(mBackgroundRect.left - marginX, mBackgroundRect.top - marginY,
-                mBackgroundRect.right + marginX, mBackgroundRect.bottom + marginY);
-        invalidate();
-    }
-
-    public void setHoverScale(float scaleFactor) {
-        if (scaleFactor != mGlowBackgroundScale) {
-            mGlowBackgroundScale = scaleFactor;
-            updateGlowRect();
-            if (getParent() != null) {
-                ((View) getParent()).invalidate();
-            }
-        }
-    }
-
-    public float getHoverScale() {
-        return mGlowBackgroundScale;
-    }
-
-    public float getHoverAlpha() {
-        return mGlowBackgroundAlpha;
-    }
-
-    public void setHoverAlpha(float alpha) {
-        mGlowBackgroundAlpha = alpha;
-        invalidate();
-    }
-
-    void animateDrop() {
-        Resources res = getResources();
-        float onDropScale = res.getInteger(R.integer.config_screenOnDropScalePercent) / 100.0f;
-        ObjectAnimator scaleUp = ObjectAnimator.ofFloat(this, "hoverScale", onDropScale);
-        scaleUp.setDuration(res.getInteger(R.integer.config_screenOnDropScaleUpDuration));
-        ObjectAnimator scaleDown = ObjectAnimator.ofFloat(this, "hoverScale", 1.0f);
-        scaleDown.setDuration(res.getInteger(R.integer.config_screenOnDropScaleDownDuration));
-        ObjectAnimator alphaFadeOut = ObjectAnimator.ofFloat(this, "hoverAlpha", 0.0f);
-
-        alphaFadeOut.setStartDelay(res.getInteger(R.integer.config_screenOnDropAlphaFadeDelay));
-        alphaFadeOut.setDuration(res.getInteger(R.integer.config_screenOnDropAlphaFadeDuration));
-
-        AnimatorSet bouncer = new AnimatorSet();
-        bouncer.play(scaleUp).before(scaleDown);
-        bouncer.play(scaleUp).with(alphaFadeOut);
-        bouncer.addListener(new AnimatorListenerAdapter() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-                setIsDragOverlapping(true);
-            }
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                setIsDragOverlapping(false);
-                setHoverScale(1.0f);
-                setHoverAlpha(1.0f);
-            }
-        });
-        bouncer.start();
-    }
-
     @Override
     protected void onDraw(Canvas canvas) {
         // When we're large, we are either drawn in a "hover" state (ie when dragging an item to
@@ -939,7 +871,6 @@
         mBackgroundRect.set(0, 0, w, h);
         mForegroundRect.set(mForegroundPadding, mForegroundPadding,
                 w - 2 * mForegroundPadding, h - 2 * mForegroundPadding);
-        updateGlowRect();
     }
 
     @Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index a62dfa6..664b597 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2503,8 +2503,6 @@
     void addExternalItemToScreen(ItemInfo itemInfo, final CellLayout layout) {
         if (!mWorkspace.addExternalItemToScreen(itemInfo, layout)) {
             showOutOfSpaceMessage();
-        } else {
-            layout.animateDrop();
         }
     }
 
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 2de7d4a..482d3d1 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1777,7 +1777,7 @@
             updateScrollingIndicatorPosition();
             cancelScrollingIndicatorAnimations();
             if (immediately) {
-                mScrollIndicator.setVisibility(View.GONE);
+                mScrollIndicator.setVisibility(View.INVISIBLE);
                 mScrollIndicator.setAlpha(0f);
             } else {
                 mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 0f);
@@ -1791,7 +1791,7 @@
                     @Override
                     public void onAnimationEnd(Animator animation) {
                         if (!cancelled) {
-                            mScrollIndicator.setVisibility(View.GONE);
+                            mScrollIndicator.setVisibility(View.INVISIBLE);
                         }
                     }
                 });
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 12c98b2..3eb4db4 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -136,10 +136,13 @@
     }
 
     void applyPreview(FastBitmapDrawable preview, int index, boolean scale) {
-        final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+        final PagedViewWidgetImageView image =
+                (PagedViewWidgetImageView) findViewById(R.id.widget_preview);
         if (preview != null) {
+            image.mAllowRequestLayout = false;
             image.setImageDrawable(preview);
             image.setScaleType(scale ? ImageView.ScaleType.FIT_START : ImageView.ScaleType.MATRIX);
+            image.mAllowRequestLayout = true;
             image.setAlpha(0f);
             image.animate()
                  .alpha(1f)
diff --git a/src/com/android/launcher2/PagedViewWidgetImageView.java b/src/com/android/launcher2/PagedViewWidgetImageView.java
new file mode 100644
index 0000000..844b337
--- /dev/null
+++ b/src/com/android/launcher2/PagedViewWidgetImageView.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher2;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+
+
+class PagedViewWidgetImageView extends ImageView {
+    public boolean mAllowRequestLayout = true;
+
+    public PagedViewWidgetImageView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public void requestLayout() {
+        if (mAllowRequestLayout) {
+            super.requestLayout();
+        }
+    }
+}
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index e90406e..3a7f24b 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -119,7 +119,7 @@
         mDropTargetBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
-                mDropTargetBar.setVisibility(View.GONE);
+                mDropTargetBar.setVisibility(View.INVISIBLE);
                 mDropTargetBar.setLayerType(View.LAYER_TYPE_NONE, null);
             }
         });
@@ -136,7 +136,7 @@
         mQSBSearchBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
-                mQSBSearchBar.setVisibility(View.GONE);
+                mQSBSearchBar.setVisibility(View.INVISIBLE);
             }
         });
     }
@@ -166,7 +166,7 @@
         if (animated) {
             mQSBSearchBarFadeOutAnim.start();
         } else {
-            mQSBSearchBar.setVisibility(View.GONE);
+            mQSBSearchBar.setVisibility(View.INVISIBLE);
             mQSBSearchBar.setAlpha(0f);
         }
         mIsSearchBarHidden = true;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index d3a31c4..a6d5cb3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2960,7 +2960,6 @@
             addInScreen(view, container, screen, mTargetCell[0], mTargetCell[1], info.spanX,
                     info.spanY, insertAtFirst);
             cellLayout.onDropChild(view);
-            cellLayout.animateDrop();
             CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
             cellLayout.getChildrenLayout().measureChild(view);