final int fromY = r.top;
animateViewIntoPosition(dragView, fromX, fromY, pos[0], pos[1], scale,
- onFinishRunnable, true);
+ onFinishRunnable, true, -1);
}
public void animateViewIntoPosition(DragView dragView, final View child,
final Runnable onFinishAnimationRunnable) {
+ animateViewIntoPosition(dragView, child, -1, onFinishAnimationRunnable);
+ }
+
+ public void animateViewIntoPosition(DragView dragView, final View child, int duration,
+ final Runnable onFinishAnimationRunnable) {
((CellLayoutChildren) child.getParent()).measureChild(child);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
oa.start();
}
};
- animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale, onCompleteRunnable, true);
+ animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale,
+ onCompleteRunnable, true, duration);
}
private void animateViewIntoPosition(final View view, final int fromX, final int fromY,
final int toX, final int toY, float finalScale, Runnable onCompleteRunnable,
- boolean fadeOut) {
+ boolean fadeOut, int duration) {
Rect from = new Rect(fromX, fromY, fromX +
view.getMeasuredWidth(), fromY + view.getMeasuredHeight());
Rect to = new Rect(toX, toY, toX + view.getMeasuredWidth(), toY + view.getMeasuredHeight());
- animateView(view, from, to, 1f, finalScale, -1, null, null, onCompleteRunnable, true);
+ animateView(view, from, to, 1f, finalScale, duration, null, null, onCompleteRunnable, true);
}
/**
private static final int BACKGROUND_FADE_OUT_DURATION = 350;
private static final int BACKGROUND_FADE_IN_DURATION = 350;
+ private static final int ADJACENT_SCREEN_DROP_DURATION = 300;
+
// These animators are used to fade the children's outlines
private ObjectAnimator mChildrenOutlineFadeInAnimation;
private ObjectAnimator mChildrenOutlineFadeOutAnimation;
final static float TOUCH_SLOP_DAMPING_FACTOR = 4;
// These variables are used for storing the initial and final values during workspace animations
+ private int mSavedScrollX;
+ private float mSavedRotationY;
+ private float mSavedTranslationX;
private float mCurrentScaleX;
private float mCurrentScaleY;
private float mCurrentRotationY;
}
CellLayout dropTargetLayout = mDragTargetLayout;
+ int snapScreen = -1;
if (d.dragSource != this) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1] };
dropTargetLayout, mTargetCell);
if (dropInscrollArea && mState != State.SPRING_LOADED) {
+ snapScreen = screen;
snapToPage(screen);
}
-
if (mTargetCell[0] >= 0 && mTargetCell[1] >= 0) {
if (hasMovedLayouts) {
// Reparent the view
};
mAnimatingViewIntoPlace = true;
if (d.dragView.hasDrawn()) {
- mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell,
+ int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
+ setFinalScrollForPageChange(snapScreen);
+ mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
disableHardwareLayersRunnable);
+ resetFinalScrollForPageChange(snapScreen);
} else {
cell.setVisibility(VISIBLE);
}
}
}
+ public void setFinalScrollForPageChange(int screen) {
+ if (screen >= 0) {
+ mSavedScrollX = getScrollX();
+ CellLayout cl = (CellLayout) getChildAt(screen);
+ mSavedTranslationX = cl.getTranslationX();
+ mSavedRotationY = cl.getRotationY();
+ final int newX = getChildOffset(screen) - getRelativeChildOffset(screen);
+ setScrollX(newX);
+ cl.setTranslationX(0f);
+ cl.setRotationY(0f);
+ }
+ }
+
+ public void resetFinalScrollForPageChange(int screen) {
+ if (screen >= 0) {
+ CellLayout cl = (CellLayout) getChildAt(screen);
+ setScrollX(mSavedScrollX);
+ cl.setTranslationX(mSavedTranslationX);
+ cl.setRotationY(mSavedRotationY);
+ }
+ }
+
public void getViewLocationRelativeToSelf(View v, int[] location) {
getLocationInWindow(location);
int x = location[0];