Refactor InsettableFrameLayout/DragLayer and add StateListener interface.

Bug: 65387919
Change-Id: I5eb94c0f3962d44f63af3efc92d852e019bba711
This commit is contained in:
Jon Miranda
2017-11-08 14:38:23 -08:00
parent ea529083bd
commit 758d5047be
3 changed files with 38 additions and 13 deletions

View File

@@ -25,7 +25,6 @@ import android.os.Handler;
import android.os.Looper;
import android.view.View;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -83,6 +82,8 @@ public class LauncherStateManager {
private StateHandler[] mStateHandlers;
private LauncherState mState = NORMAL;
private StateListener mStateListener;
public LauncherStateManager(Launcher l) {
mUiHandler = new Handler(Looper.getMainLooper());
mLauncher = l;
@@ -99,6 +100,10 @@ public class LauncherStateManager {
return mStateHandlers;
}
public void setStateListener(StateListener stateListener) {
mStateListener = stateListener;
}
/**
* @see #goToState(LauncherState, boolean, Runnable)
*/
@@ -157,6 +162,9 @@ public class LauncherStateManager {
for (StateHandler handler : getStateHandlers()) {
handler.setState(state);
}
if (mStateListener != null) {
mStateListener.onStateSetImmediately(state);
}
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
// Run any queued runnable
@@ -210,6 +218,17 @@ public class LauncherStateManager {
public void onAnimationStart(Animator animation) {
// Change the internal state only when the transition actually starts
setState(state);
if (mStateListener != null) {
mStateListener.onStateTransitionStart(state);
}
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (mStateListener != null) {
mStateListener.onStateTransitionComplete(mState);
}
}
@Override
@@ -304,4 +323,15 @@ public class LauncherStateManager {
void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
AnimatorSet anim, AnimationConfig config);
}
public interface StateListener {
/**
* Called when the state is set without an animation.
*/
void onStateSetImmediately(LauncherState state);
void onStateTransitionStart(LauncherState toState);
void onStateTransitionComplete(LauncherState finalState);
}
}