diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index aaca6952de..af876535d2 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -65,10 +65,11 @@
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
launcher:maxGap="@dimen/workspace_max_gap" />
-
0) {
- // Set the width and show the tab bar (if we have a loading graphic, we can switch
- // it off here)
+ if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) {
+ // Set the width and show the tab bar
mTabs.getLayoutParams().width = contentWidth;
post(new Runnable() {
public void run() {
@@ -202,17 +200,35 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
return;
}
- // Setup the animation buffer
- Bitmap b = Bitmap.createBitmap(mAppsCustomizePane.getMeasuredWidth(),
- mAppsCustomizePane.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
- mAppsCustomizePane.draw(c);
- mAppsCustomizePane.setAlpha(0f);
- mAnimationBuffer.setImageBitmap(b);
- mAnimationBuffer.setAlpha(1f);
- mAnimationBuffer.setVisibility(View.VISIBLE);
- c.setBitmap(null);
- b = null;
+ // Take the visible pages and re-parent them temporarily to mAnimatorBuffer
+ // and then cross fade to the new pages
+
+ // We want the pages to be rendered in exactly the same way as they were when
+ // their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
+ // to be exactly the same as mAppsCustomizePane, and below, set the left/top
+ // parameters to be correct for each of the pages
+ mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
+
+ int[] visiblePageRange = new int[2];
+ mAppsCustomizePane.getVisiblePages(visiblePageRange);
+ ArrayList visiblePages = new ArrayList();
+ for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
+ visiblePages.add(mAppsCustomizePane.getPageAt(i));
+ }
+ // mAppsCustomizePane renders its children in reverse order, so
+ // add the pages to mAnimationBuffer in reverse order to match that behavior
+ for (int i = visiblePages.size() - 1; i >= 0; i--) {
+ View child = visiblePages.get(i);
+ PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
+ mAppsCustomizePane.removeView(child);
+ PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
+ mAnimationBuffer.setAlpha(1f);
+ mAnimationBuffer.setVisibility(View.VISIBLE);
+ LayoutParams p = new FrameLayout.LayoutParams(child.getWidth(),
+ child.getHeight());
+ p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
+ mAnimationBuffer.addView(child, p);
+ }
// Toggle the new content
onTabChangedStart();
@@ -224,7 +240,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
@Override
public void onAnimationEnd(Animator animation) {
mAnimationBuffer.setVisibility(View.GONE);
- mAnimationBuffer.setImageBitmap(null);
+ mAnimationBuffer.removeAllViews();
+ }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mAnimationBuffer.setVisibility(View.GONE);
+ mAnimationBuffer.removeAllViews();
}
});
ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 3eb4db4637..b7d4c26bce 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -44,6 +44,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
private static final int sPreviewFadeInDuration = 80;
private static final int sPreviewFadeInStaggerDuration = 20;
+ private static boolean sDeletePreviewsWhenDetachedFromWindow = true;
private final Paint mPaint = new Paint();
private Bitmap mHolographicOutline;
@@ -89,17 +90,23 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
setClipToPadding(false);
}
+ public static void setDeletePreviewsWhenDetachedFromWindow(boolean value) {
+ sDeletePreviewsWhenDetachedFromWindow = value;
+ }
+
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- final ImageView image = (ImageView) findViewById(R.id.widget_preview);
- if (image != null) {
- FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
- if (preview != null && preview.getBitmap() != null) {
- preview.getBitmap().recycle();
- }
- image.setImageDrawable(null);
+ if (sDeletePreviewsWhenDetachedFromWindow) {
+ final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+ if (image != null) {
+ FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
+ if (preview != null && preview.getBitmap() != null) {
+ preview.getBitmap().recycle();
+ }
+ image.setImageDrawable(null);
+ }
}
}