Adding support for workspace state change listener
Change-Id: Id0a4bcf345ce928544f5d406f37252a00d1dc7af
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user