summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-10-26 15:36:10 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-10-26 16:38:55 -0700
commit5bc6b6f14c676e7528be62e1355a4dec3d783524 (patch)
tree4923c690c29907b54f8f27a444fe0c61bb78408a /src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
parentd4ece005e43a39af08a17acc9ad801729a5dc9d4 (diff)
downloadandroid_packages_apps_Trebuchet-5bc6b6f14c676e7528be62e1355a4dec3d783524.tar.gz
android_packages_apps_Trebuchet-5bc6b6f14c676e7528be62e1355a4dec3d783524.tar.bz2
android_packages_apps_Trebuchet-5bc6b6f14c676e7528be62e1355a4dec3d783524.zip
Consolidating various interpolators
Change-Id: I9588eee3552001b162a1e8d5ccefcfb44d221880
Diffstat (limited to 'src/com/android/launcher3/WorkspaceStateTransitionAnimation.java')
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java60
1 files changed, 7 insertions, 53 deletions
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 0ccb8ad91..fcccdf985 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -30,10 +30,10 @@ import android.content.res.Resources;
import android.util.Property;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
-import android.view.animation.DecelerateInterpolator;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.anim.AnimationLayerSet;
+import com.android.launcher3.anim.Interpolators;
/**
* A convenience class to update a view's visibility state after an alpha animation.
@@ -86,58 +86,12 @@ class AlphaUpdateListener extends AnimatorListenerAdapter implements ValueAnimat
}
/**
- * This interpolator emulates the rate at which the perceived scale of an object changes
- * as its distance from a camera increases. When this interpolator is applied to a scale
- * animation on a view, it evokes the sense that the object is shrinking due to moving away
- * from the camera.
- */
-class ZInterpolator implements TimeInterpolator {
- private float focalLength;
-
- public ZInterpolator(float foc) {
- focalLength = foc;
- }
-
- public float getInterpolation(float input) {
- return (1.0f - focalLength / (focalLength + input)) /
- (1.0f - focalLength / (focalLength + 1.0f));
- }
-}
-
-/**
- * The exact reverse of ZInterpolator.
- */
-class InverseZInterpolator implements TimeInterpolator {
- private ZInterpolator zInterpolator;
- public InverseZInterpolator(float foc) {
- zInterpolator = new ZInterpolator(foc);
- }
- public float getInterpolation(float input) {
- return 1 - zInterpolator.getInterpolation(1 - input);
- }
-}
-
-/**
- * InverseZInterpolator compounded with an ease-out.
- */
-class ZoomInInterpolator implements TimeInterpolator {
- private final InverseZInterpolator inverseZInterpolator = new InverseZInterpolator(0.35f);
- private final DecelerateInterpolator decelerate = new DecelerateInterpolator(3.0f);
-
- public float getInterpolation(float input) {
- return decelerate.getInterpolation(inverseZInterpolator.getInterpolation(input));
- }
-}
-
-/**
* Manages the animations between each of the workspace states.
*/
public class WorkspaceStateTransitionAnimation {
private static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
- private final ZoomInInterpolator mZoomInInterpolator = new ZoomInInterpolator();
-
public final int mWorkspaceScrimAlpha;
private final Launcher mLauncher;
@@ -197,13 +151,13 @@ public class WorkspaceStateTransitionAnimation {
propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha),
mLauncher.getHotseat(), finalHotseatAlpha);
- propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, mZoomInInterpolator);
+ propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
- finalWorkspaceTranslationY, mZoomInInterpolator);
+ finalWorkspaceTranslationY, Interpolators.ZOOM_IN);
// Set scrim
propertySetter.setInt(mLauncher.getDragLayer().getScrim(), DRAWABLE_ALPHA,
- state.hasScrim ? mWorkspaceScrimAlpha : 0, new DecelerateInterpolator(1.5f));
+ state.hasScrim ? mWorkspaceScrimAlpha : 0, Interpolators.DEACCEL_1_5);
}
public void applyChildState(LauncherState state, CellLayout cl, int childIndex) {
@@ -214,13 +168,13 @@ public class WorkspaceStateTransitionAnimation {
private void applyChildState(LauncherState state, CellLayout cl, int childIndex,
int centerPage, PropertySetter propertySetter) {
propertySetter.setInt(cl.getScrimBackground(),
- DRAWABLE_ALPHA, state.hasScrim ? 255 : 0, mZoomInInterpolator);
+ DRAWABLE_ALPHA, state.hasScrim ? 255 : 0, Interpolators.ZOOM_IN);
// Only animate the page alpha when we actually fade pages
if (mWorkspaceFadeInAdjacentScreens) {
float finalAlpha = state == LauncherState.NORMAL && childIndex != centerPage ? 0 : 1f;
propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
- finalAlpha, mZoomInInterpolator);
+ finalAlpha, Interpolators.ZOOM_IN);
}
}
@@ -302,7 +256,7 @@ public class WorkspaceStateTransitionAnimation {
}
private TimeInterpolator getFadeInterpolator(float finalAlpha) {
- return finalAlpha == 0 ? new DecelerateInterpolator(2) : null;
+ return finalAlpha == 0 ? Interpolators.DEACCEL_2 : null;
}
}
} \ No newline at end of file