summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-06-07 16:21:03 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-06-07 16:21:47 -0700
commit9443ef5ec69ee673b89c6387f065cf1d45eb2d5b (patch)
tree8049b43a7cab72b718fb0094d28de2524319eec1
parent081cca3731f99b1031bbb580f529b21a09a0581f (diff)
downloadandroid_packages_apps_Trebuchet-9443ef5ec69ee673b89c6387f065cf1d45eb2d5b.tar.gz
android_packages_apps_Trebuchet-9443ef5ec69ee673b89c6387f065cf1d45eb2d5b.tar.bz2
android_packages_apps_Trebuchet-9443ef5ec69ee673b89c6387f065cf1d45eb2d5b.zip
Adding support for workspace state change listener
Change-Id: Id0a4bcf345ce928544f5d406f37252a00d1dc7af
-rw-r--r--src/com/android/launcher3/Workspace.java24
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);
+ }
}