Adding layout transition for when pages get deleted

-> Fixing NPE

Change-Id: I1e0cb057ff65c2b8831a2e10652acb6db10e50e3
This commit is contained in:
Adam Cohen
2013-07-19 16:14:00 -07:00
parent 39a0604255
commit 22cba7f995

View File

@@ -18,6 +18,7 @@ package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
@@ -99,6 +100,7 @@ public class Workspace extends SmoothPagedView
private float mWallpaperScrollRatio = 1.0f;
private LayoutTransition mLayoutTransition;
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
private static final float WALLPAPER_SCREENS_SPAN = 2f;
@@ -411,6 +413,7 @@ public class Workspace extends SmoothPagedView
setClipToPadding(false);
setChildrenDrawnWithCacheEnabled(true);
setMinScale(0.5f);
setupLayoutTransition();
final Resources res = getResources();
try {
@@ -429,6 +432,16 @@ public class Workspace extends SmoothPagedView
mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
}
private void setupLayoutTransition() {
// We want to show layout transitions when pages are deleted, to close the gap.
mLayoutTransition = new LayoutTransition();
mLayoutTransition.enableTransitionType(LayoutTransition.DISAPPEARING);
mLayoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
mLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
setLayoutTransition(mLayoutTransition);
}
@Override
protected int getScrollMode() {
return SmoothPagedView.X_LARGE_MODE;
@@ -1312,8 +1325,13 @@ public class Workspace extends SmoothPagedView
(getScrollForPage(index + 1) - getScrollForPage(index));
setBackgroundAlpha(progress * 0.8f);
mLauncher.getHotseat().setTranslationX(translationX);
getPageIndicator().setTranslationX(translationX);
if (mLauncher.getHotseat() != null) {
mLauncher.getHotseat().setTranslationX(translationX);
}
if (getPageIndicator() != null) {
getPageIndicator().setTranslationX(translationX);
}
}
}
@@ -1684,6 +1702,9 @@ public class Workspace extends SmoothPagedView
((CellLayout) getChildAt(i)).setUseActiveGlowBackground(true);
}
showOutlines();
// Reordering handles its own animations, disable the automatic ones.
setLayoutTransition(null);
}
protected void onEndReordering() {
@@ -1700,6 +1721,9 @@ public class Workspace extends SmoothPagedView
mScreenOrder.add(getIdForScreen(cl));
}
mLauncher.getModel().updateWorkspaceScreenOrder(mLauncher, mScreenOrder);
// Re-enable auto layout transitions for page deletion.
setLayoutTransition(mLayoutTransition);
}
Animator getChangeStateAnimation(final State state, boolean animated, int delay) {