Fix 2325492 - No icons in launcher after pressing home from within an app
It looks like the evil hack in 14f122bf847e50a3e7730ccbe57abc25d086a01b to make the workspace
not animate didn't completely work. The key to reproducing this bug is to make sure the
activity is destroyed and to have last gone to an app from a screen other than the center
screen, because that causes it to get reloaded from the icicle, which makes the timing
more amenable to missing the animation, because the view isn't attached yet.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 374f0bf..9e32dd5 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -272,6 +272,7 @@
* @param currentScreen
*/
void setCurrentScreen(int currentScreen) {
+ if (!mScroller.isFinished()) mScroller.abortAnimation();
clearVacantCache();
mCurrentScreen = Math.max(0, Math.min(currentScreen, getChildCount() - 1));
scrollTo(mCurrentScreen * getWidth(), 0);
@@ -946,10 +947,6 @@
}
void snapToScreen(int whichScreen) {
- snapToScreen(whichScreen, true);
- }
-
- void snapToScreen(int whichScreen, boolean animate) {
//if (!mScroller.isFinished()) return;
whichScreen = Math.max(0, Math.min(whichScreen, getChildCount() - 1));
@@ -973,8 +970,7 @@
final int delta = newX - mScrollX;
final int duration = screenDelta * 300;
awakenScrollBars(duration);
- // 1ms is close to don't animate
- mScroller.startScroll(mScrollX, 0, delta, 0, animate ? duration : 1);
+ mScroller.startScroll(mScrollX, 0, delta, 0, duration);
invalidate();
}
@@ -1425,7 +1421,11 @@
}
void moveToDefaultScreen(boolean animate) {
- snapToScreen(mDefaultScreen, animate);
+ if (animate) {
+ snapToScreen(mDefaultScreen);
+ } else {
+ setCurrentScreen(mDefaultScreen);
+ }
getChildAt(mDefaultScreen).requestFocus();
}