summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/LauncherStateManager.java21
-rw-r--r--src/com/android/launcher3/Workspace.java10
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java11
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java8
-rw-r--r--src/com/android/launcher3/anim/AnimatorSetBuilder.java43
5 files changed, 73 insertions, 20 deletions
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 2cad95e9b..de21c7f51 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -28,6 +28,7 @@ import android.view.View;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.uioverrides.UiFactory;
/**
@@ -178,7 +179,8 @@ public class LauncherStateManager {
// transition plays in reverse and use the same duration as previous state.
mConfig.duration = state == NORMAL ? mState.transitionDuration : state.transitionDuration;
- AnimatorSet animation = createAnimationToNewWorkspaceInternal(state, onCompleteRunnable);
+ AnimatorSet animation = createAnimationToNewWorkspaceInternal(
+ state, new AnimatorSetBuilder(), onCompleteRunnable);
Runnable runnable = new StartAnimRunnable(animation, state.getFinalFocus(mLauncher));
if (delay > 0) {
mUiHandler.postDelayed(runnable, delay);
@@ -196,21 +198,28 @@ public class LauncherStateManager {
*/
public AnimatorPlaybackController createAnimationToNewWorkspace(
LauncherState state, long duration) {
+ return createAnimationToNewWorkspace(state, new AnimatorSetBuilder(), duration);
+ }
+
+ public AnimatorPlaybackController createAnimationToNewWorkspace(
+ LauncherState state, AnimatorSetBuilder builder, long duration) {
mConfig.reset();
mConfig.userControlled = true;
mConfig.duration = duration;
return AnimatorPlaybackController.wrap(
- createAnimationToNewWorkspaceInternal(state, null), duration);
+ createAnimationToNewWorkspaceInternal(state, builder, null), duration);
}
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
- final Runnable onCompleteRunnable) {
- final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
+ AnimatorSetBuilder builder, final Runnable onCompleteRunnable) {
final AnimationLayerSet layerViews = new AnimationLayerSet();
for (StateHandler handler : getStateHandlers()) {
- handler.setStateWithAnimation(state, layerViews, animation, mConfig);
+ builder.startTag(handler);
+ handler.setStateWithAnimation(state, layerViews, builder, mConfig);
}
+
+ final AnimatorSet animation = builder.build();
animation.addListener(layerViews);
animation.addListener(new AnimationSuccessListener() {
@@ -331,7 +340,7 @@ public class LauncherStateManager {
* Sets the UI to {@param state} by animating any changes.
*/
void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config);
+ AnimatorSetBuilder builder, AnimationConfig config);
}
public interface StateListener {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 3d59bad13..0841c4bc7 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -26,7 +26,6 @@ import static com.android.launcher3.Utilities.isAccessibilityEnabled;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
@@ -64,6 +63,7 @@ import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.badge.FolderBadgeInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
@@ -1548,9 +1548,9 @@ public class Workspace extends PagedView
*/
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet anim, AnimationConfig config) {
+ AnimatorSetBuilder builder, AnimationConfig config) {
StateTransitionListener listener = new StateTransitionListener(toState);
- mStateTransitionAnimation.setStateWithAnimation(toState, anim, layerViews, config);
+ mStateTransitionAnimation.setStateWithAnimation(toState, builder, layerViews, config);
// Invalidate the pages now, so that we have the visible pages before the
// animation is started
@@ -1562,8 +1562,8 @@ public class Workspace extends PagedView
ValueAnimator stepAnimator = ValueAnimator.ofFloat(0, 1);
stepAnimator.addUpdateListener(listener);
stepAnimator.setDuration(config.duration);
- anim.play(stepAnimator);
- anim.addListener(listener);
+ stepAnimator.addListener(listener);
+ builder.play(stepAnimator);
}
public void updateAccessibilityFlags() {
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index edf5ada6e..0ec3142dc 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -33,6 +33,7 @@ import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.LauncherState.PageAlphaProvider;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
/**
@@ -110,10 +111,10 @@ public class WorkspaceStateTransitionAnimation {
setWorkspaceProperty(toState, NO_ANIM_PROPERTY_SETTER);
}
- public void setStateWithAnimation(LauncherState toState, AnimatorSet anim,
+ public void setStateWithAnimation(LauncherState toState, AnimatorSetBuilder builder,
AnimationLayerSet layerViews, AnimationConfig config) {
AnimatedPropertySetter propertySetter =
- new AnimatedPropertySetter(config.duration, layerViews, anim);
+ new AnimatedPropertySetter(config.duration, layerViews, builder);
setWorkspaceProperty(toState, propertySetter);
}
@@ -190,13 +191,13 @@ public class WorkspaceStateTransitionAnimation {
private final long mDuration;
private final AnimationLayerSet mLayerViews;
- private final AnimatorSet mStateAnimator;
+ private final AnimatorSetBuilder mStateAnimator;
public AnimatedPropertySetter(
- long duration, AnimationLayerSet layerView, AnimatorSet anim) {
+ long duration, AnimationLayerSet layerView, AnimatorSetBuilder builder) {
mDuration = duration;
mLayerViews = layerView;
- mStateAnimator = anim;
+ mStateAnimator = builder;
}
@Override
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 7ce032f40..14ad97b45 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -5,7 +5,6 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.util.Property;
import android.view.View;
@@ -21,6 +20,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
+import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.graphics.GradientView;
import com.android.launcher3.util.SystemUiController;
@@ -122,7 +122,7 @@ public class AllAppsTransitionController
* @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
*
* @see #setState(LauncherState)
- * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig)
+ * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSetBuilder, AnimationConfig)
*/
public void setProgress(float progress) {
mProgress = progress;
@@ -168,7 +168,7 @@ public class AllAppsTransitionController
*/
@Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
- AnimatorSet animationOut, AnimationConfig config) {
+ AnimatorSetBuilder builder, AnimationConfig config) {
if (Float.compare(mProgress, toState.verticalProgress) == 0) {
// Fail fast
onProgressAnimationEnd();
@@ -182,7 +182,7 @@ public class AllAppsTransitionController
anim.setInterpolator(interpolator);
anim.addListener(getProgressAnimatorListener());
- animationOut.play(anim);
+ builder.play(anim);
}
public AnimatorListenerAdapter getProgressAnimatorListener() {
diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
new file mode 100644
index 000000000..0e44b73ce
--- /dev/null
+++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.anim;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+
+import com.android.launcher3.LauncherAnimUtils;
+
+import java.util.ArrayList;
+
+/**
+ * Utility class for building animator set
+ */
+public class AnimatorSetBuilder {
+
+ protected final ArrayList<Animator> mAnims = new ArrayList<>();
+
+ public void startTag(Object obj) { }
+
+ public void play(Animator anim) {
+ mAnims.add(anim);
+ }
+
+ public AnimatorSet build() {
+ AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
+ anim.playTogether(mAnims);
+ return anim;
+ }
+}