diff options
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index bf8e31498..b981b5550 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -18,6 +18,7 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; @@ -181,7 +182,7 @@ public class Workspace extends PagedView // State variable that indicates whether the pages are small (ie when you're // in all apps or customize mode) - enum State { + public enum State { NORMAL (false, false), NORMAL_HIDDEN (false, false), SPRING_LOADED (false, true), @@ -280,6 +281,7 @@ public class Workspace extends PagedView private WorkspaceStateTransitionAnimation mStateTransitionAnimation; private AccessibilityDelegate mPagesAccessibilityDelegate; + private OnStateChangeListener mOnStateChangeListener; /** * Used to inflate the Workspace from XML. @@ -337,6 +339,10 @@ public class Workspace extends PagedView } } + public void setOnStateChangeListener(OnStateChangeListener listener) { + mOnStateChangeListener = listener; + } + // estimate the size of a widget with spans hSpan, vSpan. return MAX_VALUE for each // dimension if unsuccessful public int[] estimateItemSize(ItemInfo itemInfo, boolean springLoaded) { @@ -1982,7 +1988,7 @@ public class Workspace extends PagedView public Animator setStateWithAnimation(State toState, boolean animated, HashMap<View, Integer> layerViews) { // Create the animation to the new state - Animator workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState, + AnimatorSet workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState, toState, animated, layerViews); boolean shouldNotifyWidgetChange = !mState.shouldUpdateWidget @@ -1995,6 +2001,10 @@ public class Workspace extends PagedView mLauncher.notifyWidgetProvidersChanged(); } + if (mOnStateChangeListener != null) { + mOnStateChangeListener.prepareStateChange(toState, animated ? workspaceAnim : null); + } + return workspaceAnim; } @@ -4408,4 +4418,14 @@ public class Workspace extends PagedView }); } } + + public interface OnStateChangeListener { + + /** + * Called when the workspace state is changing. + * @param toState final state + * @param targetAnim animation which will be played during the transition or null. + */ + void prepareStateChange(State toState, AnimatorSet targetAnim); + } } |