From 548038a155d94f674e7afc622f2a5b356a6f5328 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Thu, 18 Oct 2012 14:02:16 -0700 Subject: Various transition tweaks/fixes in Gallery Bug: 7376109 -Add new animation preset for photos based on UX feedback -Fix showing of highlight when tapping album grid photo -Move StateTransition enum to StateTransitionAnimation.State Change-Id: I2ce57580fa6c5f34d9545561515031899eb41eb2 --- .../gallery3d/anim/StateTransitionAnimation.java | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'src/com/android/gallery3d/anim/StateTransitionAnimation.java') diff --git a/src/com/android/gallery3d/anim/StateTransitionAnimation.java b/src/com/android/gallery3d/anim/StateTransitionAnimation.java index d4d59d341..8428cb866 100644 --- a/src/com/android/gallery3d/anim/StateTransitionAnimation.java +++ b/src/com/android/gallery3d/anim/StateTransitionAnimation.java @@ -29,6 +29,7 @@ public class StateTransitionAnimation extends Animation { public static class Spec { public static final Spec OUTGOING; public static final Spec INCOMING; + public static final Spec PHOTO_INCOMING; public int duration = 330; public float backgroundAlphaFrom = 0; @@ -67,9 +68,36 @@ public class StateTransitionAnimation extends Animation { INCOMING.contentScaleFrom = 0.25f; INCOMING.contentScaleTo = 1f; INCOMING.interpolator = new DecelerateInterpolator(); + + PHOTO_INCOMING = new Spec(); + PHOTO_INCOMING.overlayAlphaFrom = 1f; + PHOTO_INCOMING.overlayAlphaTo = 0f; + PHOTO_INCOMING.overlayScaleFrom = 1f; + PHOTO_INCOMING.overlayScaleTo = 1f; + PHOTO_INCOMING.contentAlphaFrom = 0f; + PHOTO_INCOMING.contentAlphaTo = 1f; + PHOTO_INCOMING.contentScaleFrom = 0.1f; + PHOTO_INCOMING.contentScaleTo = 1f; + PHOTO_INCOMING.interpolator = new DecelerateInterpolator(); + } + + private static Spec specForTransition(Transition t) { + switch (t) { + case Outgoing: + return Spec.OUTGOING; + case Incoming: + return Spec.INCOMING; + case PhotoIncoming: + return Spec.PHOTO_INCOMING; + case None: + default: + return null; + } } } + public static enum Transition { None, Outgoing, Incoming, PhotoIncoming } + private final Spec mTransitionSpec; private float mCurrentContentScale; private float mCurrentContentAlpha; @@ -79,22 +107,26 @@ public class StateTransitionAnimation extends Animation { private float mCurrentOverlayAlpha; private RawTexture mOldScreenTexture; + public StateTransitionAnimation(Transition t, RawTexture oldScreen) { + this(Spec.specForTransition(t), oldScreen); + } + public StateTransitionAnimation(Spec spec, RawTexture oldScreen) { mTransitionSpec = spec != null ? spec : Spec.OUTGOING; setDuration(mTransitionSpec.duration); setInterpolator(mTransitionSpec.interpolator); mOldScreenTexture = oldScreen; - if (mOldScreenTexture != null) { - TiledScreenNail.disableDrawPlaceholder(); - } + TiledScreenNail.disableDrawPlaceholder(); } @Override public boolean calculate(long currentTimeMillis) { boolean retval = super.calculate(currentTimeMillis); - if (mOldScreenTexture != null && !isActive()) { - mOldScreenTexture.recycle(); - mOldScreenTexture = null; + if (!isActive()) { + if (mOldScreenTexture != null) { + mOldScreenTexture.recycle(); + mOldScreenTexture = null; + } TiledScreenNail.enableDrawPlaceholder(); } return retval; -- cgit v1.2.3