diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-10-27 02:35:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-10-27 02:35:30 +0000 |
commit | 4fc994c98875b4797d3c491c8c8353c8cc6b8915 (patch) | |
tree | a7e07591a1a03ed0affce03ae1828c3c6353f032 /src/com/android/launcher3/WorkspaceStateTransitionAnimation.java | |
parent | c01cb4745aa677bea126e4e4f03c413875a37870 (diff) | |
parent | 5bc6b6f14c676e7528be62e1355a4dec3d783524 (diff) | |
download | android_packages_apps_Trebuchet-4fc994c98875b4797d3c491c8c8353c8cc6b8915.tar.gz android_packages_apps_Trebuchet-4fc994c98875b4797d3c491c8c8353c8cc6b8915.tar.bz2 android_packages_apps_Trebuchet-4fc994c98875b4797d3c491c8c8353c8cc6b8915.zip |
Merge "Consolidating various interpolators" into ub-launcher3-master
Diffstat (limited to 'src/com/android/launcher3/WorkspaceStateTransitionAnimation.java')
-rw-r--r-- | src/com/android/launcher3/WorkspaceStateTransitionAnimation.java | 60 |
1 files changed, 7 insertions, 53 deletions
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 9ae0fe4ba..e14461e85 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; @@ -195,13 +149,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) { @@ -212,13 +166,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); } } @@ -300,7 +254,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 |