summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-07-30 18:58:59 (GMT)
committerMichael Jurka <mikejurka@google.com>2010-07-30 19:04:12 (GMT)
commitb0f28bd9a52fa4e343c8299d1c3e225d8e01c1e9 (patch)
tree74716723e9db073c461abfacbf83c020adb6c55a /src
parent3d605d5bbef35e3b8aded44c5ef7fe3948f8f7d5 (diff)
downloadandroid_packages_apps_Trebuchet-b0f28bd9a52fa4e343c8299d1c3e225d8e01c1e9.zip
android_packages_apps_Trebuchet-b0f28bd9a52fa4e343c8299d1c3e225d8e01c1e9.tar.gz
android_packages_apps_Trebuchet-b0f28bd9a52fa4e343c8299d1c3e225d8e01c1e9.tar.bz2
fixed bugs with layout in Launcher
- fix bug where calling unshrink on initialization was setting all the screens' x coordinate to 0 - fix bug where mScrollX was not synched to the proper value for the mCurrentScreen it was on
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Workspace.java94
1 files changed, 54 insertions, 40 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 1a2f812..3e52d7f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -342,6 +342,14 @@ public class Workspace extends ViewGroup
* @param currentScreen
*/
void setCurrentScreen(int currentScreen) {
+ setCurrentScreen(currentScreen, true);
+ }
+
+ void setCurrentScreen(int currentScreen, boolean animateScrolling) {
+ setCurrentScreen(currentScreen, animateScrolling, getWidth());
+ }
+
+ void setCurrentScreen(int currentScreen, boolean animateScrolling, int screenWidth) {
if (!mScroller.isFinished())
mScroller.abortAnimation();
clearVacantCache();
@@ -350,9 +358,12 @@ public class Workspace extends ViewGroup
mPreviousIndicator.setLevel(mCurrentScreen);
mNextIndicator.setLevel(mCurrentScreen);
}
-
- scrollTo(mCurrentScreen * getWidth(), 0);
- updateWallpaperOffset();
+ if (animateScrolling) {
+ scrollTo(mCurrentScreen * screenWidth, 0);
+ } else {
+ mScrollX = mCurrentScreen * screenWidth;
+ }
+ updateWallpaperOffset(screenWidth * (getChildCount() - 1));
invalidate();
}
@@ -689,9 +700,8 @@ public class Workspace extends ViewGroup
if (mFirstLayout) {
setHorizontalScrollBarEnabled(false);
- scrollTo(mCurrentScreen * width, 0);
+ setCurrentScreen(mCurrentScreen, false, width);
setHorizontalScrollBarEnabled(true);
- updateWallpaperOffset(width * (getChildCount() - 1));
}
}
@@ -1176,46 +1186,50 @@ public class Workspace extends ViewGroup
// We call this when we trigger an unshrink by clicking on the CellLayout cl
private void unshrink(CellLayout clThatWasClicked) {
- int newCurrentScreen = mCurrentScreen;
- final int screenCount = getChildCount();
- for (int i = 0; i < screenCount; i++) {
- if (getChildAt(i) == clThatWasClicked) {
- newCurrentScreen = i;
+ if (mIsSmall) {
+ int newCurrentScreen = mCurrentScreen;
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
+ if (getChildAt(i) == clThatWasClicked) {
+ newCurrentScreen = i;
+ }
}
- }
- final int delta = (newCurrentScreen - mCurrentScreen)*getWidth();
- for (int i = 0; i < screenCount; i++) {
- CellLayout cl = (CellLayout) getChildAt(i);
- cl.setX(cl.getX() + delta);
- }
- mScrollX = newCurrentScreen * getWidth();
+ final int delta = (newCurrentScreen - mCurrentScreen)*getWidth();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout) getChildAt(i);
+ cl.setX(cl.getX() + delta);
+ }
+ mScrollX = newCurrentScreen * getWidth();
- unshrink();
- setCurrentScreen(newCurrentScreen);
+ unshrink();
+ setCurrentScreen(newCurrentScreen);
+ }
}
public void unshrink() {
- final int screenWidth = getWidth();
- Sequencer s = new Sequencer();
- final int screenCount = getChildCount();
- for (int i = 0; i < screenCount; i++) {
- CellLayout cl = (CellLayout)getChildAt(i);
- int x = screenWidth * i;
-
- PropertyAnimator translateX = new PropertyAnimator(500, cl, "x", cl.getX(), x);
- PropertyAnimator translateY = new PropertyAnimator(500, cl, "y", cl.getY(), 0);
- PropertyAnimator scaleX = new PropertyAnimator(500, cl, "scaleX", cl.getScaleX(), 1.0f);
- PropertyAnimator scaleY = new PropertyAnimator(500, cl, "scaleY", cl.getScaleY(), 1.0f);
- PropertyAnimator alpha = new PropertyAnimator(
- 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 0.0f);
- Sequencer.Builder b = s.play(translateX);
- b.with(translateY);
- b.with(scaleX);
- b.with(scaleY);
- b.with(alpha);
+ if (mIsSmall) {
+ final int screenWidth = getWidth();
+ Sequencer s = new Sequencer();
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout)getChildAt(i);
+ int x = screenWidth * i;
+
+ PropertyAnimator translateX = new PropertyAnimator(500, cl, "x", cl.getX(), x);
+ PropertyAnimator translateY = new PropertyAnimator(500, cl, "y", cl.getY(), 0);
+ PropertyAnimator scaleX = new PropertyAnimator(500, cl, "scaleX", cl.getScaleX(), 1.0f);
+ PropertyAnimator scaleY = new PropertyAnimator(500, cl, "scaleY", cl.getScaleY(), 1.0f);
+ PropertyAnimator alpha = new PropertyAnimator(
+ 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 0.0f);
+ Sequencer.Builder b = s.play(translateX);
+ b.with(translateY);
+ b.with(scaleX);
+ b.with(scaleY);
+ b.with(alpha);
+ }
+ s.addListener(mUnshrinkAnimationListener);
+ s.start();
}
- s.addListener(mUnshrinkAnimationListener);
- s.start();
}
void snapToScreen(int whichScreen) {
@@ -1301,7 +1315,7 @@ public class Workspace extends ViewGroup
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
if (savedState.currentScreen != -1) {
- mCurrentScreen = savedState.currentScreen;
+ setCurrentScreen(savedState.currentScreen, false);
Launcher.setScreen(mCurrentScreen);
}
}