Transition API changes from API council recommendations
Issue #10460684 KLP API Review: android.view.transition and android.animation Issue #10570740 Transitions: inflate transition targets from xml Change-Id: I7a3f6d3aece2fcafc5efd555d033f79e86635c98
This commit is contained in:
@@ -175,6 +175,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framew
|
||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/src/core/java/android/print/IPrinterDiscoverySessionClient.*)
|
||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/src/core/java/android/os/IBattery*)
|
||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates)
|
||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates)
|
||||
# ************************************************
|
||||
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
|
||||
# ************************************************
|
||||
|
||||
295
api/current.txt
295
api/current.txt
@@ -261,7 +261,7 @@ package android {
|
||||
field public static final int activityCloseExitAnimation = 16842939; // 0x10100bb
|
||||
field public static final int activityOpenEnterAnimation = 16842936; // 0x10100b8
|
||||
field public static final int activityOpenExitAnimation = 16842937; // 0x10100b9
|
||||
field public static final int addPrintersActivity = 16843747; // 0x10103e3
|
||||
field public static final int addPrintersActivity = 16843750; // 0x10103e6
|
||||
field public static final int addStatesFromChildren = 16842992; // 0x10100f0
|
||||
field public static final int adjustViewBounds = 16843038; // 0x101011e
|
||||
field public static final int alertDialogIcon = 16843605; // 0x1010355
|
||||
@@ -289,14 +289,14 @@ package android {
|
||||
field public static final deprecated int animationResolution = 16843546; // 0x101031a
|
||||
field public static final int antialias = 16843034; // 0x101011a
|
||||
field public static final int anyDensity = 16843372; // 0x101026c
|
||||
field public static final int apduServiceBanner = 16843755; // 0x10103eb
|
||||
field public static final int apduServiceBanner = 16843758; // 0x10103ee
|
||||
field public static final int apiKey = 16843281; // 0x1010211
|
||||
field public static final int author = 16843444; // 0x10102b4
|
||||
field public static final int authorities = 16842776; // 0x1010018
|
||||
field public static final int autoAdvanceViewId = 16843535; // 0x101030f
|
||||
field public static final int autoCompleteTextViewStyle = 16842859; // 0x101006b
|
||||
field public static final int autoLink = 16842928; // 0x10100b0
|
||||
field public static final int autoMirrored = 16843752; // 0x10103e8
|
||||
field public static final int autoMirrored = 16843755; // 0x10103eb
|
||||
field public static final int autoStart = 16843445; // 0x10102b5
|
||||
field public static final deprecated int autoText = 16843114; // 0x101016a
|
||||
field public static final int autoUrlDetect = 16843404; // 0x101028c
|
||||
@@ -337,7 +337,7 @@ package android {
|
||||
field public static final int canRetrieveWindowContent = 16843653; // 0x1010385
|
||||
field public static final int candidatesTextStyleSpans = 16843312; // 0x1010230
|
||||
field public static final deprecated int capitalize = 16843113; // 0x1010169
|
||||
field public static final int category = 16843749; // 0x10103e5
|
||||
field public static final int category = 16843752; // 0x10103e8
|
||||
field public static final int centerBright = 16842956; // 0x10100cc
|
||||
field public static final int centerColor = 16843275; // 0x101020b
|
||||
field public static final int centerDark = 16842952; // 0x10100c8
|
||||
@@ -393,7 +393,7 @@ package android {
|
||||
field public static final int cropToPadding = 16843043; // 0x1010123
|
||||
field public static final int cursorVisible = 16843090; // 0x1010152
|
||||
field public static final int customNavigationLayout = 16843474; // 0x10102d2
|
||||
field public static final int customRoots = 16843751; // 0x10103e7
|
||||
field public static final int customRoots = 16843754; // 0x10103ea
|
||||
field public static final int customTokens = 16843579; // 0x101033b
|
||||
field public static final int cycles = 16843220; // 0x10101d4
|
||||
field public static final int dashGap = 16843175; // 0x10101a7
|
||||
@@ -487,6 +487,7 @@ package android {
|
||||
field public static final int fadeScrollbars = 16843434; // 0x10102aa
|
||||
field public static final int fadingEdge = 16842975; // 0x10100df
|
||||
field public static final int fadingEdgeLength = 16842976; // 0x10100e0
|
||||
field public static final int fadingMode = 16843745; // 0x10103e1
|
||||
field public static final int fastScrollAlwaysVisible = 16843573; // 0x1010335
|
||||
field public static final int fastScrollEnabled = 16843302; // 0x1010226
|
||||
field public static final int fastScrollOverlayPosition = 16843578; // 0x101033a
|
||||
@@ -612,7 +613,7 @@ package android {
|
||||
field public static final int installLocation = 16843447; // 0x10102b7
|
||||
field public static final int interpolator = 16843073; // 0x1010141
|
||||
field public static final int isAlwaysSyncable = 16843571; // 0x1010333
|
||||
field public static final int isAsciiCapable = 16843750; // 0x10103e6
|
||||
field public static final int isAsciiCapable = 16843753; // 0x10103e9
|
||||
field public static final int isAuxiliary = 16843647; // 0x101037f
|
||||
field public static final int isDefault = 16843297; // 0x1010221
|
||||
field public static final int isIndicator = 16843079; // 0x1010147
|
||||
@@ -845,7 +846,7 @@ package android {
|
||||
field public static final int prompt = 16843131; // 0x101017b
|
||||
field public static final int propertyName = 16843489; // 0x10102e1
|
||||
field public static final int protectionLevel = 16842761; // 0x1010009
|
||||
field public static final int provideAssistData = 16843756; // 0x10103ec
|
||||
field public static final int provideAssistData = 16843759; // 0x10103ef
|
||||
field public static final int publicKey = 16843686; // 0x10103a6
|
||||
field public static final int queryActionMsg = 16843227; // 0x10101db
|
||||
field public static final int queryAfterZeroResults = 16843394; // 0x1010282
|
||||
@@ -870,7 +871,7 @@ package android {
|
||||
field public static final int reqKeyboardType = 16843304; // 0x1010228
|
||||
field public static final int reqNavigation = 16843306; // 0x101022a
|
||||
field public static final int reqTouchScreen = 16843303; // 0x1010227
|
||||
field public static final int requireDeviceUnlock = 16843754; // 0x10103ea
|
||||
field public static final int requireDeviceUnlock = 16843757; // 0x10103ed
|
||||
field public static final int required = 16843406; // 0x101028e
|
||||
field public static final int requiredAccountType = 16843734; // 0x10103d6
|
||||
field public static final int requiredForAllUsers = 16843728; // 0x10103d0
|
||||
@@ -969,12 +970,13 @@ package android {
|
||||
field public static final int spinnersShown = 16843595; // 0x101034b
|
||||
field public static final int splitMotionEvents = 16843503; // 0x10102ef
|
||||
field public static final int src = 16843033; // 0x1010119
|
||||
field public static final int ssp = 16843744; // 0x10103e0
|
||||
field public static final int sspPattern = 16843746; // 0x10103e2
|
||||
field public static final int sspPrefix = 16843745; // 0x10103e1
|
||||
field public static final int ssp = 16843747; // 0x10103e3
|
||||
field public static final int sspPattern = 16843749; // 0x10103e5
|
||||
field public static final int sspPrefix = 16843748; // 0x10103e4
|
||||
field public static final int stackFromBottom = 16843005; // 0x10100fd
|
||||
field public static final int starStyle = 16842882; // 0x1010082
|
||||
field public static final int startColor = 16843165; // 0x101019d
|
||||
field public static final int startDelay = 16843746; // 0x10103e2
|
||||
field public static final int startOffset = 16843198; // 0x10101be
|
||||
field public static final deprecated int startYear = 16843132; // 0x101017c
|
||||
field public static final int stateNotNeeded = 16842774; // 0x1010016
|
||||
@@ -1018,7 +1020,7 @@ package android {
|
||||
field public static final int summaryOff = 16843248; // 0x10101f0
|
||||
field public static final int summaryOn = 16843247; // 0x10101ef
|
||||
field public static final int supportsRtl = 16843695; // 0x10103af
|
||||
field public static final int supportsSwitchingToNextInputMethod = 16843753; // 0x10103e9
|
||||
field public static final int supportsSwitchingToNextInputMethod = 16843756; // 0x10103ec
|
||||
field public static final int supportsUploading = 16843419; // 0x101029b
|
||||
field public static final int switchMinWidth = 16843632; // 0x1010370
|
||||
field public static final int switchPadding = 16843633; // 0x1010371
|
||||
@@ -1035,7 +1037,7 @@ package android {
|
||||
field public static final int targetActivity = 16843266; // 0x1010202
|
||||
field public static final int targetClass = 16842799; // 0x101002f
|
||||
field public static final int targetDescriptions = 16843680; // 0x10103a0
|
||||
field public static final int targetID = 16843740; // 0x10103dc
|
||||
field public static final int targetId = 16843740; // 0x10103dc
|
||||
field public static final int targetPackage = 16842785; // 0x1010021
|
||||
field public static final int targetSdkVersion = 16843376; // 0x1010270
|
||||
field public static final int taskAffinity = 16842770; // 0x1010012
|
||||
@@ -1140,6 +1142,7 @@ package android {
|
||||
field public static final int transformPivotX = 16843552; // 0x1010320
|
||||
field public static final int transformPivotY = 16843553; // 0x1010321
|
||||
field public static final int transition = 16843743; // 0x10103df
|
||||
field public static final int transitionOrdering = 16843744; // 0x10103e0
|
||||
field public static final int translationX = 16843554; // 0x1010322
|
||||
field public static final int translationY = 16843555; // 0x1010323
|
||||
field public static final int type = 16843169; // 0x10101a1
|
||||
@@ -1158,7 +1161,7 @@ package android {
|
||||
field public static final int valueTo = 16843487; // 0x10102df
|
||||
field public static final int valueType = 16843488; // 0x10102e0
|
||||
field public static final int variablePadding = 16843157; // 0x1010195
|
||||
field public static final int vendor = 16843748; // 0x10103e4
|
||||
field public static final int vendor = 16843751; // 0x10103e7
|
||||
field public static final int versionCode = 16843291; // 0x101021b
|
||||
field public static final int versionName = 16843292; // 0x101021c
|
||||
field public static final int verticalCorrection = 16843322; // 0x101023a
|
||||
@@ -2349,7 +2352,6 @@ package android.animation {
|
||||
method public abstract long getDuration();
|
||||
method public android.animation.TimeInterpolator getInterpolator();
|
||||
method public java.util.ArrayList<android.animation.Animator.AnimatorListener> getListeners();
|
||||
method public java.util.ArrayList<android.animation.Animator.AnimatorPauseListener> getPauseListeners();
|
||||
method public abstract long getStartDelay();
|
||||
method public boolean isPaused();
|
||||
method public abstract boolean isRunning();
|
||||
@@ -25536,6 +25538,119 @@ package android.text.util {
|
||||
|
||||
}
|
||||
|
||||
package android.transition {
|
||||
|
||||
public class AutoTransition extends android.transition.TransitionSet {
|
||||
ctor public AutoTransition();
|
||||
}
|
||||
|
||||
public class ChangeBounds extends android.transition.Transition {
|
||||
ctor public ChangeBounds();
|
||||
method public void captureEndValues(android.transition.TransitionValues);
|
||||
method public void captureStartValues(android.transition.TransitionValues);
|
||||
method public void setReparent(boolean);
|
||||
method public void setResizeClip(boolean);
|
||||
}
|
||||
|
||||
public class Fade extends android.transition.Visibility {
|
||||
ctor public Fade();
|
||||
ctor public Fade(int);
|
||||
field public static final int IN = 1; // 0x1
|
||||
field public static final int OUT = 2; // 0x2
|
||||
}
|
||||
|
||||
public final class Scene {
|
||||
ctor public Scene(android.view.ViewGroup);
|
||||
ctor public Scene(android.view.ViewGroup, android.view.ViewGroup);
|
||||
method public void enter();
|
||||
method public void exit();
|
||||
method public static android.transition.Scene getSceneForLayout(android.view.ViewGroup, int, android.content.Context);
|
||||
method public android.view.ViewGroup getSceneRoot();
|
||||
method public void setEnterAction(java.lang.Runnable);
|
||||
method public void setExitAction(java.lang.Runnable);
|
||||
}
|
||||
|
||||
public abstract class Transition implements java.lang.Cloneable {
|
||||
ctor public Transition();
|
||||
method public android.transition.Transition addListener(android.transition.Transition.TransitionListener);
|
||||
method public android.transition.Transition addTarget(android.view.View);
|
||||
method public android.transition.Transition addTargetId(int);
|
||||
method public abstract void captureEndValues(android.transition.TransitionValues);
|
||||
method public abstract void captureStartValues(android.transition.TransitionValues);
|
||||
method public android.transition.Transition clone();
|
||||
method public android.animation.Animator createAnimator(android.view.ViewGroup, android.transition.TransitionValues, android.transition.TransitionValues);
|
||||
method public long getDuration();
|
||||
method public android.animation.TimeInterpolator getInterpolator();
|
||||
method public java.lang.String getName();
|
||||
method public long getStartDelay();
|
||||
method public java.util.List<java.lang.Integer> getTargetIds();
|
||||
method public java.util.List<android.view.View> getTargets();
|
||||
method public java.lang.String[] getTransitionProperties();
|
||||
method public android.transition.TransitionValues getTransitionValues(android.view.View, boolean);
|
||||
method public android.transition.Transition removeListener(android.transition.Transition.TransitionListener);
|
||||
method public android.transition.Transition removeTarget(android.view.View);
|
||||
method public android.transition.Transition removeTargetId(int);
|
||||
method public android.transition.Transition setDuration(long);
|
||||
method public android.transition.Transition setInterpolator(android.animation.TimeInterpolator);
|
||||
method public android.transition.Transition setStartDelay(long);
|
||||
}
|
||||
|
||||
public static abstract interface Transition.TransitionListener {
|
||||
method public abstract void onTransitionCancel(android.transition.Transition);
|
||||
method public abstract void onTransitionEnd(android.transition.Transition);
|
||||
method public abstract void onTransitionPause(android.transition.Transition);
|
||||
method public abstract void onTransitionResume(android.transition.Transition);
|
||||
method public abstract void onTransitionStart(android.transition.Transition);
|
||||
}
|
||||
|
||||
public class TransitionInflater {
|
||||
method public static android.transition.TransitionInflater from(android.content.Context);
|
||||
method public android.transition.Transition inflateTransition(int);
|
||||
method public android.transition.TransitionManager inflateTransitionManager(int, android.view.ViewGroup);
|
||||
}
|
||||
|
||||
public class TransitionManager {
|
||||
ctor public TransitionManager();
|
||||
method public static void beginDelayedTransition(android.view.ViewGroup);
|
||||
method public static void beginDelayedTransition(android.view.ViewGroup, android.transition.Transition);
|
||||
method public static android.transition.Transition getDefaultTransition();
|
||||
method public static void go(android.transition.Scene);
|
||||
method public static void go(android.transition.Scene, android.transition.Transition);
|
||||
method public void setDefaultTransition(android.transition.Transition);
|
||||
method public void setTransition(android.transition.Scene, android.transition.Transition);
|
||||
method public void setTransition(android.transition.Scene, android.transition.Scene, android.transition.Transition);
|
||||
method public void transitionTo(android.transition.Scene);
|
||||
}
|
||||
|
||||
public class TransitionSet extends android.transition.Transition {
|
||||
ctor public TransitionSet();
|
||||
method public android.transition.TransitionSet addTransition(android.transition.Transition);
|
||||
method public void captureEndValues(android.transition.TransitionValues);
|
||||
method public void captureStartValues(android.transition.TransitionValues);
|
||||
method public int getOrdering();
|
||||
method public android.transition.TransitionSet removeTransition(android.transition.Transition);
|
||||
method public android.transition.TransitionSet setOrdering(int);
|
||||
field public static final int ORDERING_SEQUENTIAL = 1; // 0x1
|
||||
field public static final int ORDERING_TOGETHER = 0; // 0x0
|
||||
}
|
||||
|
||||
public class TransitionValues {
|
||||
ctor public TransitionValues();
|
||||
field public final java.util.Map values;
|
||||
field public android.view.View view;
|
||||
}
|
||||
|
||||
public abstract class Visibility extends android.transition.Transition {
|
||||
ctor public Visibility();
|
||||
method public void captureEndValues(android.transition.TransitionValues);
|
||||
method public void captureStartValues(android.transition.TransitionValues);
|
||||
method public boolean isVisible(android.transition.TransitionValues);
|
||||
method public android.animation.Animator onAppear(android.view.ViewGroup, android.transition.TransitionValues, int, android.transition.TransitionValues, int);
|
||||
method public android.animation.Animator onDisappear(android.view.ViewGroup, android.transition.TransitionValues, int, android.transition.TransitionValues, int);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.util {
|
||||
|
||||
public class AndroidException extends java.lang.Exception {
|
||||
@@ -27432,7 +27547,6 @@ package android.view {
|
||||
method public java.lang.CharSequence getContentDescription();
|
||||
method public final android.content.Context getContext();
|
||||
method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
|
||||
method public android.view.transition.Scene getCurrentScene();
|
||||
method public static int getDefaultSize(int, int);
|
||||
method public android.view.Display getDisplay();
|
||||
method public final int[] getDrawableState();
|
||||
@@ -29709,155 +29823,6 @@ package android.view.textservice {
|
||||
|
||||
}
|
||||
|
||||
package android.view.transition {
|
||||
|
||||
public class AutoTransition extends android.view.transition.TransitionGroup {
|
||||
ctor public AutoTransition();
|
||||
}
|
||||
|
||||
public class Crossfade extends android.view.transition.Transition {
|
||||
ctor public Crossfade();
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method public int getFadeBehavior();
|
||||
method public int getResizeBehavior();
|
||||
method public void setFadeBehavior(int);
|
||||
method public void setResizeBehavior(int);
|
||||
field public static final int FADE_BEHAVIOR_CROSSFADE = 0; // 0x0
|
||||
field public static final int FADE_BEHAVIOR_OUT_IN = 2; // 0x2
|
||||
field public static final int FADE_BEHAVIOR_REVEAL = 1; // 0x1
|
||||
field public static final int RESIZE_BEHAVIOR_NONE = 0; // 0x0
|
||||
field public static final int RESIZE_BEHAVIOR_SCALE = 1; // 0x1
|
||||
}
|
||||
|
||||
public class Fade extends android.view.transition.Visibility {
|
||||
ctor public Fade();
|
||||
ctor public Fade(int);
|
||||
field public static final int IN = 1; // 0x1
|
||||
field public static final int OUT = 2; // 0x2
|
||||
}
|
||||
|
||||
public class Move extends android.view.transition.Transition {
|
||||
ctor public Move();
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method public void setReparent(boolean);
|
||||
method public void setResizeClip(boolean);
|
||||
}
|
||||
|
||||
public class Recolor extends android.view.transition.Transition {
|
||||
ctor public Recolor();
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
}
|
||||
|
||||
public class Rotate extends android.view.transition.Transition {
|
||||
ctor public Rotate();
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
}
|
||||
|
||||
public final class Scene {
|
||||
ctor public Scene(android.view.ViewGroup);
|
||||
ctor public Scene(android.view.ViewGroup, int, android.content.Context);
|
||||
ctor public Scene(android.view.ViewGroup, android.view.ViewGroup);
|
||||
method public void enter();
|
||||
method public void exit();
|
||||
method public android.view.ViewGroup getSceneRoot();
|
||||
method public void setEnterAction(java.lang.Runnable);
|
||||
method public void setExitAction(java.lang.Runnable);
|
||||
}
|
||||
|
||||
public class Slide extends android.view.transition.Visibility {
|
||||
ctor public Slide();
|
||||
}
|
||||
|
||||
public class TextChange extends android.view.transition.Transition {
|
||||
ctor public TextChange();
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method public void setChangeBehavior(int);
|
||||
field public static final int CHANGE_BEHAVIOR_IN = 2; // 0x2
|
||||
field public static final int CHANGE_BEHAVIOR_KEEP = 0; // 0x0
|
||||
field public static final int CHANGE_BEHAVIOR_OUT = 1; // 0x1
|
||||
field public static final int CHANGE_BEHAVIOR_OUT_IN = 3; // 0x3
|
||||
}
|
||||
|
||||
public abstract class Transition implements java.lang.Cloneable {
|
||||
ctor public Transition();
|
||||
method public void addListener(android.view.transition.Transition.TransitionListener);
|
||||
method protected void cancel();
|
||||
method protected abstract void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method public android.view.transition.Transition clone();
|
||||
method public long getDuration();
|
||||
method public android.animation.TimeInterpolator getInterpolator();
|
||||
method public java.util.ArrayList<android.view.transition.Transition.TransitionListener> getListeners();
|
||||
method public java.lang.String getName();
|
||||
method public long getStartDelay();
|
||||
method public int[] getTargetIds();
|
||||
method public android.view.View[] getTargets();
|
||||
method public java.lang.String[] getTransitionProperties();
|
||||
method protected android.view.transition.TransitionValues getTransitionValues(android.view.View, boolean);
|
||||
method protected android.animation.Animator play(android.view.ViewGroup, android.view.transition.TransitionValues, android.view.transition.TransitionValues);
|
||||
method public void removeListener(android.view.transition.Transition.TransitionListener);
|
||||
method public android.view.transition.Transition setDuration(long);
|
||||
method public void setInterpolator(android.animation.TimeInterpolator);
|
||||
method public void setStartDelay(long);
|
||||
method public android.view.transition.Transition setTargetIds(int...);
|
||||
method public android.view.transition.Transition setTargets(android.view.View...);
|
||||
}
|
||||
|
||||
public static abstract interface Transition.TransitionListener {
|
||||
method public abstract void onTransitionCancel(android.view.transition.Transition);
|
||||
method public abstract void onTransitionEnd(android.view.transition.Transition);
|
||||
method public abstract void onTransitionPause(android.view.transition.Transition);
|
||||
method public abstract void onTransitionResume(android.view.transition.Transition);
|
||||
method public abstract void onTransitionStart(android.view.transition.Transition);
|
||||
}
|
||||
|
||||
public class TransitionGroup extends android.view.transition.Transition {
|
||||
ctor public TransitionGroup();
|
||||
ctor public TransitionGroup(int);
|
||||
method public void addTransitions(android.view.transition.Transition...);
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method public void removeTransition(android.view.transition.Transition);
|
||||
method public void setOrdering(int);
|
||||
field public static final int SEQUENTIALLY = 1; // 0x1
|
||||
field public static final int TOGETHER = 0; // 0x0
|
||||
}
|
||||
|
||||
public class TransitionInflater {
|
||||
method public static android.view.transition.TransitionInflater from(android.content.Context);
|
||||
method public android.view.transition.Scene inflateScene(int, android.view.ViewGroup);
|
||||
method public android.view.transition.Transition inflateTransition(int);
|
||||
method public android.view.transition.TransitionManager inflateTransitionManager(int, android.view.ViewGroup);
|
||||
}
|
||||
|
||||
public class TransitionManager {
|
||||
ctor public TransitionManager();
|
||||
method public static void beginDelayedTransition(android.view.ViewGroup, android.view.transition.Transition);
|
||||
method public android.view.transition.Transition getDefaultTransition();
|
||||
method public static void go(android.view.transition.Scene);
|
||||
method public static void go(android.view.transition.Scene, android.view.transition.Transition);
|
||||
method public static void go(android.view.ViewGroup, java.lang.Runnable);
|
||||
method public static void go(android.view.ViewGroup, java.lang.Runnable, android.view.transition.Transition);
|
||||
method public void setDefaultTransition(android.view.transition.Transition);
|
||||
method public void setTransition(android.view.transition.Scene, android.view.transition.Transition);
|
||||
method public void setTransition(android.view.transition.Scene, android.view.transition.Scene, android.view.transition.Transition);
|
||||
method public void transitionTo(android.view.transition.Scene);
|
||||
}
|
||||
|
||||
public class TransitionValues {
|
||||
ctor public TransitionValues();
|
||||
field public final java.util.Map values;
|
||||
field public android.view.View view;
|
||||
}
|
||||
|
||||
public abstract class Visibility extends android.view.transition.Transition {
|
||||
ctor public Visibility();
|
||||
method protected android.animation.Animator appear(android.view.ViewGroup, android.view.transition.TransitionValues, int, android.view.transition.TransitionValues, int);
|
||||
method protected void captureValues(android.view.transition.TransitionValues, boolean);
|
||||
method protected android.animation.Animator disappear(android.view.ViewGroup, android.view.transition.TransitionValues, int, android.view.transition.TransitionValues, int);
|
||||
method public boolean isVisible(android.view.transition.TransitionValues);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.webkit {
|
||||
|
||||
public class ConsoleMessage {
|
||||
|
||||
@@ -280,19 +280,9 @@ public abstract class Animator implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of {@link AnimatorPauseListener} objects that are currently
|
||||
* listening for pause/resume events on this animator.
|
||||
*
|
||||
* @return ArrayList<AnimatorListener> The set of pause listeners.
|
||||
*/
|
||||
public ArrayList<AnimatorPauseListener> getPauseListeners() {
|
||||
return mPauseListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all listeners from this object. This is equivalent to calling
|
||||
* {@link #getListeners()} and {@link #getPauseListeners()} followed by calling
|
||||
* {@link ArrayList#clear()} on the returned lists of listeners.
|
||||
* Removes all {@link #addListener(android.animation.Animator.AnimatorListener) listeners}
|
||||
* and {@link #addPauseListener(android.animation.Animator.AnimatorPauseListener)
|
||||
* pauseListeners} from this object.
|
||||
*/
|
||||
public void removeAllListeners() {
|
||||
if (mListeners != null) {
|
||||
|
||||
@@ -636,7 +636,7 @@ public class PropertyValuesHolder implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* The TypeEvaluator will the automatically determined based on the type of values
|
||||
* The TypeEvaluator will be automatically determined based on the type of values
|
||||
* supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so
|
||||
* desired. This may be important in cases where either the type of the values supplied
|
||||
* do not match the way that they should be interpolated between, or if the values
|
||||
|
||||
@@ -14,22 +14,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
/**
|
||||
* Utility class for creating a default transition that automatically fades,
|
||||
* moves, and resizes views during a scene change.
|
||||
*
|
||||
* <p>An AutoTransition can be described in a resource file by using the
|
||||
* tag <code>autoTransition</code>, along with the other standard
|
||||
* attributes of {@link android.R.styleable#Transition}.</p>
|
||||
*/
|
||||
public class AutoTransition extends TransitionGroup {
|
||||
public class AutoTransition extends TransitionSet {
|
||||
|
||||
/**
|
||||
* Constructs an AutoTransition object, which is a TransitionGroup which
|
||||
* Constructs an AutoTransition object, which is a TransitionSet which
|
||||
* first fades out disappearing targets, then moves and resizes existing
|
||||
* targets, and finally fades in appearing targets.
|
||||
*
|
||||
*/
|
||||
public AutoTransition() {
|
||||
setOrdering(SEQUENTIALLY);
|
||||
addTransitions(new Fade(Fade.OUT), new Move(), new Fade(Fade.IN));
|
||||
setOrdering(ORDERING_SEQUENTIAL);
|
||||
addTransition(new Fade(Fade.OUT)).
|
||||
addTransition(new ChangeBounds()).
|
||||
addTransition(new Fade(Fade.IN));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -33,13 +33,17 @@ import java.util.Map;
|
||||
/**
|
||||
* This transition captures the layout bounds of target views before and after
|
||||
* the scene change and animates those changes during the transition.
|
||||
*
|
||||
* <p>A ChangeBounds transition can be described in a resource file by using the
|
||||
* tag <code>changeBounds</code>, along with the other standard
|
||||
* attributes of {@link android.R.styleable#Transition}.</p>
|
||||
*/
|
||||
public class Move extends Transition {
|
||||
public class ChangeBounds extends Transition {
|
||||
|
||||
private static final String PROPNAME_BOUNDS = "android:move:bounds";
|
||||
private static final String PROPNAME_PARENT = "android:move:parent";
|
||||
private static final String PROPNAME_WINDOW_X = "android:move:windowX";
|
||||
private static final String PROPNAME_WINDOW_Y = "android:move:windowY";
|
||||
private static final String PROPNAME_BOUNDS = "android:changeBounds:bounds";
|
||||
private static final String PROPNAME_PARENT = "android:changeBounds:parent";
|
||||
private static final String PROPNAME_WINDOW_X = "android:changeBounds:windowX";
|
||||
private static final String PROPNAME_WINDOW_Y = "android:changeBounds:windowY";
|
||||
private static final String[] sTransitionProperties = {
|
||||
PROPNAME_BOUNDS,
|
||||
PROPNAME_PARENT,
|
||||
@@ -50,7 +54,7 @@ public class Move extends Transition {
|
||||
int[] tempLocation = new int[2];
|
||||
boolean mResizeClip = false;
|
||||
boolean mReparent = false;
|
||||
private static final String LOG_TAG = "Move";
|
||||
private static final String LOG_TAG = "ChangeBounds";
|
||||
|
||||
private static RectEvaluator sRectEvaluator = new RectEvaluator();
|
||||
|
||||
@@ -64,7 +68,7 @@ public class Move extends Transition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting this flag tells Move to track the before/after parent
|
||||
* Setting this flag tells ChangeBounds to track the before/after parent
|
||||
* of every view using this transition. The flag is not enabled by
|
||||
* default because it requires the parent instances to be the same
|
||||
* in the two scenes or else all parents must use ids to allow
|
||||
@@ -77,8 +81,7 @@ public class Move extends Transition {
|
||||
mReparent = reparent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
private void captureValues(TransitionValues values) {
|
||||
View view = values.view;
|
||||
values.values.put(PROPNAME_BOUNDS, new Rect(view.getLeft(), view.getTop(),
|
||||
view.getRight(), view.getBottom()));
|
||||
@@ -89,7 +92,17 @@ public class Move extends Transition {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(final ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
if (startValues == null || endValues == null) {
|
||||
return null;
|
||||
@@ -105,7 +118,7 @@ public class Move extends Transition {
|
||||
boolean parentsEqual = (startParent == endParent) ||
|
||||
(startParent.getId() == endParent.getId());
|
||||
// TODO: Might want reparenting to be separate/subclass transition, or at least
|
||||
// triggered by a property on Move. Otherwise, we're forcing the requirement that
|
||||
// triggered by a property on ChangeBounds. Otherwise, we're forcing the requirement that
|
||||
// all parents in layouts have IDs to avoid layout-inflation resulting in a side-effect
|
||||
// of reparenting the views.
|
||||
if (!mReparent || parentsEqual) {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -24,10 +24,8 @@ import android.animation.RectEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
@@ -43,6 +41,8 @@ import java.util.Map;
|
||||
*
|
||||
* <p>Note: This transition is not compatible with {@link TextureView}
|
||||
* or {@link SurfaceView}.</p>
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class Crossfade extends Transition {
|
||||
// TODO: Add a hook that lets a Transition call user code to query whether it should run on
|
||||
@@ -121,12 +121,19 @@ public class Crossfade extends Transition {
|
||||
* @param fadeBehavior The type of fading animation to use when this
|
||||
* transition is run.
|
||||
*/
|
||||
public void setFadeBehavior(int fadeBehavior) {
|
||||
public Crossfade setFadeBehavior(int fadeBehavior) {
|
||||
if (fadeBehavior >= FADE_BEHAVIOR_CROSSFADE && fadeBehavior <= FADE_BEHAVIOR_OUT_IN) {
|
||||
mFadeBehavior = fadeBehavior;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fading behavior of the animation.
|
||||
*
|
||||
* @return This crossfade object.
|
||||
* @see #setFadeBehavior(int)
|
||||
*/
|
||||
public int getFadeBehavior() {
|
||||
return mFadeBehavior;
|
||||
}
|
||||
@@ -139,18 +146,25 @@ public class Crossfade extends Transition {
|
||||
* @param resizeBehavior The type of resizing behavior to use when this
|
||||
* transition is run.
|
||||
*/
|
||||
public void setResizeBehavior(int resizeBehavior) {
|
||||
public Crossfade setResizeBehavior(int resizeBehavior) {
|
||||
if (resizeBehavior >= RESIZE_BEHAVIOR_NONE && resizeBehavior <= RESIZE_BEHAVIOR_SCALE) {
|
||||
mResizeBehavior = resizeBehavior;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resizing behavior of the animation.
|
||||
*
|
||||
* @return This crossfade object.
|
||||
* @see #setResizeBehavior(int)
|
||||
*/
|
||||
public int getResizeBehavior() {
|
||||
return mResizeBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
if (startValues == null || endValues == null) {
|
||||
return null;
|
||||
@@ -243,18 +257,16 @@ public class Crossfade extends Transition {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
View view = values.view;
|
||||
private void captureValues(TransitionValues transitionValues) {
|
||||
View view = transitionValues.view;
|
||||
Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
|
||||
if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
|
||||
bounds.offset(view.getLeft(), view.getTop());
|
||||
}
|
||||
values.values.put(PROPNAME_BOUNDS, bounds);
|
||||
transitionValues.values.put(PROPNAME_BOUNDS, bounds);
|
||||
|
||||
if (Transition.DBG) {
|
||||
Log.d(LOG_TAG, "Captured bounds " + values.values.get(PROPNAME_BOUNDS) + ": start = " +
|
||||
start);
|
||||
Log.d(LOG_TAG, "Captured bounds " + transitionValues.values.get(PROPNAME_BOUNDS));
|
||||
}
|
||||
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
@@ -264,12 +276,21 @@ public class Crossfade extends Transition {
|
||||
Canvas c = new Canvas(bitmap);
|
||||
view.draw(c);
|
||||
}
|
||||
values.values.put(PROPNAME_BITMAP, bitmap);
|
||||
transitionValues.values.put(PROPNAME_BITMAP, bitmap);
|
||||
// TODO: I don't have resources, can't call the non-deprecated method?
|
||||
BitmapDrawable drawable = new BitmapDrawable(bitmap);
|
||||
// TODO: lrtb will be wrong if the view has transXY set
|
||||
drawable.setBounds(bounds);
|
||||
values.values.put(PROPNAME_DRAWABLE, drawable);
|
||||
transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -30,6 +29,12 @@ import android.view.ViewGroup;
|
||||
* or non-visible. Visibility is determined by both the
|
||||
* {@link View#setVisibility(int)} state of the view as well as whether it
|
||||
* is parented in the current view hierarchy.
|
||||
*
|
||||
* <p>A Fade transition can be described in a resource file by using the
|
||||
* tag <code>fade</code>, along with the standard
|
||||
* attributes of {@link android.R.styleable#Fade} and
|
||||
* {@link android.R.styleable#Transition}.</p>
|
||||
|
||||
*/
|
||||
public class Fade extends Visibility {
|
||||
|
||||
@@ -93,21 +98,31 @@ public class Fade extends Visibility {
|
||||
return anim;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
super.captureValues(values, start);
|
||||
float alpha = values.view.getAlpha();
|
||||
values.values.put(PROPNAME_ALPHA, alpha);
|
||||
private void captureValues(TransitionValues transitionValues) {
|
||||
float alpha = transitionValues.view.getAlpha();
|
||||
transitionValues.values.put(PROPNAME_ALPHA, alpha);
|
||||
int[] loc = new int[2];
|
||||
values.view.getLocationOnScreen(loc);
|
||||
values.values.put(PROPNAME_SCREEN_X, loc[0]);
|
||||
values.values.put(PROPNAME_SCREEN_Y, loc[1]);
|
||||
transitionValues.view.getLocationOnScreen(loc);
|
||||
transitionValues.values.put(PROPNAME_SCREEN_X, loc[0]);
|
||||
transitionValues.values.put(PROPNAME_SCREEN_Y, loc[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
super.captureStartValues(transitionValues);
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
super.captureEndValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
Animator animator = super.play(sceneRoot, startValues, endValues);
|
||||
Animator animator = super.createAnimator(sceneRoot, startValues, endValues);
|
||||
if (animator == null && startValues != null && endValues != null) {
|
||||
boolean endVisible = isVisible(endValues);
|
||||
final View endView = endValues.view;
|
||||
@@ -122,13 +137,18 @@ public class Fade extends Visibility {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator appear(ViewGroup sceneRoot,
|
||||
public Animator onAppear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
if ((mFadingMode & IN) != IN || endValues == null) {
|
||||
return null;
|
||||
}
|
||||
final View endView = endValues.view;
|
||||
if (DBG) {
|
||||
View startView = (startValues != null) ? startValues.view : null;
|
||||
Log.d(LOG_TAG, "Fade.onDisappear: startView, startVis, endView, endVis = " +
|
||||
startView + ", " + startVisibility + ", " + endView + ", " + endVisibility);
|
||||
}
|
||||
// if alpha < 1, just fade it in from the current value
|
||||
if (endView.getAlpha() == 1.0f) {
|
||||
endView.setAlpha(0);
|
||||
@@ -137,7 +157,7 @@ public class Fade extends Visibility {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator disappear(ViewGroup sceneRoot,
|
||||
public Animator onDisappear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
if ((mFadingMode & OUT) != OUT) {
|
||||
@@ -147,7 +167,7 @@ public class Fade extends Visibility {
|
||||
View startView = (startValues != null) ? startValues.view : null;
|
||||
View endView = (endValues != null) ? endValues.view : null;
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "Fade.predisappear: startView, startVis, endView, endVis = " +
|
||||
Log.d(LOG_TAG, "Fade.onDisappear: startView, startVis, endView, endVis = " +
|
||||
startView + ", " + startVisibility + ", " + endView + ", " + endVisibility);
|
||||
}
|
||||
View overlayView = null;
|
||||
@@ -14,20 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This transition tracks changes during scene changes to the
|
||||
* {@link View#setBackground(android.graphics.drawable.Drawable) background}
|
||||
@@ -36,22 +33,34 @@ import java.util.Map;
|
||||
* {@link TextView#setTextColor(android.content.res.ColorStateList)
|
||||
* color} of the text for target TextViews. If the color changes between
|
||||
* scenes, the color change is animated.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class Recolor extends Transition {
|
||||
|
||||
private static final String PROPNAME_BACKGROUND = "android:recolor:background";
|
||||
private static final String PROPNAME_TEXT_COLOR = "android:recolor:textColor";
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
values.values.put(PROPNAME_BACKGROUND, values.view.getBackground());
|
||||
if (values.view instanceof TextView) {
|
||||
values.values.put(PROPNAME_TEXT_COLOR, ((TextView)values.view).getCurrentTextColor());
|
||||
private void captureValues(TransitionValues transitionValues) {
|
||||
transitionValues.values.put(PROPNAME_BACKGROUND, transitionValues.view.getBackground());
|
||||
if (transitionValues.view instanceof TextView) {
|
||||
transitionValues.values.put(PROPNAME_TEXT_COLOR,
|
||||
((TextView)transitionValues.view).getCurrentTextColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
if (startValues == null || endValues == null) {
|
||||
return null;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
@@ -24,18 +24,25 @@ import android.view.ViewGroup;
|
||||
/**
|
||||
* This transition captures the rotation property of targets before and after
|
||||
* the scene change and animates any changes.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class Rotate extends Transition {
|
||||
|
||||
private static final String PROPNAME_ROTATION = "android:rotate:rotation";
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
values.values.put(PROPNAME_ROTATION, values.view.getRotation());
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
transitionValues.values.put(PROPNAME_ROTATION, transitionValues.view.getRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
transitionValues.values.put(PROPNAME_ROTATION, transitionValues.view.getRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
if (startValues == null || endValues == null) {
|
||||
return null;
|
||||
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
@@ -34,6 +36,37 @@ public final class Scene {
|
||||
private ViewGroup mSceneRoot;
|
||||
private ViewGroup mLayout; // alternative to layoutId
|
||||
Runnable mEnterAction, mExitAction;
|
||||
private static ThreadLocal<SparseArray<Scene>> sScenes = new ThreadLocal<SparseArray<Scene>>();
|
||||
|
||||
/**
|
||||
* Returns a Scene described by the resource file associated with the given
|
||||
* <code>layoutId</code> parameter. If such a Scene has already been created,
|
||||
* that same Scene will be returned. This caching of layoutId-based scenes enables
|
||||
* sharing of common scenes between those created in code and those referenced
|
||||
* by {@link TransitionManager} XML resource files.
|
||||
*
|
||||
* @param sceneRoot The root of the hierarchy in which scene changes
|
||||
* and transitions will take place.
|
||||
* @param layoutId The id of a standard layout resource file.
|
||||
* @param context The context used in the process of inflating
|
||||
* the layout resource.
|
||||
* @return
|
||||
*/
|
||||
public static Scene getSceneForLayout(ViewGroup sceneRoot, int layoutId, Context context) {
|
||||
SparseArray<Scene> scenes = sScenes.get();
|
||||
if (scenes == null) {
|
||||
scenes = new SparseArray<Scene>();
|
||||
sScenes.set(scenes);
|
||||
}
|
||||
Scene scene = scenes.get(layoutId);
|
||||
if (scene != null) {
|
||||
return scene;
|
||||
} else {
|
||||
scene = new Scene(sceneRoot, layoutId, context);
|
||||
scenes.put(layoutId, scene);
|
||||
return scene;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Scene with no information about how values will change
|
||||
@@ -54,6 +87,9 @@ public final class Scene {
|
||||
* children from the sceneRoot container and will inflate and add
|
||||
* the hierarchy specified by the layoutId resource file.
|
||||
*
|
||||
* <p>This method is hidden because layoutId-based scenes should be
|
||||
* created by the caching factory method {@link Scene#getCurrentScene(View)}.</p>
|
||||
*
|
||||
* @param sceneRoot The root of the hierarchy in which scene changes
|
||||
* and transitions will take place.
|
||||
* @param layoutId The id of a resource file that defines the view
|
||||
@@ -61,7 +97,7 @@ public final class Scene {
|
||||
* @param context The context used in the process of inflating
|
||||
* the layout resource.
|
||||
*/
|
||||
public Scene(ViewGroup sceneRoot, int layoutId, Context context) {
|
||||
private Scene(ViewGroup sceneRoot, int layoutId, Context context) {
|
||||
mContext = context;
|
||||
mSceneRoot = sceneRoot;
|
||||
mLayoutId = layoutId;
|
||||
@@ -74,7 +110,7 @@ public final class Scene {
|
||||
*
|
||||
* @param sceneRoot The root of the hierarchy in which scene changes
|
||||
* and transitions will take place.
|
||||
* @param layout The view hiearrchy of this scene, added as a child
|
||||
* @param layout The view hierarchy of this scene, added as a child
|
||||
* of sceneRoot when this scene is entered.
|
||||
*/
|
||||
public Scene(ViewGroup sceneRoot, ViewGroup layout) {
|
||||
@@ -94,19 +130,14 @@ public final class Scene {
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits this scene, if it is the {@link ViewGroup#getCurrentScene()
|
||||
* currentScene} on the scene's {@link #getSceneRoot() scene root}.
|
||||
* Exiting a scene involves removing the layout added if the scene
|
||||
* has either a layoutId or layout view group (set at construction
|
||||
* time) and running the {@link #setExitAction(Runnable) exit action}
|
||||
* Exits this scene, if it is the current scene
|
||||
* on the scene's {@link #getSceneRoot() scene root}. The current scene is
|
||||
* set when {@link #enter() entering} a scene.
|
||||
* Exiting a scene runs the {@link #setExitAction(Runnable) exit action}
|
||||
* if there is one.
|
||||
*/
|
||||
public void exit() {
|
||||
if (mSceneRoot.getCurrentScene() == this) {
|
||||
if (mLayoutId >= 0 || mLayout != null) {
|
||||
// Undo layout change caused by entering this scene
|
||||
getSceneRoot().removeAllViews();
|
||||
}
|
||||
if (getCurrentScene(mSceneRoot) == this) {
|
||||
if (mExitAction != null) {
|
||||
mExitAction.run();
|
||||
}
|
||||
@@ -127,8 +158,7 @@ public final class Scene {
|
||||
|
||||
// Apply layout change, if any
|
||||
if (mLayoutId >= 0 || mLayout != null) {
|
||||
// redundant with exit() action of previous scene, but must
|
||||
// empty out that parent container before adding to it
|
||||
// empty out parent container before adding to it
|
||||
getSceneRoot().removeAllViews();
|
||||
|
||||
if (mLayoutId >= 0) {
|
||||
@@ -143,7 +173,30 @@ public final class Scene {
|
||||
mEnterAction.run();
|
||||
}
|
||||
|
||||
mSceneRoot.setCurrentScene(this );
|
||||
setCurrentScene(mSceneRoot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scene that the given view is in. The current scene is set only
|
||||
* on the root view of a scene, not for every view in that hierarchy. This
|
||||
* information is used by Scene to determine whether there is a previous
|
||||
* scene which should be exited before the new scene is entered.
|
||||
*
|
||||
* @param view The view on which the current scene is being set
|
||||
*/
|
||||
static void setCurrentScene(View view, Scene scene) {
|
||||
view.setTagInternal(com.android.internal.R.id.current_scene, scene);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current {@link Scene} set on the given view. A scene is set on a view
|
||||
* only if that view is the scene root.
|
||||
*
|
||||
* @return The current Scene set on this view. A value of null indicates that
|
||||
* no Scene is currently set.
|
||||
*/
|
||||
static Scene getCurrentScene(View view) {
|
||||
return (Scene) view.getTag(com.android.internal.R.id.current_scene);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
@@ -28,6 +28,8 @@ import android.view.animation.DecelerateInterpolator;
|
||||
* This transition captures the visibility of target objects before and
|
||||
* after a scene change and animates any changes by sliding the target
|
||||
* objects into or out of place.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class Slide extends Visibility {
|
||||
|
||||
@@ -37,7 +39,7 @@ public class Slide extends Visibility {
|
||||
private static final TimeInterpolator sDecelerator = new DecelerateInterpolator();
|
||||
|
||||
@Override
|
||||
protected Animator appear(ViewGroup sceneRoot,
|
||||
public Animator onAppear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
View endView = (endValues != null) ? endValues.view : null;
|
||||
@@ -49,7 +51,7 @@ public class Slide extends Visibility {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator disappear(ViewGroup sceneRoot,
|
||||
public Animator onDisappear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
View startView = (startValues != null) ? startValues.view : null;
|
||||
@@ -14,14 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.Color;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -33,6 +32,8 @@ import java.util.Map;
|
||||
* starting text stays until the transition ends, at which point it changes
|
||||
* to the end text. This is useful in situations where you want to resize a
|
||||
* text view to its new size before displaying the text that goes there.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class TextChange extends Transition {
|
||||
private static final String PROPNAME_TEXT = "android:textchange:text";
|
||||
@@ -84,15 +85,18 @@ public class TextChange extends Transition {
|
||||
|
||||
/**
|
||||
* Sets the type of changing animation that will be run, one of
|
||||
* {@link #CHANGE_BEHAVIOR_KEEP} and {@link #CHANGE_BEHAVIOR_OUT_IN}.
|
||||
* {@link #CHANGE_BEHAVIOR_KEEP}, {@link #CHANGE_BEHAVIOR_OUT},
|
||||
* {@link #CHANGE_BEHAVIOR_IN}, and {@link #CHANGE_BEHAVIOR_OUT_IN}.
|
||||
*
|
||||
* @param changeBehavior The type of fading animation to use when this
|
||||
* transition is run.
|
||||
* @return this textChange object.
|
||||
*/
|
||||
public void setChangeBehavior(int changeBehavior) {
|
||||
public TextChange setChangeBehavior(int changeBehavior) {
|
||||
if (changeBehavior >= CHANGE_BEHAVIOR_KEEP && changeBehavior <= CHANGE_BEHAVIOR_OUT_IN) {
|
||||
mChangeBehavior = changeBehavior;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,19 +104,38 @@ public class TextChange extends Transition {
|
||||
return sTransitionProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
if (values.view instanceof TextView) {
|
||||
TextView textview = (TextView) values.view;
|
||||
values.values.put(PROPNAME_TEXT, textview.getText());
|
||||
/**
|
||||
* Returns the type of changing animation that will be run.
|
||||
*
|
||||
* @return either {@link #CHANGE_BEHAVIOR_KEEP}, {@link #CHANGE_BEHAVIOR_OUT},
|
||||
* {@link #CHANGE_BEHAVIOR_IN}, or {@link #CHANGE_BEHAVIOR_OUT_IN}.
|
||||
*/
|
||||
public int getChangeBehavior() {
|
||||
return mChangeBehavior;
|
||||
}
|
||||
|
||||
private void captureValues(TransitionValues transitionValues) {
|
||||
if (transitionValues.view instanceof TextView) {
|
||||
TextView textview = (TextView) transitionValues.view;
|
||||
transitionValues.values.put(PROPNAME_TEXT, textview.getText());
|
||||
if (mChangeBehavior > CHANGE_BEHAVIOR_KEEP) {
|
||||
values.values.put(PROPNAME_TEXT_COLOR, textview.getCurrentTextColor());
|
||||
transitionValues.values.put(PROPNAME_TEXT_COLOR, textview.getCurrentTextColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
if (startValues == null || endValues == null || !(endValues.view instanceof TextView)) {
|
||||
return null;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -31,11 +31,12 @@ import android.view.ViewOverlay;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A Transition holds information about animations that will be run on its
|
||||
* targets during a scene change. Subclasses of this abstract class may
|
||||
* choreograph several child transitions ({@link TransitionGroup} or they may
|
||||
* choreograph several child transitions ({@link TransitionSet} or they may
|
||||
* perform custom animations themselves. Any Transition has two main jobs:
|
||||
* (1) capture property values, and (2) play animations based on changes to
|
||||
* captured property values. A custom transition knows what property values
|
||||
@@ -50,9 +51,42 @@ import java.util.ArrayList;
|
||||
* a non-UI thread, so changes to the view due to transitions (such as moving
|
||||
* and resizing the view) may be out of sync with the display inside those bounds.
|
||||
* TextureView is more compatible with transitions in general, but some
|
||||
* specific transitions (such as {@link Crossfade}) may not be compatible
|
||||
* specific transitions (such as {@link Fade}) may not be compatible
|
||||
* with TextureView because they rely on {@link ViewOverlay} functionality,
|
||||
* which does not currently work with TextureView.</p>
|
||||
*
|
||||
* <p>Transitions can be declared in XML resource files inside the <code>res/transition</code>
|
||||
* directory. Transition resources consist of a tag name for one of the Transition
|
||||
* subclasses along with attributes to define some of the attributes of that transition.
|
||||
* For example, here is a minimal resource file that declares a {@link ChangeBounds} transition:</p>
|
||||
*
|
||||
* {@sample development/samples/ApiDemos/res/transition/changebounds.xml ChangeBounds}
|
||||
*
|
||||
* <p>Note that attributes for the transition are not required, just as they are
|
||||
* optional when declared in code; Transitions created from XML resources will use
|
||||
* the same defaults as their code-created equivalents. Here is a slightly more
|
||||
* elaborate example which declares a {@link TransitionSet} transition with
|
||||
* {@link ChangeBounds} and {@link Fade} child transitions:</p>
|
||||
*
|
||||
* {@sample
|
||||
* development/samples/ApiDemos/res/transition/changebounds_fadeout_sequential.xml TransitionSet}
|
||||
*
|
||||
* <p>In this example, the transitionOrdering attribute is used on the TransitionSet
|
||||
* object to change from the default {@link TransitionSet#ORDERING_TOGETHER} behavior
|
||||
* to be {@link TransitionSet#ORDERING_SEQUENTIAL} instead. Also, the {@link Fade}
|
||||
* transition uses a fadingMode of {@link Fade#OUT} instead of the default
|
||||
* out-in behavior. Finally, note the use of the <code>targets</code> sub-tag, which
|
||||
* takes a set of {@link android.R.styleable#TransitionTarget target} tags, each
|
||||
* of which lists a specific <code>targetId</code> which this transition acts upon.
|
||||
* Use of targets is optional, but can be used to either limit the time spent checking
|
||||
* attributes on unchanging views, or limiting the types of animations run on specific views.
|
||||
* In this case, we know that only the <code>grayscaleContainer</code> will be
|
||||
* disappearing, so we choose to limit the {@link Fade} transition to only that view.</p>
|
||||
*
|
||||
* Further information on XML resource descriptions for transitions can be found for
|
||||
* {@link android.R.styleable#Transition}, {@link android.R.styleable#TransitionSet},
|
||||
* {@link android.R.styleable#TransitionTarget}, and {@link android.R.styleable#Fade}.
|
||||
*
|
||||
*/
|
||||
public abstract class Transition implements Cloneable {
|
||||
|
||||
@@ -64,17 +98,17 @@ public abstract class Transition implements Cloneable {
|
||||
long mStartDelay = -1;
|
||||
long mDuration = -1;
|
||||
TimeInterpolator mInterpolator = null;
|
||||
int[] mTargetIds;
|
||||
View[] mTargets;
|
||||
ArrayList<Integer> mTargetIds = new ArrayList<Integer>();
|
||||
ArrayList<View> mTargets = new ArrayList<View>();
|
||||
private TransitionValuesMaps mStartValues = new TransitionValuesMaps();
|
||||
private TransitionValuesMaps mEndValues = new TransitionValuesMaps();
|
||||
TransitionGroup mParent = null;
|
||||
TransitionSet mParent = null;
|
||||
|
||||
// Per-animator information used for later canceling when future transitions overlap
|
||||
private static ThreadLocal<ArrayMap<Animator, AnimationInfo>> sRunningAnimators =
|
||||
new ThreadLocal<ArrayMap<Animator, AnimationInfo>>();
|
||||
|
||||
// Scene Root is set at play() time in the cloned Transition
|
||||
// Scene Root is set at createAnimator() time in the cloned Transition
|
||||
ViewGroup mSceneRoot = null;
|
||||
|
||||
// Track all animators in use in case the transition gets canceled and needs to
|
||||
@@ -91,14 +125,15 @@ public abstract class Transition implements Cloneable {
|
||||
// The set of listeners to be sent transition lifecycle events.
|
||||
ArrayList<TransitionListener> mListeners = null;
|
||||
|
||||
// The set of animators collected from calls to play(), to be run in runAnimations()
|
||||
// The set of animators collected from calls to createAnimator(),
|
||||
// to be run in runAnimators()
|
||||
ArrayList<Animator> mAnimators = new ArrayList<Animator>();
|
||||
|
||||
/**
|
||||
* Constructs a Transition object with no target objects. A transition with
|
||||
* no targets defaults to running on all target objects in the scene hierarchy
|
||||
* (if the transition is not contained in a TransitionGroup), or all target
|
||||
* objects passed down from its parent (if it is in a TransitionGroup).
|
||||
* (if the transition is not contained in a TransitionSet), or all target
|
||||
* objects passed down from its parent (if it is in a TransitionSet).
|
||||
*/
|
||||
public Transition() {}
|
||||
|
||||
@@ -110,6 +145,7 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @param duration The length of the animation, in milliseconds.
|
||||
* @return This transition object.
|
||||
* @attr ref android.R.styleable#Transition_duration
|
||||
*/
|
||||
public Transition setDuration(long duration) {
|
||||
mDuration = duration;
|
||||
@@ -121,8 +157,8 @@ public abstract class Transition implements Cloneable {
|
||||
* the returned value will be negative, indicating that resulting animators will
|
||||
* retain their own durations.
|
||||
*
|
||||
* @return The duration set on this transition, if one has been set, otherwise
|
||||
* returns a negative number.
|
||||
* @return The duration set on this transition, in milliseconds, if one has been
|
||||
* set, otherwise returns a negative number.
|
||||
*/
|
||||
public long getDuration() {
|
||||
return mDuration;
|
||||
@@ -135,9 +171,12 @@ public abstract class Transition implements Cloneable {
|
||||
* Transition is set, that delay will override the Animator delay.
|
||||
*
|
||||
* @param startDelay The length of the delay, in milliseconds.
|
||||
* @return This transition object.
|
||||
* @attr ref android.R.styleable#Transition_startDelay
|
||||
*/
|
||||
public void setStartDelay(long startDelay) {
|
||||
public Transition setStartDelay(long startDelay) {
|
||||
mStartDelay = startDelay;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,8 +184,8 @@ public abstract class Transition implements Cloneable {
|
||||
* the returned value will be negative, indicating that resulting animators will
|
||||
* retain their own startDelays.
|
||||
*
|
||||
* @return The startDealy set on this transition, if one has been set, otherwise
|
||||
* returns a negative number.
|
||||
* @return The startDelay set on this transition, in milliseconds, if one has
|
||||
* been set, otherwise returns a negative number.
|
||||
*/
|
||||
public long getStartDelay() {
|
||||
return mStartDelay;
|
||||
@@ -159,9 +198,12 @@ public abstract class Transition implements Cloneable {
|
||||
* Transition is set, that interpolator will override the Animator interpolator.
|
||||
*
|
||||
* @param interpolator The time interpolator used by the transition
|
||||
* @return This transition object.
|
||||
* @attr ref android.R.styleable#Transition_interpolator
|
||||
*/
|
||||
public void setInterpolator(TimeInterpolator interpolator) {
|
||||
public Transition setInterpolator(TimeInterpolator interpolator) {
|
||||
mInterpolator = interpolator;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +220,7 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* Returns the set of property names used stored in the {@link TransitionValues}
|
||||
* object passed into {@link #captureValues(TransitionValues, boolean)} that
|
||||
* object passed into {@link #captureStartValues(TransitionValues)} that
|
||||
* this transition cares about for the purposes of canceling overlapping animations.
|
||||
* When any transition is started on a given scene root, all transitions
|
||||
* currently running on that same scene root are checked to see whether the
|
||||
@@ -202,11 +244,17 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by the transition's parent (all the way up to the
|
||||
* This method creates an animation that will be run for this transition
|
||||
* given the information in the startValues and endValues structures captured
|
||||
* earlier for the start and end scenes. Subclasses of Transition should override
|
||||
* this method. The method should only be called by the transition system; it is
|
||||
* not intended to be called from external classes.
|
||||
*
|
||||
* <p>This method is called by the transition's parent (all the way up to the
|
||||
* topmost Transition in the hierarchy) with the sceneRoot and start/end
|
||||
* values that the transition may need to set up initial target values
|
||||
* and construct an appropriate animation. For example, if an overall
|
||||
* Transition is a {@link TransitionGroup} consisting of several
|
||||
* Transition is a {@link TransitionSet} consisting of several
|
||||
* child transitions in sequence, then some of the child transitions may
|
||||
* want to set initial values on target views prior to the overall
|
||||
* Transition commencing, to put them in an appropriate state for the
|
||||
@@ -216,14 +264,13 @@ public abstract class Transition implements Cloneable {
|
||||
* actually starting the animation. This is necessary because the scene
|
||||
* change that triggers the Transition will automatically set the end-scene
|
||||
* on all target views, so a Transition that wants to animate from a
|
||||
* different value should set that value prior to returning from this method.
|
||||
* different value should set that value prior to returning from this method.</p>
|
||||
*
|
||||
* <p>Additionally, a Transition can perform logic to determine whether
|
||||
* the transition needs to run on the given target and start/end values.
|
||||
* For example, a transition that resizes objects on the screen may wish
|
||||
* to avoid running for views which are not present in either the start
|
||||
* or end scenes. A return value of <code>null</code> indicates that
|
||||
* no animation should run. The default implementation returns null.</p>
|
||||
* or end scenes.</p>
|
||||
*
|
||||
* <p>If there is an animator created and returned from this method, the
|
||||
* transition mechanism will apply any applicable duration, startDelay,
|
||||
@@ -234,31 +281,34 @@ public abstract class Transition implements Cloneable {
|
||||
* <p>The method is called for every applicable target object, which is
|
||||
* stored in the {@link TransitionValues#view} field.</p>
|
||||
*
|
||||
* @param sceneRoot
|
||||
* @param startValues
|
||||
* @param endValues
|
||||
* @return A non-null Animator to be started at the appropriate time in the
|
||||
* overall transition for this scene change, null otherwise.
|
||||
*
|
||||
* @param sceneRoot The root of the transition hierarchy.
|
||||
* @param startValues The values for a specific target in the start scene.
|
||||
* @param endValues The values for the target in the end scene.
|
||||
* @return A Animator to be started at the appropriate time in the
|
||||
* overall transition for this scene change. A null value means no animation
|
||||
* should be run.
|
||||
*/
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This version of play() is called with the entire set of start/end
|
||||
* This method, essentially a wrapper around all calls to createAnimator for all
|
||||
* possible target views, is called with the entire set of start/end
|
||||
* values. The implementation in Transition iterates through these lists
|
||||
* and calls {@link #play(ViewGroup, TransitionValues, TransitionValues)}
|
||||
* and calls {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}
|
||||
* with each set of start/end values on this transition. The
|
||||
* TransitionGroup subclass overrides this method and delegates it to
|
||||
* TransitionSet subclass overrides this method and delegates it to
|
||||
* each of its children in succession.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
protected void play(ViewGroup sceneRoot, TransitionValuesMaps startValues,
|
||||
protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues,
|
||||
TransitionValuesMaps endValues) {
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "play() for " + this);
|
||||
Log.d(LOG_TAG, "createAnimators() for " + this);
|
||||
}
|
||||
ArrayMap<View, TransitionValues> endCopy =
|
||||
new ArrayMap<View, TransitionValues>(endValues.viewValues);
|
||||
@@ -392,7 +442,7 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
}
|
||||
// TODO: what to do about targetIds and itemIds?
|
||||
Animator animator = play(sceneRoot, start, end);
|
||||
Animator animator = createAnimator(sceneRoot, start, end);
|
||||
if (animator != null) {
|
||||
// Save animation info for future cancellation purposes
|
||||
View view = null;
|
||||
@@ -450,19 +500,19 @@ public abstract class Transition implements Cloneable {
|
||||
* views are ignored and only the ids are used).
|
||||
*/
|
||||
boolean isValidTarget(View target, long targetId) {
|
||||
if (mTargetIds == null && mTargets == null) {
|
||||
if (mTargetIds.size() == 0 && mTargets.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
if (mTargetIds != null) {
|
||||
for (int i = 0; i < mTargetIds.length; ++i) {
|
||||
if (mTargetIds[i] == targetId) {
|
||||
if (mTargetIds.size() > 0) {
|
||||
for (int i = 0; i < mTargetIds.size(); ++i) {
|
||||
if (mTargetIds.get(i) == targetId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target != null && mTargets != null) {
|
||||
for (int i = 0; i < mTargets.length; ++i) {
|
||||
if (mTargets[i] == target) {
|
||||
if (target != null && mTargets.size() > 0) {
|
||||
for (int i = 0; i < mTargets.size(); ++i) {
|
||||
if (mTargets.get(i) == target) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -485,13 +535,13 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
protected void runAnimations() {
|
||||
protected void runAnimators() {
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, "runAnimations() on " + this);
|
||||
Log.d(LOG_TAG, "runAnimators() on " + this);
|
||||
}
|
||||
start();
|
||||
ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
|
||||
// Now start every Animator that was previously created for this transition in play()
|
||||
// Now start every Animator that was previously created for this transition
|
||||
for (Animator anim : mAnimators) {
|
||||
if (DBG) {
|
||||
Log.d(LOG_TAG, " anim: " + anim);
|
||||
@@ -525,17 +575,20 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures the current scene of values for the properties that this
|
||||
* transition monitors. These values can be either the start or end
|
||||
* values used in a subsequent call to
|
||||
* {@link #play(ViewGroup, TransitionValues, TransitionValues)}, as indicated by
|
||||
* <code>start</code>. The main concern for an implementation is what the
|
||||
* Captures the values in the start scene for the properties that this
|
||||
* transition monitors. These values are then passed as the startValues
|
||||
* structure in a later call to
|
||||
* {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}.
|
||||
* The main concern for an implementation is what the
|
||||
* properties are that the transition cares about and what the values are
|
||||
* for all of those properties. The start and end values will be compared
|
||||
* later during the
|
||||
* {@link #play(android.view.ViewGroup, TransitionValues, TransitionValues)}
|
||||
* {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)}
|
||||
* method to determine what, if any, animations, should be run.
|
||||
*
|
||||
* <p>Subclasses must implement this method. The method should only be called by the
|
||||
* transition system; it is not intended to be called from external classes.</p>
|
||||
*
|
||||
* @param transitionValues The holder for any values that the Transition
|
||||
* wishes to store. Values are stored in the <code>values</code> field
|
||||
* of this TransitionValues object and are keyed from
|
||||
@@ -544,29 +597,80 @@ public abstract class Transition implements Cloneable {
|
||||
* <code>transitionValues.values.put("appname:transitionname:rotation",
|
||||
* view.getRotation())</code>. The target view will already be stored in
|
||||
* the transitionValues structure when this method is called.
|
||||
*
|
||||
* @see #captureEndValues(TransitionValues)
|
||||
* @see #createAnimator(ViewGroup, TransitionValues, TransitionValues)
|
||||
*/
|
||||
protected abstract void captureValues(TransitionValues transitionValues, boolean start);
|
||||
public abstract void captureStartValues(TransitionValues transitionValues);
|
||||
|
||||
/**
|
||||
* Sets the ids of target views that this Transition is interested in
|
||||
* Captures the values in the end scene for the properties that this
|
||||
* transition monitors. These values are then passed as the endValues
|
||||
* structure in a later call to
|
||||
* {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}.
|
||||
* The main concern for an implementation is what the
|
||||
* properties are that the transition cares about and what the values are
|
||||
* for all of those properties. The start and end values will be compared
|
||||
* later during the
|
||||
* {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)}
|
||||
* method to determine what, if any, animations, should be run.
|
||||
*
|
||||
* <p>Subclasses must implement this method. The method should only be called by the
|
||||
* transition system; it is not intended to be called from external classes.</p>
|
||||
*
|
||||
* @param transitionValues The holder for any values that the Transition
|
||||
* wishes to store. Values are stored in the <code>values</code> field
|
||||
* of this TransitionValues object and are keyed from
|
||||
* a String value. For example, to store a view's rotation value,
|
||||
* a transition might call
|
||||
* <code>transitionValues.values.put("appname:transitionname:rotation",
|
||||
* view.getRotation())</code>. The target view will already be stored in
|
||||
* the transitionValues structure when this method is called.
|
||||
*
|
||||
* @see #captureStartValues(TransitionValues)
|
||||
* @see #createAnimator(ViewGroup, TransitionValues, TransitionValues)
|
||||
*/
|
||||
public abstract void captureEndValues(TransitionValues transitionValues);
|
||||
|
||||
/**
|
||||
* Adds the id of a target view that this Transition is interested in
|
||||
* animating. By default, there are no targetIds, and a Transition will
|
||||
* listen for changes on every view in the hierarchy below the sceneRoot
|
||||
* of the Scene being transitioned into. Setting targetIDs constrains
|
||||
* of the Scene being transitioned into. Setting targetIds constrains
|
||||
* the Transition to only listen for, and act on, views with these IDs.
|
||||
* Views with different IDs, or no IDs whatsoever, will be ignored.
|
||||
*
|
||||
* <p>Note that using ids to specify targets implies that ids should be unique
|
||||
* within the view hierarchy underneat the scene root.</p>
|
||||
*
|
||||
* @see View#getId()
|
||||
* @param targetIds A list of IDs which specify the set of Views on which
|
||||
* the Transition will act.
|
||||
* @return Transition The Transition on which the targetIds have been set.
|
||||
* @param targetId The id of a target view, must be a positive number.
|
||||
* @return The Transition to which the targetId is added.
|
||||
* Returning the same object makes it easier to chain calls during
|
||||
* construction, such as
|
||||
* <code>transitionGroup.addTransitions(new Fade()).setTargetIds(someId);</code>
|
||||
* <code>transitionSet.addTransitions(new Fade()).addTargetId(someId);</code>
|
||||
*/
|
||||
public Transition setTargetIds(int... targetIds) {
|
||||
int numTargets = targetIds.length;
|
||||
mTargetIds = new int[numTargets];
|
||||
System.arraycopy(targetIds, 0, mTargetIds, 0, numTargets);
|
||||
public Transition addTargetId(int targetId) {
|
||||
if (targetId > 0) {
|
||||
mTargetIds.add(targetId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given targetId from the list of ids that this Transition
|
||||
* is interested in animating.
|
||||
*
|
||||
* @param targetId The id of a target view, must be a positive number.
|
||||
* @return The Transition from which the targetId is removed.
|
||||
* Returning the same object makes it easier to chain calls during
|
||||
* construction, such as
|
||||
* <code>transitionSet.addTransitions(new Fade()).removeTargetId(someId);</code>
|
||||
*/
|
||||
public Transition removeTargetId(int targetId) {
|
||||
if (targetId > 0) {
|
||||
mTargetIds.remove(targetId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -578,28 +682,43 @@ public abstract class Transition implements Cloneable {
|
||||
* the Transition to only listen for, and act on, these views.
|
||||
* All other views will be ignored.
|
||||
*
|
||||
* <p>The target list is like the {@link #setTargetIds(int...) targetId}
|
||||
* <p>The target list is like the {@link #addTargetId(int) targetId}
|
||||
* list except this list specifies the actual View instances, not the ids
|
||||
* of the views. This is an important distinction when scene changes involve
|
||||
* view hierarchies which have been inflated separately; different views may
|
||||
* share the same id but not actually be the same instance. If the transition
|
||||
* should treat those views as the same, then seTargetIds() should be used
|
||||
* instead of setTargets(). If, on the other hand, scene changes involve
|
||||
* should treat those views as the same, then {@link #addTargetId(int)} should be used
|
||||
* instead of {@link #addTarget(View)}. If, on the other hand, scene changes involve
|
||||
* changes all within the same view hierarchy, among views which do not
|
||||
* necessary have ids set on them, then the target list may be more
|
||||
* necessarily have ids set on them, then the target list of views may be more
|
||||
* convenient.</p>
|
||||
*
|
||||
* @see #setTargetIds(int...)
|
||||
* @param targets A list of Views on which the Transition will act.
|
||||
* @return Transition The Transition on which the targets have been set.
|
||||
* @see #addTargetId(int)
|
||||
* @param target A View on which the Transition will act, must be non-null.
|
||||
* @return The Transition to which the target is added.
|
||||
* Returning the same object makes it easier to chain calls during
|
||||
* construction, such as
|
||||
* <code>transitionGroup.addTransitions(new Fade()).setTargets(someView);</code>
|
||||
* <code>transitionSet.addTransitions(new Fade()).addTarget(someView);</code>
|
||||
*/
|
||||
public Transition setTargets(View... targets) {
|
||||
int numTargets = targets.length;
|
||||
mTargets = new View[numTargets];
|
||||
System.arraycopy(targets, 0, mTargets, 0, numTargets);
|
||||
public Transition addTarget(View target) {
|
||||
mTargets.add(target);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given target from the list of targets that this Transition
|
||||
* is interested in animating.
|
||||
*
|
||||
* @param target The target view, must be non-null.
|
||||
* @return Transition The Transition from which the target is removed.
|
||||
* Returning the same object makes it easier to chain calls during
|
||||
* construction, such as
|
||||
* <code>transitionSet.addTransitions(new Fade()).removeTarget(someView);</code>
|
||||
*/
|
||||
public Transition removeTarget(View target) {
|
||||
if (target != null) {
|
||||
mTargets.remove(target);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -612,7 +731,7 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @return the list of target IDs
|
||||
*/
|
||||
public int[] getTargetIds() {
|
||||
public List<Integer> getTargetIds() {
|
||||
return mTargetIds;
|
||||
}
|
||||
|
||||
@@ -625,7 +744,7 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @return the list of target views
|
||||
*/
|
||||
public View[] getTargets() {
|
||||
public List<View> getTargets() {
|
||||
return mTargets;
|
||||
}
|
||||
|
||||
@@ -646,16 +765,19 @@ public abstract class Transition implements Cloneable {
|
||||
mEndValues.idValues.clear();
|
||||
mEndValues.itemIdValues.clear();
|
||||
}
|
||||
if (mTargetIds != null && mTargetIds.length > 0 ||
|
||||
mTargets != null && mTargets.length > 0) {
|
||||
if (mTargetIds != null) {
|
||||
for (int i = 0; i < mTargetIds.length; ++i) {
|
||||
int id = mTargetIds[i];
|
||||
if (mTargetIds.size() > 0 || mTargets.size() > 0) {
|
||||
if (mTargetIds.size() > 0) {
|
||||
for (int i = 0; i < mTargetIds.size(); ++i) {
|
||||
int id = mTargetIds.get(i);
|
||||
View view = sceneRoot.findViewById(id);
|
||||
if (view != null) {
|
||||
TransitionValues values = new TransitionValues();
|
||||
values.view = view;
|
||||
captureValues(values, start);
|
||||
if (start) {
|
||||
captureStartValues(values);
|
||||
} else {
|
||||
captureEndValues(values);
|
||||
}
|
||||
if (start) {
|
||||
mStartValues.viewValues.put(view, values);
|
||||
if (id >= 0) {
|
||||
@@ -670,13 +792,17 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mTargets != null) {
|
||||
for (int i = 0; i < mTargets.length; ++i) {
|
||||
View view = mTargets[i];
|
||||
if (mTargets.size() > 0) {
|
||||
for (int i = 0; i < mTargets.size(); ++i) {
|
||||
View view = mTargets.get(i);
|
||||
if (view != null) {
|
||||
TransitionValues values = new TransitionValues();
|
||||
values.view = view;
|
||||
captureValues(values, start);
|
||||
if (start) {
|
||||
captureStartValues(values);
|
||||
} else {
|
||||
captureEndValues(values);
|
||||
}
|
||||
if (start) {
|
||||
mStartValues.viewValues.put(view, values);
|
||||
} else {
|
||||
@@ -723,7 +849,7 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
TransitionValues values = new TransitionValues();
|
||||
values.view = view;
|
||||
captureValues(values, start);
|
||||
captureStartValues(values);
|
||||
if (start) {
|
||||
if (!isListViewItem) {
|
||||
mStartValues.viewValues.put(view, values);
|
||||
@@ -757,7 +883,7 @@ public abstract class Transition implements Cloneable {
|
||||
* necessary, for example, to query the before/after state of related views
|
||||
* for a given transition.
|
||||
*/
|
||||
protected TransitionValues getTransitionValues(View view, boolean start) {
|
||||
public TransitionValues getTransitionValues(View view, boolean start) {
|
||||
if (mParent != null) {
|
||||
return mParent.getTransitionValues(view, start);
|
||||
}
|
||||
@@ -834,7 +960,7 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* Called by TransitionManager to play the transition. This calls
|
||||
* play() to set things up and create all of the animations and then
|
||||
* createAnimators() to set things up and create all of the animations and then
|
||||
* runAnimations() to actually start the animations.
|
||||
*/
|
||||
void playTransition(ViewGroup sceneRoot) {
|
||||
@@ -889,11 +1015,8 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
// setup() must be called on entire transition hierarchy and set of views
|
||||
// before calling play() on anything; every transition needs a chance to set up
|
||||
// target views appropriately before transitions begin running
|
||||
play(sceneRoot, mStartValues, mEndValues);
|
||||
runAnimations();
|
||||
createAnimators(sceneRoot, mStartValues, mEndValues);
|
||||
runAnimators();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -933,7 +1056,7 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* This method is called automatically by the transition and
|
||||
* TransitionGroup classes prior to a Transition subclass starting;
|
||||
* TransitionSet classes prior to a Transition subclass starting;
|
||||
* subclasses should not need to call it directly.
|
||||
*
|
||||
* @hide
|
||||
@@ -954,9 +1077,9 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* This method is called automatically by the Transition and
|
||||
* TransitionGroup classes when a transition finishes, either because
|
||||
* TransitionSet classes when a transition finishes, either because
|
||||
* a transition did nothing (returned a null Animator from
|
||||
* {@link Transition#play(ViewGroup, TransitionValues,
|
||||
* {@link Transition#createAnimator(ViewGroup, TransitionValues,
|
||||
* TransitionValues)}) or because the transition returned a valid
|
||||
* Animator and end() was called in the onAnimationEnd()
|
||||
* callback of the AnimatorListener.
|
||||
@@ -993,11 +1116,10 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* This method cancels a transition that is currently running.
|
||||
* Implementation TBD.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
protected void cancel() {
|
||||
// TODO: how does this work with instances?
|
||||
// TODO: this doesn't actually do *anything* yet
|
||||
int numAnimators = mCurrentAnimators.size();
|
||||
for (int i = numAnimators - 1; i >= 0; i--) {
|
||||
Animator animator = mCurrentAnimators.get(i);
|
||||
@@ -1019,12 +1141,14 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @param listener the listener to be added to the current set of listeners
|
||||
* for this animation.
|
||||
* @return This transition object.
|
||||
*/
|
||||
public void addListener(TransitionListener listener) {
|
||||
public Transition addListener(TransitionListener listener) {
|
||||
if (mListeners == null) {
|
||||
mListeners = new ArrayList<TransitionListener>();
|
||||
}
|
||||
mListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1032,29 +1156,22 @@ public abstract class Transition implements Cloneable {
|
||||
*
|
||||
* @param listener the listener to be removed from the current set of
|
||||
* listeners for this transition.
|
||||
* @return This transition object.
|
||||
*/
|
||||
public void removeListener(TransitionListener listener) {
|
||||
public Transition removeListener(TransitionListener listener) {
|
||||
if (mListeners == null) {
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
mListeners.remove(listener);
|
||||
if (mListeners.size() == 0) {
|
||||
mListeners = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of {@link TransitionListener} objects that are currently
|
||||
* listening for events on this <code>Transition</code> object.
|
||||
*
|
||||
* @return ArrayList<TransitionListener> The set of listeners.
|
||||
*/
|
||||
public ArrayList<TransitionListener> getListeners() {
|
||||
return mListeners;
|
||||
}
|
||||
|
||||
void setSceneRoot(ViewGroup sceneRoot) {
|
||||
Transition setSceneRoot(ViewGroup sceneRoot) {
|
||||
mSceneRoot = sceneRoot;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1076,9 +1193,9 @@ public abstract class Transition implements Cloneable {
|
||||
/**
|
||||
* Returns the name of this Transition. This name is used internally to distinguish
|
||||
* between different transitions to determine when interrupting transitions overlap.
|
||||
* For example, a Move running on the same target view as another Move should determine
|
||||
* whether the old transition is animating to different end values and should be
|
||||
* canceled in favor of the new transition.
|
||||
* For example, a ChangeBounds running on the same target view as another ChangeBounds
|
||||
* should determine whether the old transition is animating to different end values
|
||||
* and should be canceled in favor of the new transition.
|
||||
*
|
||||
* <p>By default, a Transition's name is simply the value of {@link Class#getName()},
|
||||
* but subclasses are free to override and return something different.</p>
|
||||
@@ -1101,22 +1218,22 @@ public abstract class Transition implements Cloneable {
|
||||
if (mInterpolator != null) {
|
||||
result += "interp(" + mInterpolator + ") ";
|
||||
}
|
||||
if (mTargetIds != null || mTargets != null) {
|
||||
if (mTargetIds.size() > 0 || mTargets.size() > 0) {
|
||||
result += "tgts(";
|
||||
if (mTargetIds != null) {
|
||||
for (int i = 0; i < mTargetIds.length; ++i) {
|
||||
if (mTargetIds.size() > 0) {
|
||||
for (int i = 0; i < mTargetIds.size(); ++i) {
|
||||
if (i > 0) {
|
||||
result += ", ";
|
||||
}
|
||||
result += mTargetIds[i];
|
||||
result += mTargetIds.get(i);
|
||||
}
|
||||
}
|
||||
if (mTargets != null) {
|
||||
for (int i = 0; i < mTargets.length; ++i) {
|
||||
if (mTargets.size() > 0) {
|
||||
for (int i = 0; i < mTargets.size(); ++i) {
|
||||
if (i > 0) {
|
||||
result += ", ";
|
||||
}
|
||||
result += mTargets[i];
|
||||
result += mTargets.get(i);
|
||||
}
|
||||
}
|
||||
result += ")";
|
||||
@@ -1149,11 +1266,11 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* Notification about the cancellation of the transition.
|
||||
* Note that cancel() may be called by a parent {@link TransitionGroup} on
|
||||
* Note that cancel may be called by a parent {@link TransitionSet} on
|
||||
* a child transition which has not yet started. This allows the child
|
||||
* transition to restore state on target objects which was set at
|
||||
* {@link #play(android.view.ViewGroup, TransitionValues, TransitionValues)
|
||||
* play()} time.
|
||||
* {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)
|
||||
* createAnimator()} time.
|
||||
*
|
||||
* @param transition The transition which was canceled.
|
||||
*/
|
||||
@@ -1161,11 +1278,11 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* Notification when a transition is paused.
|
||||
* Note that play() may be called by a parent {@link TransitionGroup} on
|
||||
* Note that createAnimator() may be called by a parent {@link TransitionSet} on
|
||||
* a child transition which has not yet started. This allows the child
|
||||
* transition to restore state on target objects which was set at
|
||||
* {@link #play(android.view.ViewGroup, TransitionValues, TransitionValues)
|
||||
* play()} time.
|
||||
* {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues)
|
||||
* createAnimator()} time.
|
||||
*
|
||||
* @param transition The transition which was paused.
|
||||
*/
|
||||
@@ -1173,7 +1290,7 @@ public abstract class Transition implements Cloneable {
|
||||
|
||||
/**
|
||||
* Notification when a transition is resumed.
|
||||
* Note that resume() may be called by a parent {@link TransitionGroup} on
|
||||
* Note that resume() may be called by a parent {@link TransitionSet} on
|
||||
* a child transition which has not yet started. This allows the child
|
||||
* transition to restore state which may have changed in an earlier call
|
||||
* to {@link #onTransitionPause(Transition)}.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -35,6 +35,11 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class inflates scenes and transitions from resource files.
|
||||
*
|
||||
* Information on XML resource descriptions for transitions can be found for
|
||||
* {@link android.R.styleable#Transition}, {@link android.R.styleable#TransitionSet},
|
||||
* {@link android.R.styleable#TransitionTarget}, {@link android.R.styleable#Fade},
|
||||
* and {@link android.R.styleable#TransitionManager}.
|
||||
*/
|
||||
public class TransitionInflater {
|
||||
|
||||
@@ -121,46 +126,12 @@ public class TransitionInflater {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a {@link Scene} object from a resource
|
||||
*
|
||||
* @param resource The resource id of the scene to load
|
||||
* @return The loaded Scene object
|
||||
* @throws android.content.res.Resources.NotFoundException when the scene
|
||||
* cannot be loaded
|
||||
*/
|
||||
public Scene inflateScene(int resource, ViewGroup parent) {
|
||||
Scene scene = mScenes.get(resource);
|
||||
if (scene != null) {
|
||||
return scene;
|
||||
}
|
||||
XmlResourceParser parser = mContext.getResources().getXml(resource);
|
||||
try {
|
||||
scene = createSceneFromXml(parser, Xml.asAttributeSet(parser), parent);
|
||||
mScenes.put(resource, scene);
|
||||
return scene;
|
||||
} catch (XmlPullParserException e) {
|
||||
InflateException ex = new InflateException(e.getMessage());
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} catch (IOException e) {
|
||||
InflateException ex = new InflateException(
|
||||
parser.getPositionDescription()
|
||||
+ ": " + e.getMessage());
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
} finally {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Transition loading
|
||||
//
|
||||
|
||||
private Transition createTransitionFromXml(XmlPullParser parser,
|
||||
AttributeSet attrs, TransitionGroup transitionGroup)
|
||||
AttributeSet attrs, TransitionSet transitionSet)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
Transition transition = null;
|
||||
@@ -180,10 +151,14 @@ public class TransitionInflater {
|
||||
|
||||
String name = parser.getName();
|
||||
if ("fade".equals(name)) {
|
||||
transition = new Fade();
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.Fade);
|
||||
int fadingMode = a.getInt(com.android.internal.R.styleable.Fade_fadingMode,
|
||||
Fade.IN | Fade.OUT);
|
||||
transition = new Fade(fadingMode);
|
||||
newTransition = true;
|
||||
} else if ("move".equals(name)) {
|
||||
transition = new Move();
|
||||
} else if ("changeBounds".equals(name)) {
|
||||
transition = new ChangeBounds();
|
||||
newTransition = true;
|
||||
} else if ("slide".equals(name)) {
|
||||
transition = new Slide();
|
||||
@@ -194,24 +169,31 @@ public class TransitionInflater {
|
||||
} else if ("recolor".equals(name)) {
|
||||
transition = new Recolor();
|
||||
newTransition = true;
|
||||
} else if ("transitionGroup".equals(name)) {
|
||||
transition = new TransitionGroup();
|
||||
createTransitionFromXml(parser, attrs, ((TransitionGroup) transition));
|
||||
} else if ("set".equals(name)) {
|
||||
transition = new TransitionSet();
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.TransitionSet);
|
||||
int ordering = a.getInt(
|
||||
com.android.internal.R.styleable.TransitionSet_transitionOrdering,
|
||||
TransitionSet.ORDERING_TOGETHER);
|
||||
((TransitionSet) transition).setOrdering(ordering);
|
||||
createTransitionFromXml(parser, attrs, ((TransitionSet) transition));
|
||||
a.recycle();
|
||||
newTransition = true;
|
||||
} else if ("targets".equals(name)) {
|
||||
if (parser.getDepth() - 1 > depth && transition != null) {
|
||||
// We're inside the child tag - add targets to the child
|
||||
getTargetIDs(parser, attrs, transition);
|
||||
} else if (parser.getDepth() - 1 == depth && transitionGroup != null) {
|
||||
// add targets to the group
|
||||
getTargetIDs(parser, attrs, transitionGroup);
|
||||
getTargetIds(parser, attrs, transition);
|
||||
} else if (parser.getDepth() - 1 == depth && transitionSet != null) {
|
||||
// add targets to the set
|
||||
getTargetIds(parser, attrs, transitionSet);
|
||||
}
|
||||
}
|
||||
if (transition != null || "targets".equals(name)) {
|
||||
if (newTransition) {
|
||||
loadTransition(transition, attrs);
|
||||
if (transitionGroup != null) {
|
||||
transitionGroup.addTransitions(transition);
|
||||
if (transitionSet != null) {
|
||||
transitionSet.addTransition(transition);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -222,7 +204,7 @@ public class TransitionInflater {
|
||||
return transition;
|
||||
}
|
||||
|
||||
private void getTargetIDs(XmlPullParser parser,
|
||||
private void getTargetIds(XmlPullParser parser,
|
||||
AttributeSet attrs, Transition transition) throws XmlPullParserException, IOException {
|
||||
|
||||
// Make sure we are on a start tag.
|
||||
@@ -240,8 +222,9 @@ public class TransitionInflater {
|
||||
String name = parser.getName();
|
||||
if (name.equals("target")) {
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.Transition);
|
||||
int id = a.getResourceId(com.android.internal.R.styleable.Transition_targetID, -1);
|
||||
com.android.internal.R.styleable.TransitionTarget);
|
||||
int id = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionTarget_targetId, -1);
|
||||
if (id >= 0) {
|
||||
targetIds.add(id);
|
||||
}
|
||||
@@ -251,11 +234,9 @@ public class TransitionInflater {
|
||||
}
|
||||
int numTargets = targetIds.size();
|
||||
if (numTargets > 0) {
|
||||
int[] targetsArray = new int[numTargets];
|
||||
for (int i = 0; i < targetIds.size(); ++i) {
|
||||
targetsArray[i] = targetIds.get(i);
|
||||
for (int i = 0; i < numTargets; ++i) {
|
||||
transition.addTargetId(targetIds.get(i));
|
||||
}
|
||||
transition.setTargetIds(targetsArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,9 +249,9 @@ public class TransitionInflater {
|
||||
if (duration >= 0) {
|
||||
transition.setDuration(duration);
|
||||
}
|
||||
long startOffset = a.getInt(com.android.internal.R.styleable.Transition_startOffset, -1);
|
||||
if (startOffset > 0) {
|
||||
transition.setStartDelay(startOffset);
|
||||
long startDelay = a.getInt(com.android.internal.R.styleable.Transition_startDelay, -1);
|
||||
if (startDelay > 0) {
|
||||
transition.setStartDelay(startDelay);
|
||||
}
|
||||
final int resID =
|
||||
a.getResourceId(com.android.internal.R.styleable.Animator_interpolator, 0);
|
||||
@@ -313,20 +294,19 @@ public class TransitionInflater {
|
||||
}
|
||||
|
||||
private void loadTransition(AttributeSet attrs, ViewGroup sceneRoot,
|
||||
TransitionManager transitionManager)
|
||||
throws Resources.NotFoundException {
|
||||
TransitionManager transitionManager) throws Resources.NotFoundException {
|
||||
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.TransitionManager);
|
||||
int transitionId = attrs.getAttributeResourceValue(
|
||||
int transitionId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_transition, -1);
|
||||
Scene fromScene = null, toScene = null;
|
||||
int fromId = attrs.getAttributeResourceValue(
|
||||
int fromId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_fromScene, -1);
|
||||
if (fromId >= 0) fromScene = inflateScene(fromId, sceneRoot);
|
||||
int toId = attrs.getAttributeResourceValue(
|
||||
if (fromId >= 0) fromScene = Scene.getSceneForLayout(sceneRoot, fromId, mContext);
|
||||
int toId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_toScene, -1);
|
||||
if (toId >= 0) toScene = inflateScene(toId, sceneRoot);
|
||||
if (toId >= 0) toScene = Scene.getSceneForLayout(sceneRoot, toId, mContext);
|
||||
if (transitionId >= 0) {
|
||||
Transition transition = inflateTransition(transitionId);
|
||||
if (transition != null) {
|
||||
@@ -344,50 +324,4 @@ public class TransitionInflater {
|
||||
}
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
//
|
||||
// Scene loading
|
||||
//
|
||||
|
||||
private Scene createSceneFromXml(XmlPullParser parser, AttributeSet attrs, ViewGroup parent)
|
||||
throws XmlPullParserException, IOException {
|
||||
Scene scene = null;
|
||||
|
||||
// Make sure we are on a start tag.
|
||||
int type;
|
||||
int depth = parser.getDepth();
|
||||
|
||||
while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
|
||||
&& type != XmlPullParser.END_DOCUMENT) {
|
||||
|
||||
if (type != XmlPullParser.START_TAG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = parser.getName();
|
||||
if (name.equals("scene")) {
|
||||
scene = loadScene(attrs, parent);
|
||||
} else {
|
||||
throw new RuntimeException("Unknown scene name: " + parser.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
private Scene loadScene(AttributeSet attrs, ViewGroup parent)
|
||||
throws Resources.NotFoundException {
|
||||
|
||||
Scene scene;
|
||||
TypedArray a = mContext.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.Scene);
|
||||
int layoutId = a.getResourceId(com.android.internal.R.styleable.Scene_layout, -1);
|
||||
if (layoutId >= 0) {
|
||||
scene = new Scene(parent, layoutId, mContext);
|
||||
} else {
|
||||
scene = new Scene(parent);
|
||||
}
|
||||
a.recycle();
|
||||
return scene;
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
||||
@@ -34,14 +34,36 @@ import java.util.ArrayList;
|
||||
* situations. Specifying other transitions for particular scene changes is
|
||||
* only necessary if the application wants different transition behavior
|
||||
* in these situations.
|
||||
*
|
||||
* <p>TransitionManagers can be declared in XML resource files inside the
|
||||
* <code>res/transition</code> directory. TransitionManager resources consist of
|
||||
* the <code>transitionManager</code>tag name, containing one or more
|
||||
* <code>transition</code> tags, each of which describe the relationship of
|
||||
* that transition to the from/to scene information in that tag.
|
||||
* For example, here is a resource file that declares several scene
|
||||
* transitions:</p>
|
||||
*
|
||||
* {@sample development/samples/ApiDemos/res/transition/transitions_mgr.xml TransitionManager}
|
||||
*
|
||||
* <p>For each of the <code>fromScene</code> and <code>toScene</code> attributes,
|
||||
* there is a reference to a standard XML layout file. This is equivalent to
|
||||
* creating a scene from a layout in code by calling
|
||||
* {@link Scene#getSceneForLayout(ViewGroup, int, Context)}. For the
|
||||
* <code>transition</code> attribute, there is a reference to a resource
|
||||
* file in the <code>res/transition</code> directory which describes that
|
||||
* transition.</p>
|
||||
*
|
||||
* Information on XML resource descriptions for transitions can be found for
|
||||
* {@link android.R.styleable#Transition}, {@link android.R.styleable#TransitionSet},
|
||||
* {@link android.R.styleable#TransitionTarget}, {@link android.R.styleable#Fade},
|
||||
* and {@link android.R.styleable#TransitionManager}.
|
||||
*/
|
||||
public class TransitionManager {
|
||||
// TODO: how to handle enter/exit?
|
||||
|
||||
private static String LOG_TAG = "TransitionManager";
|
||||
|
||||
private static final Transition sDefaultTransition = new AutoTransition();
|
||||
private Transition mDefaultTransition = new AutoTransition();
|
||||
private static Transition sDefaultTransition = new AutoTransition();
|
||||
|
||||
ArrayMap<Scene, Transition> mSceneTransitions = new ArrayMap<Scene, Transition>();
|
||||
ArrayMap<Scene, ArrayMap<Scene, Transition>> mScenePairTransitions =
|
||||
@@ -59,7 +81,7 @@ public class TransitionManager {
|
||||
* @param transition The default transition to be used for scene changes.
|
||||
*/
|
||||
public void setDefaultTransition(Transition transition) {
|
||||
mDefaultTransition = transition;
|
||||
sDefaultTransition = transition;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +91,8 @@ public class TransitionManager {
|
||||
* @return The current default transition.
|
||||
* @see #setDefaultTransition(Transition)
|
||||
*/
|
||||
public Transition getDefaultTransition() {
|
||||
return mDefaultTransition;
|
||||
public static Transition getDefaultTransition() {
|
||||
return sDefaultTransition;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +102,7 @@ public class TransitionManager {
|
||||
* transition to run.
|
||||
* @param transition The transition that will play when the given scene is
|
||||
* entered. A value of null will result in the default behavior of
|
||||
* using {@link AutoTransition}.
|
||||
* using the {@link #getDefaultTransition() default transition} instead.
|
||||
*/
|
||||
public void setTransition(Scene scene, Transition transition) {
|
||||
mSceneTransitions.put(scene, transition);
|
||||
@@ -96,7 +118,7 @@ public class TransitionManager {
|
||||
* be run
|
||||
* @param transition The transition that will play when the given scene is
|
||||
* entered. A value of null will result in the default behavior of
|
||||
* using {@link AutoTransition}.
|
||||
* using the {@link #getDefaultTransition() default transition} instead.
|
||||
*/
|
||||
public void setTransition(Scene fromScene, Scene toScene, Transition transition) {
|
||||
ArrayMap<Scene, Transition> sceneTransitionMap = mScenePairTransitions.get(toScene);
|
||||
@@ -114,15 +136,15 @@ public class TransitionManager {
|
||||
*
|
||||
* @param scene The scene being entered
|
||||
* @return The Transition to be used for the given scene change. If no
|
||||
* Transition was specified for this scene change, {@link AutoTransition}
|
||||
* will be used instead.
|
||||
* Transition was specified for this scene change, the {@link #getDefaultTransition()
|
||||
* default transition} will be used instead.
|
||||
*/
|
||||
private Transition getTransition(Scene scene) {
|
||||
Transition transition = null;
|
||||
ViewGroup sceneRoot = scene.getSceneRoot();
|
||||
if (sceneRoot != null) {
|
||||
// TODO: cached in Scene instead? long-term, cache in View itself
|
||||
Scene currScene = sceneRoot.getCurrentScene();
|
||||
Scene currScene = Scene.getCurrentScene(sceneRoot);
|
||||
if (currScene != null) {
|
||||
ArrayMap<Scene, Transition> sceneTransitionMap = mScenePairTransitions.get(scene);
|
||||
if (sceneTransitionMap != null) {
|
||||
@@ -134,7 +156,7 @@ public class TransitionManager {
|
||||
}
|
||||
}
|
||||
transition = mSceneTransitions.get(scene);
|
||||
return (transition != null) ? transition : new AutoTransition();
|
||||
return (transition != null) ? transition : sDefaultTransition;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +256,7 @@ public class TransitionManager {
|
||||
}
|
||||
|
||||
// Notify previous scene that it is being exited
|
||||
Scene previousScene = sceneRoot.getCurrentScene();
|
||||
Scene previousScene = Scene.getCurrentScene(sceneRoot);
|
||||
if (previousScene != null) {
|
||||
previousScene.exit();
|
||||
}
|
||||
@@ -256,7 +278,7 @@ public class TransitionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static utility method to simply change to the given scene using
|
||||
* Convenience method to simply change to the given scene using
|
||||
* the default transition for TransitionManager.
|
||||
*
|
||||
* @param scene The Scene to change to
|
||||
@@ -266,15 +288,14 @@ public class TransitionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static utility method to simply change to the given scene using
|
||||
* Convenience method to simply change to the given scene using
|
||||
* the given transition.
|
||||
*
|
||||
* <p>Passing in <code>null</code> for the transition parameter will
|
||||
* result in the scene changing without any transition running, and is
|
||||
* equivalent to calling {@link Scene#exit()} on the scene root's
|
||||
* {@link ViewGroup#getCurrentScene() current scene}, followed by
|
||||
* {@link Scene#enter()} on the scene specified by the <code>scene</code>
|
||||
* parameter.</p>
|
||||
* current scene, followed by {@link Scene#enter()} on the scene
|
||||
* specified by the <code>scene</code> parameter.</p>
|
||||
*
|
||||
* @param scene The Scene to change to
|
||||
* @param transition The transition to use for this scene change. A
|
||||
@@ -285,55 +306,20 @@ public class TransitionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static utility method to simply change to a scene defined by the
|
||||
* code in the given runnable, which will be executed after
|
||||
* the current values have been captured for the transition.
|
||||
* This is equivalent to creating a Scene and calling {@link
|
||||
* Scene#setEnterAction(Runnable)} with the runnable, then calling
|
||||
* {@link #go(Scene, Transition)}. The transition used will be the
|
||||
* default provided by TransitionManager.
|
||||
*
|
||||
* @param sceneRoot The root of the View hierarchy used when this scene
|
||||
* runs a transition automatically.
|
||||
* @param action The runnable whose {@link Runnable#run() run()} method will
|
||||
* be called.
|
||||
*/
|
||||
public static void go(ViewGroup sceneRoot, Runnable action) {
|
||||
Scene scene = new Scene(sceneRoot);
|
||||
scene.setEnterAction(action);
|
||||
changeScene(scene, sDefaultTransition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static utility method to simply change to a scene defined by the
|
||||
* code in the given runnable, which will be executed after
|
||||
* the current values have been captured for the transition.
|
||||
* This is equivalent to creating a Scene and calling {@link
|
||||
* Scene#setEnterAction(Runnable)} with the runnable, then calling
|
||||
* {@link #go(Scene, Transition)}. The given transition will be
|
||||
* used to animate the changes.
|
||||
*
|
||||
* <p>Passing in <code>null</code> for the transition parameter will
|
||||
* result in the scene changing without any transition running, and is
|
||||
* equivalent to calling {@link Scene#exit()} on the scene root's
|
||||
* {@link ViewGroup#getCurrentScene() current scene}, followed by
|
||||
* {@link Scene#enter()} on a new scene specified by the
|
||||
* <code>action</code> parameter.</p>
|
||||
* Convenience method to animate, using the default transition,
|
||||
* to a new scene defined by all changes within the given scene root between
|
||||
* calling this method and the next rendering frame.
|
||||
* Equivalent to calling {@link #beginDelayedTransition(ViewGroup, Transition)}
|
||||
* with a value of <code>null</code> for the <code>transition</code> parameter.
|
||||
*
|
||||
* @param sceneRoot The root of the View hierarchy to run the transition on.
|
||||
* @param action The runnable whose {@link Runnable#run() run()} method will
|
||||
* be called.
|
||||
* @param transition The transition to use for this change. A
|
||||
* value of null causes the change to happen with no transition.
|
||||
*/
|
||||
public static void go(ViewGroup sceneRoot, Runnable action, Transition transition) {
|
||||
Scene scene = new Scene(sceneRoot);
|
||||
scene.setEnterAction(action);
|
||||
changeScene(scene, transition);
|
||||
public static void beginDelayedTransition(final ViewGroup sceneRoot) {
|
||||
beginDelayedTransition(sceneRoot, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static utility method to animate to a new scene defined by all changes within
|
||||
* Convenience method to animate to a new scene defined by all changes within
|
||||
* the given scene root between calling this method and the next rendering frame.
|
||||
* Calling this method causes TransitionManager to capture current values in the
|
||||
* scene root and then post a request to run a transition on the next frame.
|
||||
@@ -367,7 +353,7 @@ public class TransitionManager {
|
||||
}
|
||||
final Transition finalTransition = transition.clone();
|
||||
sceneChangeSetup(sceneRoot, transition);
|
||||
sceneRoot.setCurrentScene(null);
|
||||
Scene.setCurrentScene(sceneRoot, null);
|
||||
sceneChangeRunTransition(sceneRoot, finalTransition);
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A TransitionGroup is a parent of child transitions (including other
|
||||
* TransitionGroups). Using TransitionGroups enables more complex
|
||||
* choreography of transitions, where some groups play {@link #TOGETHER} and
|
||||
* others play {@link #SEQUENTIALLY}. For example, {@link AutoTransition}
|
||||
* uses a TransitionGroup to sequentially play a Fade(Fade.OUT), followed by
|
||||
* a {@link Move}, followed by a Fade(Fade.OUT) transition.
|
||||
* A TransitionSet is a parent of child transitions (including other
|
||||
* TransitionSets). Using TransitionSets enables more complex
|
||||
* choreography of transitions, where some sets play {@link #ORDERING_TOGETHER} and
|
||||
* others play {@link #ORDERING_SEQUENTIAL}. For example, {@link AutoTransition}
|
||||
* uses a TransitionSet to sequentially play a Fade(Fade.OUT), followed by
|
||||
* a {@link ChangeBounds}, followed by a Fade(Fade.OUT) transition.
|
||||
*/
|
||||
public class TransitionGroup extends Transition {
|
||||
public class TransitionSet extends Transition {
|
||||
|
||||
ArrayList<Transition> mTransitions = new ArrayList<Transition>();
|
||||
private boolean mPlayTogether = true;
|
||||
@@ -37,88 +39,96 @@ public class TransitionGroup extends Transition {
|
||||
boolean mStarted = false;
|
||||
|
||||
/**
|
||||
* A flag used to indicate that the child transitions of this group
|
||||
* A flag used to indicate that the child transitions of this set
|
||||
* should all start at the same time.
|
||||
*/
|
||||
public static final int TOGETHER = 0;
|
||||
public static final int ORDERING_TOGETHER = 0;
|
||||
/**
|
||||
* A flag used to indicate that the child transitions of this group should
|
||||
* A flag used to indicate that the child transitions of this set should
|
||||
* play in sequence; when one child transition ends, the next child
|
||||
* transition begins. Note that a transition does not end until all
|
||||
* instances of it (which are playing on all applicable targets of the
|
||||
* transition) end.
|
||||
*/
|
||||
public static final int SEQUENTIALLY = 1;
|
||||
public static final int ORDERING_SEQUENTIAL = 1;
|
||||
|
||||
/**
|
||||
* Constructs an empty transition group. Add child transitions to the
|
||||
* group by calling to {@link #addTransitions(Transition...)} )}. By default,
|
||||
* child transitions will play {@link #TOGETHER}.
|
||||
* Constructs an empty transition set. Add child transitions to the
|
||||
* set by calling {@link #addTransition(Transition)} )}. By default,
|
||||
* child transitions will play {@link #ORDERING_TOGETHER together}.
|
||||
*/
|
||||
public TransitionGroup() {
|
||||
public TransitionSet() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an empty transition group with the specified ordering.
|
||||
* Sets the play order of this set's child transitions.
|
||||
*
|
||||
* @param ordering {@link #TOGETHER} to start this group's child
|
||||
* transitions together, {@link #SEQUENTIALLY} to play the child
|
||||
* @param ordering {@link #ORDERING_TOGETHER} to play this set's child
|
||||
* transitions together, {@link #ORDERING_SEQUENTIAL} to play the child
|
||||
* transitions in sequence.
|
||||
* @see #setOrdering(int)
|
||||
* @return This transitionSet object.
|
||||
*/
|
||||
public TransitionGroup(int ordering) {
|
||||
setOrdering(ordering);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the play order of this group's child transitions.
|
||||
*
|
||||
* @param ordering {@link #TOGETHER} to start this group's child
|
||||
* transitions together, {@link #SEQUENTIALLY} to play the child
|
||||
* transitions in sequence.
|
||||
*/
|
||||
public void setOrdering(int ordering) {
|
||||
public TransitionSet setOrdering(int ordering) {
|
||||
switch (ordering) {
|
||||
case SEQUENTIALLY:
|
||||
case ORDERING_SEQUENTIAL:
|
||||
mPlayTogether = false;
|
||||
break;
|
||||
case TOGETHER:
|
||||
case ORDERING_TOGETHER:
|
||||
mPlayTogether = true;
|
||||
break;
|
||||
default:
|
||||
throw new AndroidRuntimeException("Invalid parameter for TransitionGroup " +
|
||||
throw new AndroidRuntimeException("Invalid parameter for TransitionSet " +
|
||||
"ordering: " + ordering);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds child transitions to this group. The order of the child transitions
|
||||
* passed in determines the order in which they are started.
|
||||
* Returns the ordering of this TransitionSet. By default, the value is
|
||||
* {@link #ORDERING_TOGETHER}.
|
||||
*
|
||||
* @param transitions A list of child transition to be added to this group.
|
||||
* @return {@link #ORDERING_TOGETHER} if child transitions will play at the same
|
||||
* time, {@link #ORDERING_SEQUENTIAL} if they will play in sequence.
|
||||
*
|
||||
* @see #setOrdering(int)
|
||||
*/
|
||||
public void addTransitions(Transition... transitions) {
|
||||
if (transitions != null) {
|
||||
int numTransitions = transitions.length;
|
||||
for (int i = 0; i < numTransitions; ++i) {
|
||||
mTransitions.add(transitions[i]);
|
||||
transitions[i].mParent = this;
|
||||
if (mDuration >= 0) {
|
||||
transitions[i].setDuration(mDuration);
|
||||
}
|
||||
public int getOrdering() {
|
||||
return mPlayTogether ? ORDERING_TOGETHER : ORDERING_SEQUENTIAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds child transition to this set. The order in which this child transition
|
||||
* is added relative to other child transitions that are added, in addition to
|
||||
* the {@link #getOrdering() ordering} property, determines the
|
||||
* order in which the transitions are started.
|
||||
*
|
||||
* <p>If this transitionSet has a {@link #getDuration() duration} set on it, the
|
||||
* child transition will inherit that duration. Transitions are assumed to have
|
||||
* a maximum of one transitionSet parent.</p>
|
||||
*
|
||||
* @param transition A non-null child transition to be added to this set.
|
||||
* @return This transitionSet object.
|
||||
*/
|
||||
public TransitionSet addTransition(Transition transition) {
|
||||
if (transition != null) {
|
||||
mTransitions.add(transition);
|
||||
transition.mParent = this;
|
||||
if (mDuration >= 0) {
|
||||
transition.setDuration(mDuration);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting a non-negative duration on a TransitionGroup causes all of the child
|
||||
* Setting a non-negative duration on a TransitionSet causes all of the child
|
||||
* transitions (current and future) to inherit this duration.
|
||||
*
|
||||
* @param duration The length of the animation, in milliseconds.
|
||||
* @return This transitionGroup object.
|
||||
* @return This transitionSet object.
|
||||
*/
|
||||
@Override
|
||||
public Transition setDuration(long duration) {
|
||||
public TransitionSet setDuration(long duration) {
|
||||
super.setDuration(duration);
|
||||
if (mDuration >= 0) {
|
||||
int numTransitions = mTransitions.size();
|
||||
@@ -129,23 +139,65 @@ public class TransitionGroup extends Transition {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet setStartDelay(long startDelay) {
|
||||
return (TransitionSet) super.setStartDelay(startDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet setInterpolator(TimeInterpolator interpolator) {
|
||||
return (TransitionSet) super.setInterpolator(interpolator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet addTarget(View target) {
|
||||
return (TransitionSet) super.addTarget(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet addTargetId(int targetId) {
|
||||
return (TransitionSet) super.addTargetId(targetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet addListener(TransitionListener listener) {
|
||||
return (TransitionSet) super.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet removeTargetId(int targetId) {
|
||||
return (TransitionSet) super.removeTargetId(targetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet removeTarget(View target) {
|
||||
return (TransitionSet) super.removeTarget(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionSet removeListener(TransitionListener listener) {
|
||||
return (TransitionSet) super.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified child transition from this group.
|
||||
* Removes the specified child transition from this set.
|
||||
*
|
||||
* @param transition The transition to be removed.
|
||||
* @return This transitionSet object.
|
||||
*/
|
||||
public void removeTransition(Transition transition) {
|
||||
public TransitionSet removeTransition(Transition transition) {
|
||||
mTransitions.remove(transition);
|
||||
transition.mParent = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up listeners for each of the child transitions. This is used to
|
||||
* determine when this transition group is finished (all child transitions
|
||||
* determine when this transition set is finished (all child transitions
|
||||
* must finish first).
|
||||
*/
|
||||
private void setupStartEndListeners() {
|
||||
TransitionGroupListener listener = new TransitionGroupListener(this);
|
||||
TransitionSetListener listener = new TransitionSetListener(this);
|
||||
for (Transition childTransition : mTransitions) {
|
||||
childTransition.addListener(listener);
|
||||
}
|
||||
@@ -154,28 +206,28 @@ public class TransitionGroup extends Transition {
|
||||
|
||||
/**
|
||||
* This listener is used to detect when all child transitions are done, at
|
||||
* which point this transition group is also done.
|
||||
* which point this transition set is also done.
|
||||
*/
|
||||
static class TransitionGroupListener extends TransitionListenerAdapter {
|
||||
TransitionGroup mTransitionGroup;
|
||||
TransitionGroupListener(TransitionGroup transitionGroup) {
|
||||
mTransitionGroup = transitionGroup;
|
||||
static class TransitionSetListener extends TransitionListenerAdapter {
|
||||
TransitionSet mTransitionSet;
|
||||
TransitionSetListener(TransitionSet transitionSet) {
|
||||
mTransitionSet = transitionSet;
|
||||
}
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
if (!mTransitionGroup.mStarted) {
|
||||
mTransitionGroup.start();
|
||||
mTransitionGroup.mStarted = true;
|
||||
if (!mTransitionSet.mStarted) {
|
||||
mTransitionSet.start();
|
||||
mTransitionSet.mStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
--mTransitionGroup.mCurrentListeners;
|
||||
if (mTransitionGroup.mCurrentListeners == 0) {
|
||||
--mTransitionSet.mCurrentListeners;
|
||||
if (mTransitionSet.mCurrentListeners == 0) {
|
||||
// All child trans
|
||||
mTransitionGroup.mStarted = false;
|
||||
mTransitionGroup.end();
|
||||
mTransitionSet.mStarted = false;
|
||||
mTransitionSet.end();
|
||||
}
|
||||
transition.removeListener(this);
|
||||
}
|
||||
@@ -185,10 +237,10 @@ public class TransitionGroup extends Transition {
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
protected void play(ViewGroup sceneRoot, TransitionValuesMaps startValues,
|
||||
protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues,
|
||||
TransitionValuesMaps endValues) {
|
||||
for (Transition childTransition : mTransitions) {
|
||||
childTransition.play(sceneRoot, startValues, endValues);
|
||||
childTransition.createAnimators(sceneRoot, startValues, endValues);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +248,7 @@ public class TransitionGroup extends Transition {
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
protected void runAnimations() {
|
||||
protected void runAnimators() {
|
||||
setupStartEndListeners();
|
||||
if (!mPlayTogether) {
|
||||
// Setup sequence with listeners
|
||||
@@ -207,28 +259,38 @@ public class TransitionGroup extends Transition {
|
||||
previousTransition.addListener(new TransitionListenerAdapter() {
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
nextTransition.runAnimations();
|
||||
nextTransition.runAnimators();
|
||||
transition.removeListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
Transition firstTransition = mTransitions.get(0);
|
||||
if (firstTransition != null) {
|
||||
firstTransition.runAnimations();
|
||||
firstTransition.runAnimators();
|
||||
}
|
||||
} else {
|
||||
for (Transition childTransition : mTransitions) {
|
||||
childTransition.runAnimations();
|
||||
childTransition.runAnimators();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues transitionValues, boolean start) {
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
int targetId = transitionValues.view.getId();
|
||||
for (Transition childTransition : mTransitions) {
|
||||
if (childTransition.isValidTarget(transitionValues.view, targetId)) {
|
||||
childTransition.captureValues(transitionValues, start);
|
||||
childTransition.captureStartValues(transitionValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
int targetId = transitionValues.view.getId();
|
||||
for (Transition childTransition : mTransitions) {
|
||||
if (childTransition.isValidTarget(transitionValues.view, targetId)) {
|
||||
childTransition.captureEndValues(transitionValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,6 +315,7 @@ public class TransitionGroup extends Transition {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
protected void cancel() {
|
||||
super.cancel();
|
||||
@@ -263,12 +326,13 @@ public class TransitionGroup extends Transition {
|
||||
}
|
||||
|
||||
@Override
|
||||
void setSceneRoot(ViewGroup sceneRoot) {
|
||||
TransitionSet setSceneRoot(ViewGroup sceneRoot) {
|
||||
super.setSceneRoot(sceneRoot);
|
||||
int numTransitions = mTransitions.size();
|
||||
for (int i = 0; i < numTransitions; ++i) {
|
||||
mTransitions.get(i).setSceneRoot(sceneRoot);
|
||||
}
|
||||
return (TransitionSet) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,8 +345,8 @@ public class TransitionGroup extends Transition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionGroup clone() {
|
||||
TransitionGroup clone = (TransitionGroup) super.clone();
|
||||
public TransitionSet clone() {
|
||||
TransitionSet clone = (TransitionSet) super.clone();
|
||||
clone.mTransitions = new ArrayList<Transition>();
|
||||
int numTransitions = mTransitions.size();
|
||||
for (int i = 0; i < numTransitions; ++i) {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
import android.view.View;
|
||||
@@ -33,11 +33,11 @@ import java.util.Map;
|
||||
* "Fader" as "android:fader:alpha".
|
||||
*
|
||||
* <p>These values are cached during the
|
||||
* {@link Transition#captureValues(TransitionValues, boolean)}
|
||||
* {@link Transition#captureStartValues(TransitionValues)}
|
||||
* capture} phases of a scene change, once when the start values are captured
|
||||
* and again when the end values are captured. These start/end values are then
|
||||
* passed into the transitions via the
|
||||
* for {@link Transition#play(ViewGroup, TransitionValues, TransitionValues)}
|
||||
* for {@link Transition#createAnimator(ViewGroup, TransitionValues, TransitionValues)}
|
||||
* method.</p>
|
||||
*/
|
||||
public class TransitionValues {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
import android.util.LongSparseArray;
|
||||
@@ -14,13 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.transition;
|
||||
package android.transition;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOverlay;
|
||||
import android.view.ViewParent;
|
||||
|
||||
/**
|
||||
* This transition tracks changes to the visibility of target views in the
|
||||
@@ -30,13 +28,13 @@ import android.view.ViewParent;
|
||||
* utility for subclasses such as {@link Fade}, which use this visibility
|
||||
* information to determine the specific animations to run when visibility
|
||||
* changes occur. Subclasses should implement one or both of the methods
|
||||
* {@link #appear(ViewGroup, TransitionValues, int, TransitionValues, int), and
|
||||
* {@link #disappear(ViewGroup, TransitionValues, int, TransitionValues, int)}.
|
||||
* {@link #onAppear(ViewGroup, TransitionValues, int, TransitionValues, int)},
|
||||
* {@link #onDisappear(ViewGroup, TransitionValues, int, TransitionValues, int)},
|
||||
*
|
||||
* <p>Note that a view's visibility change is determined by both whether the view
|
||||
* itself is changing and whether its parent hierarchy's visibility is changing.
|
||||
* That is, a view that appears in the end scene will only trigger a call to
|
||||
* {@link #appear(android.view.ViewGroup, TransitionValues, int, TransitionValues, int)
|
||||
* {@link #onAppear(android.view.ViewGroup, TransitionValues, int, TransitionValues, int)
|
||||
* appear()} if its parent hierarchy was stable between the start and end scenes.
|
||||
* This is done to avoid causing a visibility transition on every node in a hierarchy
|
||||
* when only the top-most node is the one that should be transitioned in/out.
|
||||
@@ -75,11 +73,20 @@ public abstract class Visibility extends Transition {
|
||||
return sTransitionProperties;
|
||||
}
|
||||
|
||||
private void captureValues(TransitionValues transitionValues) {
|
||||
int visibility = transitionValues.view.getVisibility();
|
||||
transitionValues.values.put(PROPNAME_VISIBILITY, visibility);
|
||||
transitionValues.values.put(PROPNAME_PARENT, transitionValues.view.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void captureValues(TransitionValues values, boolean start) {
|
||||
int visibility = values.view.getVisibility();
|
||||
values.values.put(PROPNAME_VISIBILITY, visibility);
|
||||
values.values.put(PROPNAME_PARENT, values.view.getParent());
|
||||
public void captureStartValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(TransitionValues transitionValues) {
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +94,7 @@ public abstract class Visibility extends Transition {
|
||||
* object. This is determined by testing the same properties in the values
|
||||
* object that are used to determine whether the object is appearing or
|
||||
* disappearing in the {@link
|
||||
* #play(android.view.ViewGroup, TransitionValues, TransitionValues)}
|
||||
* Transition#createAnimator(ViewGroup, TransitionValues, TransitionValues)}
|
||||
* method. This method can be called by, for example, subclasses that want
|
||||
* to know whether the object is visible in the same way that Visibility
|
||||
* determines it for the actual animation.
|
||||
@@ -207,14 +214,14 @@ public abstract class Visibility extends Transition {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Animator play(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
VisibilityInfo visInfo = getVisibilityChangeInfo(startValues, endValues);
|
||||
if (visInfo.visibilityChange) {
|
||||
// Only transition views that are either targets of this transition
|
||||
// or whose parent hierarchies remain stable between scenes
|
||||
boolean isTarget = false;
|
||||
if (mTargets != null || mTargetIds != null) {
|
||||
if (mTargets.size() > 0 || mTargetIds.size() > 0) {
|
||||
View startView = startValues != null ? startValues.view : null;
|
||||
View endView = endValues != null ? endValues.view : null;
|
||||
int startId = startView != null ? startView.getId() : -1;
|
||||
@@ -225,10 +232,10 @@ public abstract class Visibility extends Transition {
|
||||
!isHierarchyVisibilityChanging(sceneRoot,
|
||||
visInfo.startParent, visInfo.endParent))) {
|
||||
if (visInfo.fadeIn) {
|
||||
return appear(sceneRoot, startValues, visInfo.startVisibility,
|
||||
return onAppear(sceneRoot, startValues, visInfo.startVisibility,
|
||||
endValues, visInfo.endVisibility);
|
||||
} else {
|
||||
return disappear(sceneRoot, startValues, visInfo.startVisibility,
|
||||
return onDisappear(sceneRoot, startValues, visInfo.startVisibility,
|
||||
endValues, visInfo.endVisibility
|
||||
);
|
||||
}
|
||||
@@ -239,17 +246,20 @@ public abstract class Visibility extends Transition {
|
||||
|
||||
/**
|
||||
* The default implementation of this method does nothing. Subclasses
|
||||
* should override if they need to set up anything prior to the
|
||||
* transition starting.
|
||||
* should override if they need to create an Animator when targets appear.
|
||||
* The method should only be called by the Visibility class; it is
|
||||
* not intended to be called from external classes.
|
||||
*
|
||||
* @param sceneRoot
|
||||
* @param startValues
|
||||
* @param startVisibility
|
||||
* @param endValues
|
||||
* @param endVisibility
|
||||
* @return
|
||||
* @param sceneRoot The root of the transition hierarchy
|
||||
* @param startValues The target values in the start scene
|
||||
* @param startVisibility The target visibility in the start scene
|
||||
* @param endValues The target values in the end scene
|
||||
* @param endVisibility The target visibility in the end scene
|
||||
* @return An Animator to be started at the appropriate time in the
|
||||
* overall transition for this scene change. A null value means no animation
|
||||
* should be run.
|
||||
*/
|
||||
protected Animator appear(ViewGroup sceneRoot,
|
||||
public Animator onAppear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
return null;
|
||||
@@ -257,17 +267,21 @@ public abstract class Visibility extends Transition {
|
||||
|
||||
/**
|
||||
* The default implementation of this method does nothing. Subclasses
|
||||
* should override if they need to set up anything prior to the
|
||||
* transition starting.
|
||||
* should override if they need to create an Animator when targets disappear.
|
||||
* The method should only be called by the Visibility class; it is
|
||||
* not intended to be called from external classes.
|
||||
*
|
||||
* @param sceneRoot
|
||||
* @param startValues
|
||||
* @param startVisibility
|
||||
* @param endValues
|
||||
* @param endVisibility
|
||||
* @return
|
||||
*
|
||||
* @param sceneRoot The root of the transition hierarchy
|
||||
* @param startValues The target values in the start scene
|
||||
* @param startVisibility The target visibility in the start scene
|
||||
* @param endValues The target values in the end scene
|
||||
* @param endVisibility The target visibility in the end scene
|
||||
* @return An Animator to be started at the appropriate time in the
|
||||
* overall transition for this scene change. A null value means no animation
|
||||
* should be run.
|
||||
*/
|
||||
protected Animator disappear(ViewGroup sceneRoot,
|
||||
public Animator onDisappear(ViewGroup sceneRoot,
|
||||
TransitionValues startValues, int startVisibility,
|
||||
TransitionValues endValues, int endVisibility) {
|
||||
return null;
|
||||
@@ -3,15 +3,15 @@
|
||||
<p>The classes in this package enable "scenes & transitions" functionality for
|
||||
view hiearchies.</p>
|
||||
|
||||
<p>A <b>Scene</b> is an encapsulation of the state of a view hiearchy,
|
||||
<p>A <b>Scene</b> is an encapsulation of the state of a view hierarchy,
|
||||
including the views in that hierarchy and the various values (layout-related
|
||||
and otherwise) that those views have. A scene be defined by a layout hierarchy
|
||||
directly or some code which sets up the scene dynamically as it is entered.</p>
|
||||
and otherwise) that those views have. A scene can be defined by a layout hierarchy
|
||||
directly or by code which sets up the scene dynamically as it is entered.</p>
|
||||
|
||||
<p>A <b>Transition</b> is a mechanism to automatically animate changes that occur
|
||||
when a new scene is entered. Some transition capabilities are automatic. That
|
||||
is, entering a scene may cause animations to run which fade out views that
|
||||
go away, move and resize existing views that change, and fade in views that
|
||||
go away, changeBounds and resize existing views that change, and fade in views that
|
||||
become visible. There are additional transitions that can animate other
|
||||
attributes, such as color changes, and which can optionally be specified
|
||||
to take place during particular scene changes. Finally, developers can
|
||||
@@ -19,7 +19,8 @@ define their own Transition subclasses which monitor particular property
|
||||
changes and which run custom animations when those properties change values.</p>
|
||||
|
||||
<p><b>TransitionManager</b> is used to specify custom transitions for particular
|
||||
scene changes, and to cause scene changes with transitions to take place.</p>
|
||||
scene changes, and to cause scene changes with specific transitions to
|
||||
take place.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -74,7 +74,6 @@ import android.view.animation.Transformation;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.transition.Scene;
|
||||
import android.widget.ScrollBarDrawable;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.*;
|
||||
@@ -1575,8 +1574,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
protected Object mTag;
|
||||
|
||||
private Scene mCurrentScene = null;
|
||||
|
||||
// for mPrivateFlags:
|
||||
/** {@hide} */
|
||||
static final int PFLAG_WANTS_FOCUS = 0x00000001;
|
||||
@@ -12189,7 +12186,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
cleanupDraw();
|
||||
|
||||
mCurrentAnimation = null;
|
||||
mCurrentScene = null;
|
||||
}
|
||||
|
||||
private void cleanupDraw() {
|
||||
@@ -18101,31 +18097,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
return mAnimator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current Scene that this view is in. The current scene is set only
|
||||
* on the root view of a scene, not for every view in that hierarchy. This
|
||||
* information is used by Scene to determine whether there is a previous
|
||||
* scene which should be exited before the new scene is entered.
|
||||
*
|
||||
* @param scene The new scene being set on the view
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setCurrentScene(Scene scene) {
|
||||
mCurrentScene = scene;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current {@link Scene} set on this view. A scene is set on a view
|
||||
* only if that view is the scene root.
|
||||
*
|
||||
* @return The current Scene set on this view. A value of null indicates that
|
||||
* no Scene is current set.
|
||||
*/
|
||||
public Scene getCurrentScene() {
|
||||
return mCurrentScene;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when a hardware key event is
|
||||
* dispatched to this view. The callback will be invoked before the key event is
|
||||
|
||||
@@ -4511,24 +4511,71 @@
|
||||
</declare-styleable>
|
||||
|
||||
<!-- ========================== -->
|
||||
<!-- State class attributes -->
|
||||
<!-- Transition attributes -->
|
||||
<!-- ========================== -->
|
||||
<eat-comment />
|
||||
|
||||
<declare-styleable name="Scene">
|
||||
<attr name="layout" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Use specific transition subclass names as the root tag of the XML resource that
|
||||
describes a {@link android.transition.Transition Transition},
|
||||
such as <code>move</code>, <code>fade</code>, and <code>set</code>. -->
|
||||
<declare-styleable name="Transition">
|
||||
<!-- Amount of time (in milliseconds) that the transition should run. -->
|
||||
<attr name="duration" />
|
||||
<attr name="startOffset" />
|
||||
<!-- Delay in milliseconds before the transition starts. -->
|
||||
<attr name="startDelay" format="integer" />
|
||||
<!-- Interpolator to be used in the animations spawned by this transition. -->
|
||||
<attr name="interpolator" />
|
||||
<attr name="targetID" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Use <code>fade</code>as the root tag of the XML resource that
|
||||
describes a {@link android.transition.Fade Fade} transition.
|
||||
The attributes of the {@link android.R.styleable#Transition Transition}
|
||||
resource are available in addition to the specific attributes of Fade
|
||||
described here. -->
|
||||
<declare-styleable name="Fade">
|
||||
<attr name="fadingMode">
|
||||
<!-- Fade will only fade appearing items in. -->
|
||||
<enum name="fade_in" value="1" />
|
||||
<!-- Fade will only fade disappearing items out. -->
|
||||
<enum name="fade_out" value="2" />
|
||||
<!-- Fade will fade appearing items in and disappearing items out. -->
|
||||
<enum name="fade_in_out" value="3" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Use <code>target</code> as the root tag of the XML resource that
|
||||
describes a {@link android.transition.Transition#addTargetId(int)
|
||||
targetId} of a transition. There can be one or more targets inside
|
||||
a <code>targets</code> tag, which is itself inside an appropriate
|
||||
{@link android.R.styleable#Transition Transition} tag.
|
||||
-->
|
||||
<declare-styleable name="TransitionTarget">
|
||||
<!-- The id of a target on which this transition will animate changes. -->
|
||||
<attr name="targetId" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Use <code>set</code> as the root tag of the XML resource that
|
||||
describes a {@link android.transition.TransitionSet
|
||||
TransitionSet} transition. -->
|
||||
<declare-styleable name="TransitionSet">
|
||||
<attr name="transitionOrdering">
|
||||
<!-- child transitions should be played together. -->
|
||||
<enum name="together" value="0" />
|
||||
<!-- child transitions should be played sequentially, in the same order
|
||||
as the xml. -->
|
||||
<enum name="sequential" value="1" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Use <code>transitionManager</code> as the root tag of the XML resource that
|
||||
describes a {@link android.transition.TransitionManager
|
||||
TransitionManager}. -->
|
||||
<declare-styleable name="TransitionManager">
|
||||
<!-- The id of a transition to be used in a particular scene change. -->
|
||||
<attr name="transition" format="reference" />
|
||||
<!-- The originating scene in this scene change. -->
|
||||
<attr name="fromScene" format="reference" />
|
||||
<!-- The destination scene in this scene change. -->
|
||||
<attr name="toScene" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
|
||||
@@ -80,4 +80,5 @@
|
||||
<item type="id" name="overflow_menu_presenter" />
|
||||
<item type="id" name="popup_submenu_presenter" />
|
||||
<item type="id" name="action_bar_spinner" />
|
||||
<item type="id" name="current_scene" />
|
||||
</resources>
|
||||
|
||||
@@ -2059,10 +2059,13 @@
|
||||
<eat-comment />
|
||||
|
||||
<public type="attr" name="keyset" />
|
||||
<public type="attr" name="targetID" />
|
||||
<public type="attr" name="targetId" />
|
||||
<public type="attr" name="fromScene" />
|
||||
<public type="attr" name="toScene" />
|
||||
<public type="attr" name="transition" />
|
||||
<public type="attr" name="transitionOrdering" />
|
||||
<public type="attr" name="fadingMode" />
|
||||
<public type="attr" name="startDelay" />
|
||||
<public type="attr" name="ssp" />
|
||||
<public type="attr" name="sspPrefix" />
|
||||
<public type="attr" name="sspPattern" />
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<java-symbol type="id" name="characterPicker" />
|
||||
<java-symbol type="id" name="clearDefaultHint" />
|
||||
<java-symbol type="id" name="contentPanel" />
|
||||
<java-symbol type="id" name="current_scene" />
|
||||
<java-symbol type="id" name="customPanel" />
|
||||
<java-symbol type="id" name="datePicker" />
|
||||
<java-symbol type="id" name="day" />
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/incorrect_password"/>
|
||||
@@ -1,2 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/activity_login"/>
|
||||
@@ -1,2 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/new_user"/>
|
||||
@@ -1,2 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/login_password"/>
|
||||
@@ -1,3 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/results_screen">
|
||||
</scene>
|
||||
@@ -1,3 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/search_screen">
|
||||
</scene>
|
||||
@@ -1,2 +0,0 @@
|
||||
<scene xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout="@layout/success"/>
|
||||
@@ -1,6 +1,6 @@
|
||||
<recolor xmlns:android="http://schemas.android.com/apk/res/android">>
|
||||
<recolor xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<targets>
|
||||
<target android:targetID="@id/password"/>
|
||||
<target android:targetID="@id/passwordEdit"/>
|
||||
<target android:targetId="@id/password"/>
|
||||
<target android:targetId="@id/passwordEdit"/>
|
||||
</targets>
|
||||
</recolor>
|
||||
@@ -1,21 +1,21 @@
|
||||
<transitionGroup xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<slide>
|
||||
<targets>
|
||||
<target android:targetID="@id/retype"/>
|
||||
<target android:targetID="@id/retypeEdit"/>
|
||||
<target android:targetId="@id/retype"/>
|
||||
<target android:targetId="@id/retypeEdit"/>
|
||||
</targets>
|
||||
</slide>
|
||||
<recolor>
|
||||
<targets>
|
||||
<target android:targetID="@id/password"/>
|
||||
<target android:targetID="@id/passwordEdit"/>
|
||||
<target android:targetId="@id/password"/>
|
||||
<target android:targetId="@id/passwordEdit"/>
|
||||
</targets>
|
||||
</recolor>
|
||||
<fade/>
|
||||
</transitionGroup>
|
||||
</transitionSet>
|
||||
|
||||
<!--
|
||||
TransitionGroup slider = new TransitionGroup();
|
||||
TransitionSet slider = new TransitionSet();
|
||||
slider.addTransition(new Slide(R.id.retype, R.id.retypeEdit));
|
||||
slider.addTransition(new Recolor(R.id.password, R.id.passwordEdit));
|
||||
slider.addTransition(new Fade());
|
||||
|
||||
@@ -1,39 +1,14 @@
|
||||
<transitionManager xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<transition fromScene="@scene/login_scene" toScene="@scene/new_user_scene"
|
||||
transition="@transition/login_slider_transition"/>
|
||||
<transition fromScene="@scene/password_scene" toScene="@scene/new_user_scene"
|
||||
transition="@transition/login_slider_transition"/>
|
||||
<transition fromScene="@scene/new_user_scene" toScene="@scene/login_scene"
|
||||
transition="@transition/login_slider_transition"/>
|
||||
<transition fromScene="@scene/new_user_scene" toScene="@scene/password_scene"
|
||||
transition="@transition/login_slider_transition"/>
|
||||
<transition fromScene="@scene/login_scene" toScene="@scene/password_scene"
|
||||
transition="@transition/colorizer_transition"/>
|
||||
<transition fromScene="@scene/password_scene" toScene="@scene/login_scene"
|
||||
transition="@transition/colorizer_transition"/>
|
||||
<transition android:fromScene="@layout/activity_login" android:toScene="@layout/new_user"
|
||||
android:transition="@transition/login_slider_transition"/>
|
||||
<transition android:fromScene="@layout/login_password" android:toScene="@layout/new_user"
|
||||
android:transition="@transition/login_slider_transition"/>
|
||||
<transition android:fromScene="@layout/new_user" android:toScene="@layout/activity_login"
|
||||
android:transition="@transition/login_slider_transition"/>
|
||||
<transition android:fromScene="@layout/new_user" android:toScene="@layout/login_password"
|
||||
android:transition="@transition/login_slider_transition"/>
|
||||
<transition android:fromScene="@layout/activity_login" android:toScene="@layout/login_password"
|
||||
android:transition="@transition/colorizer_transition"/>
|
||||
<transition android:fromScene="@layout/login_password" android:toScene="@layout/activity_login"
|
||||
android:transition="@transition/colorizer_transition"/>
|
||||
</transitionManager>
|
||||
|
||||
<!--
|
||||
mLoginScene = new Scene(this, mSceneRoot, R.layout.activity_login);
|
||||
mPasswordScene = new Scene(this, mSceneRoot, R.layout.login_password);
|
||||
mIncorrectPasswordScene = new Scene(this, mSceneRoot, R.layout.incorrect_password);
|
||||
mUsernameTakenScene = new Scene(this, mSceneRoot, R.layout.username_taken);
|
||||
mSuccessScene = new Scene(this, mSceneRoot, R.layout.success);
|
||||
mNewUserScene = new Scene(this, mSceneRoot, R.layout.new_user);
|
||||
|
||||
mTransitionManager = new TransitionManager();
|
||||
// Custom transitions in/out of NewUser screen - slide in the 2nd password UI
|
||||
TransitionGroup slider = new TransitionGroup();
|
||||
slider.addTransition(new Slide(R.id.retype, R.id.retypeEdit));
|
||||
slider.addTransition(new Recolor(R.id.password, R.id.passwordEdit));
|
||||
slider.addTransition(new Fade());
|
||||
mTransitionManager.setTransition(mLoginScene, mNewUserScene, slider);
|
||||
mTransitionManager.setTransition(mPasswordScene, mNewUserScene, slider);
|
||||
mTransitionManager.setTransition(mNewUserScene, mLoginScene, slider);
|
||||
mTransitionManager.setTransition(mNewUserScene, mPasswordScene, slider);
|
||||
|
||||
// Custom transitions with recoloring password field
|
||||
Transition colorizer = new Recolor(R.id.password, R.id.passwordEdit);
|
||||
mTransitionManager.setTransition(mLoginScene, mPasswordScene, colorizer);
|
||||
mTransitionManager.setTransition(mPasswordScene, mLoginScene, colorizer);
|
||||
-->
|
||||
@@ -1 +1 @@
|
||||
<move/>
|
||||
<changeBounds/>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<transitionGroup xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<fade/>
|
||||
<move/>
|
||||
</transitionGroup>
|
||||
<changeBounds/>
|
||||
</transitionSet>
|
||||
@@ -1,20 +1,20 @@
|
||||
<transitionGroup xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<fade></fade>
|
||||
<transitionGroup>
|
||||
<move android:duration="500">
|
||||
<transitionSet>
|
||||
<changeBounds android:duration="500">
|
||||
<targets>
|
||||
<target android:targetID="@id/container"/>
|
||||
<target android:targetID="@id/resultsList"/>
|
||||
<target android:targetId="@id/container"/>
|
||||
<target android:targetId="@id/resultsList"/>
|
||||
</targets>
|
||||
</move>
|
||||
<transitionGroup>
|
||||
</changeBounds>
|
||||
<transitionSet>
|
||||
<targets>
|
||||
<target android:targetID="@id/container"/>
|
||||
<target android:targetID="@id/resultsList"/>
|
||||
<target android:targetId="@id/container"/>
|
||||
<target android:targetId="@id/resultsList"/>
|
||||
</targets>
|
||||
<fade android:startOffset="25"/>
|
||||
</transitionGroup>
|
||||
</transitionSet>
|
||||
<recolor/>
|
||||
</transitionGroup>
|
||||
<move/>
|
||||
</transitionGroup>
|
||||
</transitionSet>
|
||||
<changeBounds/>
|
||||
</transitionSet>
|
||||
@@ -1,6 +1,6 @@
|
||||
<transitionManager xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<transition fromScene="@scene/search_scene" toScene="@scene/results_scene"
|
||||
transition="@transition/mover_fader"/>
|
||||
<transition fromScene="@scene/results_scene" toScene="@scene/search_scene"
|
||||
transition="@transition/mover_fader"/>
|
||||
<transition android:fromScene="@layout/search_screen" android:toScene="@layout/results_screen"
|
||||
android:transition="@transition/mover_fader"/>
|
||||
<transition android:fromScene="@layout/results_screen" android:toScene="@layout/search_screen"
|
||||
android:transition="@transition/mover_fader"/>
|
||||
</transitionManager>
|
||||
@@ -19,42 +19,43 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.widget.Button;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.TextChange;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.TextChange;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
public class ChangingText extends Activity {
|
||||
|
||||
Scene mScene1, mScene2;
|
||||
ViewGroup mSceneRoot;
|
||||
TransitionGroup mChanger;
|
||||
TransitionSet mChanger;
|
||||
Scene mCurrentScene;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.changing_text_1);
|
||||
|
||||
View container = (View) findViewById(R.id.container);
|
||||
View container = findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.changing_text_1, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.changing_text_2, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_1, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_2, this);
|
||||
|
||||
mChanger = new TransitionGroup(TransitionGroup.TOGETHER);
|
||||
mChanger.addTransitions(new Move(), new TextChange());
|
||||
mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
|
||||
mChanger.addTransition(new ChangeBounds()).addTransition(new TextChange());
|
||||
|
||||
mSceneRoot.setCurrentScene(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
if (mSceneRoot.getCurrentScene() == mScene1) {
|
||||
if (mCurrentScene == mScene1) {
|
||||
TransitionManager.go(mScene2, mChanger);
|
||||
mCurrentScene = mScene2;
|
||||
} else {
|
||||
TransitionManager.go(mScene1, mChanger);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.transition.Scene;
|
||||
import android.widget.Button;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.TextChange;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.TextChange;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
public class ClippingText extends Activity {
|
||||
|
||||
@@ -34,7 +34,8 @@ public class ClippingText extends Activity {
|
||||
ViewGroup mSceneRoot;
|
||||
// static Fade sFade = new Fade(R.id.removingButton, R.id.invisibleButton, R.id.goneButton);
|
||||
Fade fader;
|
||||
TransitionGroup mChanger;
|
||||
TransitionSet mChanger;
|
||||
Scene mCurrentScene;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -44,22 +45,24 @@ public class ClippingText extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.clipping_text_1, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.clipping_text_2, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_1, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_2, this);
|
||||
|
||||
mChanger = new TransitionGroup(TransitionGroup.TOGETHER);
|
||||
Move move = new Move();
|
||||
move.setResizeClip(true);
|
||||
mChanger.addTransitions(move, new TextChange());
|
||||
mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
|
||||
ChangeBounds changeBounds = new ChangeBounds();
|
||||
changeBounds.setResizeClip(true);
|
||||
mChanger.addTransition(changeBounds).addTransition(new TextChange());
|
||||
|
||||
mSceneRoot.setCurrentScene(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
if (mSceneRoot.getCurrentScene() == mScene1) {
|
||||
if (mCurrentScene == mScene1) {
|
||||
TransitionManager.go(mScene2, mChanger);
|
||||
mCurrentScene = mScene2;
|
||||
} else {
|
||||
TransitionManager.go(mScene1, mChanger);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,19 @@ package com.android.transitiontests;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.Transition;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.view.transition.Crossfade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Rotate;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Crossfade;
|
||||
import android.transition.Rotate;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
public class ContactsExpansion extends Activity {
|
||||
|
||||
@@ -42,7 +42,8 @@ public class ContactsExpansion extends Activity {
|
||||
|
||||
View currentItem = null;
|
||||
|
||||
TransitionGroup mMyAutoTransition = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
TransitionSet mMyAutoTransition = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -73,11 +74,12 @@ public class ContactsExpansion extends Activity {
|
||||
((TextView)contactItem.findViewById(R.id.contact_email)).setText(contactsData[dataIndex++]);
|
||||
container.addView(contactItem);
|
||||
|
||||
final TransitionGroup myTransition = new TransitionGroup();
|
||||
myTransition.addTransitions(new Fade(Fade.IN),
|
||||
new Rotate().setTargetIds(R.id.contact_arrow),
|
||||
new Move(), new Fade(Fade.OUT),
|
||||
new Crossfade().setTargetIds(R.id.contact_picture));
|
||||
final TransitionSet myTransition = new TransitionSet();
|
||||
myTransition.addTransition(new Fade(Fade.IN)).
|
||||
addTransition(new Rotate().addTargetId(R.id.contact_arrow)).
|
||||
addTransition(new ChangeBounds()).
|
||||
addTransition(new Fade(Fade.OUT)).
|
||||
addTransition(new Crossfade().addTargetId(R.id.contact_picture));
|
||||
final ToggleScene toggleScene = new ToggleScene(container, myTransition);
|
||||
contactItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -17,13 +17,13 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Crossfade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Crossfade;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class CrossFadeDemo extends Activity {
|
||||
@@ -41,16 +41,17 @@ public class CrossFadeDemo extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.crossfade, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.crossfade_1, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.crossfade, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.crossfade_1, this);
|
||||
|
||||
Crossfade crossfade = new Crossfade();
|
||||
crossfade.setFadeBehavior(Crossfade.FADE_BEHAVIOR_CROSSFADE);
|
||||
crossfade.setResizeBehavior(Crossfade.RESIZE_BEHAVIOR_NONE);
|
||||
crossfade.setTargetIds(R.id.textview, R.id.textview1, R.id.textview2);
|
||||
crossfade.addTargetId(R.id.textview).addTargetId(R.id.textview1).
|
||||
addTargetId(R.id.textview2);
|
||||
mTransitionManager = new TransitionManager();
|
||||
TransitionGroup moveCrossFade = new TransitionGroup();
|
||||
moveCrossFade.addTransitions(crossfade, new Move());
|
||||
TransitionSet moveCrossFade = new TransitionSet();
|
||||
moveCrossFade.addTransition(crossfade).addTransition(new ChangeBounds());
|
||||
mTransitionManager.setTransition(mScene1, moveCrossFade);
|
||||
mTransitionManager.setTransition(mScene2, moveCrossFade);
|
||||
mCurrentScene = 1;
|
||||
|
||||
@@ -19,12 +19,12 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Crossfade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Crossfade;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class CrossfadeImage extends Activity {
|
||||
@@ -48,11 +48,11 @@ public class CrossfadeImage extends Activity {
|
||||
mImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
|
||||
Crossfade mCrossfade = new Crossfade();
|
||||
mCrossfade.setTargetIds(R.id.contact_picture);
|
||||
mCrossfade.addTargetId(R.id.contact_picture);
|
||||
|
||||
TransitionGroup group = new TransitionGroup();
|
||||
TransitionSet group = new TransitionSet();
|
||||
group.setDuration(1500);
|
||||
group.addTransitions(mCrossfade, new Move());
|
||||
group.addTransition(mCrossfade).addTransition(new ChangeBounds());
|
||||
mTransition = group;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Crossfade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.TextChange;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Crossfade;
|
||||
import android.transition.TextChange;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -40,9 +40,9 @@ public class CrossfadeMultiple extends Activity {
|
||||
TextView mTextView;
|
||||
Button mButton;
|
||||
Crossfade mCrossfade;
|
||||
TransitionGroup mCrossfadeGroup;
|
||||
TransitionGroup mTextChangeGroup1, mTextChangeGroup2;
|
||||
TransitionGroup mInOutGroup;
|
||||
TransitionSet mCrossfadeGroup;
|
||||
TransitionSet mTextChangeGroup1, mTextChangeGroup2;
|
||||
TransitionSet mInOutGroup;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -57,34 +57,35 @@ public class CrossfadeMultiple extends Activity {
|
||||
mTextView = (TextView) findViewById(R.id.textview);
|
||||
|
||||
mCrossfade = new Crossfade();
|
||||
mCrossfade.setTargetIds(R.id.button, R.id.textview, R.id.imageview);
|
||||
mCrossfade.addTargetId(R.id.button).addTargetId(R.id.textview).addTargetId(R.id.imageview);
|
||||
|
||||
mCrossfadeGroup = new TransitionGroup();
|
||||
mCrossfadeGroup = new TransitionSet();
|
||||
mCrossfadeGroup.setDuration(300);
|
||||
mCrossfadeGroup.addTransitions(mCrossfade, new Move());
|
||||
mCrossfadeGroup.addTransition(mCrossfade).addTransition(new ChangeBounds());
|
||||
mTransition = mCrossfadeGroup;
|
||||
|
||||
mInOutGroup = new TransitionGroup();
|
||||
mInOutGroup = new TransitionSet();
|
||||
Crossfade inOut = new Crossfade();
|
||||
inOut.setDuration(300);
|
||||
inOut.setFadeBehavior(Crossfade.FADE_BEHAVIOR_OUT_IN);
|
||||
Move move = new Move();
|
||||
move.setStartDelay(150);
|
||||
move.setDuration(0);
|
||||
mInOutGroup.addTransitions(inOut, move);
|
||||
ChangeBounds changeBounds = new ChangeBounds();
|
||||
changeBounds.setStartDelay(150);
|
||||
changeBounds.setDuration(0);
|
||||
mInOutGroup.addTransition(inOut).addTransition(changeBounds);
|
||||
|
||||
mTextChangeGroup1 = new TransitionGroup();
|
||||
mTextChangeGroup1 = new TransitionSet();
|
||||
TextChange textChangeInOut = new TextChange();
|
||||
textChangeInOut.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_OUT_IN);
|
||||
mTextChangeGroup1.addTransitions(textChangeInOut, new Move());
|
||||
mTextChangeGroup1.addTransition(textChangeInOut).addTransition(new ChangeBounds());
|
||||
|
||||
mTextChangeGroup2 = new TransitionGroup();
|
||||
mTextChangeGroup2.setOrdering(TransitionGroup.SEQUENTIALLY);
|
||||
mTextChangeGroup2 = new TransitionSet();
|
||||
mTextChangeGroup2.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
TextChange textChangeOut = new TextChange();
|
||||
textChangeOut.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_OUT);
|
||||
TextChange textChangeIn = new TextChange();
|
||||
textChangeIn.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_IN);
|
||||
mTextChangeGroup2.addTransitions(textChangeOut, new Move(), textChangeIn);
|
||||
mTextChangeGroup2.addTransition(textChangeOut).addTransition(new ChangeBounds()).
|
||||
addTransition(textChangeIn);
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import static android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
@@ -21,11 +21,11 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class Demo1 extends Activity {
|
||||
@@ -69,9 +69,10 @@ public class Demo1 extends Activity {
|
||||
public void sendMessage(View view) {
|
||||
if (mFirstTime) {
|
||||
mFirstTime = false;
|
||||
TransitionGroup transition = new TransitionGroup();
|
||||
transition.addTransitions(new Fade().setTargetIds(R.id.resultsText, R.id.resultsList),
|
||||
new Move().setTargetIds(R.id.searchContainer));
|
||||
TransitionSet transition = new TransitionSet();
|
||||
transition.addTransition(new Fade().addTargetId(R.id.resultsText).
|
||||
addTargetId(R.id.resultsList)).
|
||||
addTransition(new ChangeBounds().addTargetId(R.id.searchContainer));
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transition);
|
||||
mTransitionManager.setTransition(mResultsScreen, transition);
|
||||
|
||||
@@ -19,13 +19,12 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionInflater;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
public class Demo2 extends Activity {
|
||||
ViewGroup mSceneRoot;
|
||||
@@ -51,18 +50,17 @@ public class Demo2 extends Activity {
|
||||
// mSearchScreen = new Scene(this, mSceneRoot, R.layout.search_screen);
|
||||
// mResultsScreen = new Scene(this, mSceneRoot, R.layout.results_screen);
|
||||
try {
|
||||
mSearchScreen = TransitionInflater.from(this).
|
||||
inflateScene(R.scene.search_scene, mSceneRoot);
|
||||
mResultsScreen = TransitionInflater.from(this).
|
||||
inflateScene(R.scene.results_scene, mSceneRoot);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Problem loading scene resource: " + e);
|
||||
}
|
||||
|
||||
TransitionGroup transition = new TransitionGroup();
|
||||
transition.addTransitions(new Fade().setTargetIds(R.id.resultsText, R.id.resultsList),
|
||||
new Move().setTargetIds(R.id.searchContainer),
|
||||
new Recolor().setTargetIds(R.id.container));
|
||||
TransitionSet transition = new TransitionSet();
|
||||
transition.addTransition(new Fade().addTargetId(R.id.resultsText).
|
||||
addTargetId(R.id.resultsList)).
|
||||
addTransition(new ChangeBounds().addTargetId(R.id.searchContainer)).
|
||||
addTransition(new Recolor().addTargetId(R.id.container));
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transition);
|
||||
mTransitionManager.setTransition(mResultsScreen, transition);
|
||||
|
||||
@@ -17,14 +17,14 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class Demo3 extends Activity {
|
||||
@@ -41,11 +41,11 @@ public class Demo3 extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
|
||||
TransitionGroup transition = new TransitionGroup();
|
||||
transition.addTransitions(new Fade(), new Move(), new Recolor());
|
||||
TransitionSet transition = new TransitionSet();
|
||||
transition.addTransition(new Fade()).addTransition(new ChangeBounds()).addTransition(new Recolor());
|
||||
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transition);
|
||||
|
||||
@@ -17,14 +17,14 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class Demo4 extends Activity {
|
||||
@@ -41,20 +41,22 @@ public class Demo4 extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
|
||||
TransitionGroup transitionToResults = new TransitionGroup();
|
||||
TransitionSet transitionToResults = new TransitionSet();
|
||||
Fade fade = new Fade();
|
||||
fade.setTargetIds(R.id.resultsText, R.id.resultsList);
|
||||
fade.addTargetId(R.id.resultsText).addTargetId(R.id.resultsList);
|
||||
fade.setStartDelay(300);
|
||||
fade.setDuration(1000);
|
||||
transitionToResults.addTransitions(fade, new Move().setTargetIds(R.id.searchContainer),
|
||||
new Recolor().setTargetIds(R.id.container));
|
||||
transitionToResults.addTransition(fade).
|
||||
addTransition(new ChangeBounds().addTargetId(R.id.searchContainer)).
|
||||
addTransition(new Recolor().addTargetId(R.id.container));
|
||||
|
||||
TransitionGroup transitionToSearch = new TransitionGroup();
|
||||
transitionToSearch.addTransitions(fade, new Move().setTargetIds(R.id.searchContainer),
|
||||
new Recolor().setTargetIds(R.id.container));
|
||||
TransitionSet transitionToSearch = new TransitionSet();
|
||||
transitionToSearch.addTransition(fade).
|
||||
addTransition(new ChangeBounds().addTargetId(R.id.searchContainer)).
|
||||
addTransition(new Recolor().addTargetId(R.id.container));
|
||||
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transitionToSearch);
|
||||
|
||||
@@ -19,8 +19,8 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class Demo5 extends Activity {
|
||||
@@ -36,8 +36,8 @@ public class Demo5 extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
|
||||
public class FadingHierarchy extends Activity {
|
||||
|
||||
@@ -19,10 +19,10 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.transition.Scene;
|
||||
import android.widget.Button;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class FadingTest extends Activity {
|
||||
@@ -31,9 +31,11 @@ public class FadingTest extends Activity {
|
||||
Scene mScene1, mScene2;
|
||||
ViewGroup mSceneRoot;
|
||||
static Fade sFade = new Fade();
|
||||
Scene mCurrentScene;
|
||||
|
||||
static {
|
||||
sFade.setTargetIds(R.id.removingButton, R.id.invisibleButton, R.id.goneButton);
|
||||
sFade.addTargetId(R.id.removingButton).addTargetId(R.id.invisibleButton).
|
||||
addTargetId(R.id.goneButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,17 +58,19 @@ public class FadingTest extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.fading_test, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.fading_test_scene_2, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_scene_2, this);
|
||||
|
||||
mSceneRoot.setCurrentScene(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
if (mSceneRoot.getCurrentScene() == mScene1) {
|
||||
if (mCurrentScene == mScene1) {
|
||||
TransitionManager.go(mScene2);
|
||||
mCurrentScene = mScene2;
|
||||
} else {
|
||||
TransitionManager.go(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
|
||||
import static android.widget.LinearLayout.LayoutParams;
|
||||
@@ -59,33 +59,37 @@ public class HierarchicalMove extends Activity {
|
||||
// group (sequentially)
|
||||
// Move 3
|
||||
// Move 4/5
|
||||
TransitionGroup rootTransition = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
TransitionSet rootTransition = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
|
||||
// button0
|
||||
Transition move0 = new Move();
|
||||
move0.setTargets(buttons[0]);
|
||||
Transition move0 = new ChangeBounds();
|
||||
move0.addTarget(buttons[0]);
|
||||
|
||||
// buttons 1/2/3/4/5
|
||||
TransitionGroup group12345 = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
TransitionSet group12345 = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
|
||||
// buttons 1/2
|
||||
TransitionGroup group12 = new TransitionGroup(TransitionGroup.TOGETHER);
|
||||
Move move1 = new Move();
|
||||
move1.setTargets(buttons[1]);
|
||||
Move move2 = new Move();
|
||||
move2.setTargets(buttons[2]);
|
||||
group12.addTransitions(move1, move2);
|
||||
TransitionSet group12 = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_TOGETHER);
|
||||
ChangeBounds changeBounds1 = new ChangeBounds();
|
||||
changeBounds1.addTarget(buttons[1]);
|
||||
ChangeBounds changeBounds2 = new ChangeBounds();
|
||||
changeBounds2.addTarget(buttons[2]);
|
||||
group12.addTransition(changeBounds1).addTransition(changeBounds2);
|
||||
|
||||
TransitionGroup group345 = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
Move move3 = new Move();
|
||||
move3.setTargets(buttons[3]);
|
||||
Move move45 = new Move();
|
||||
move45.setTargets(buttons[4], buttons[5]);
|
||||
group345.addTransitions(move3, move45);
|
||||
TransitionSet group345 = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
ChangeBounds changeBounds3 = new ChangeBounds();
|
||||
changeBounds3.addTarget(buttons[3]);
|
||||
ChangeBounds changeBounds45 = new ChangeBounds();
|
||||
changeBounds45.addTarget(buttons[4]).addTarget(buttons[5]);
|
||||
group345.addTransition(changeBounds3).addTransition(changeBounds45);
|
||||
|
||||
group12345.addTransitions(move0, group12, group345);
|
||||
group12345.addTransition(move0).addTransition(group12).addTransition(group345);
|
||||
|
||||
rootTransition.addTransitions(group12345);
|
||||
rootTransition.addTransition(group12345);
|
||||
rootTransition.setDuration(1000);
|
||||
mTransition = rootTransition;
|
||||
|
||||
|
||||
@@ -16,16 +16,12 @@
|
||||
package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
|
||||
@@ -46,23 +42,19 @@ public class InstanceTargets extends Activity {
|
||||
}
|
||||
|
||||
public void sendMessage(final View view) {
|
||||
TransitionManager.go(mSceneRoot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < mSceneRoot.getChildCount(); ++i) {
|
||||
Button button = (Button) mSceneRoot.getChildAt(i);
|
||||
LayoutParams params = (LayoutParams) button.getLayoutParams();
|
||||
int rules[] = params.getRules();
|
||||
if (rules[ALIGN_PARENT_RIGHT] != 0) {
|
||||
params.removeRule(ALIGN_PARENT_RIGHT);
|
||||
params.addRule(ALIGN_PARENT_LEFT);
|
||||
} else {
|
||||
params.removeRule(ALIGN_PARENT_LEFT);
|
||||
params.addRule(ALIGN_PARENT_RIGHT);
|
||||
}
|
||||
button.setLayoutParams(params);
|
||||
}
|
||||
TransitionManager.beginDelayedTransition(mSceneRoot, new ChangeBounds().addTarget(view));
|
||||
for (int i = 0; i < mSceneRoot.getChildCount(); ++i) {
|
||||
Button button = (Button) mSceneRoot.getChildAt(i);
|
||||
LayoutParams params = (LayoutParams) button.getLayoutParams();
|
||||
int rules[] = params.getRules();
|
||||
if (rules[ALIGN_PARENT_RIGHT] != 0) {
|
||||
params.removeRule(ALIGN_PARENT_RIGHT);
|
||||
params.addRule(ALIGN_PARENT_LEFT);
|
||||
} else {
|
||||
params.removeRule(ALIGN_PARENT_LEFT);
|
||||
params.addRule(ALIGN_PARENT_RIGHT);
|
||||
}
|
||||
}, new Move().setTargets(view));
|
||||
button.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,12 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.AutoTransition;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TextChange;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
public class InterruptionTest extends Activity {
|
||||
@@ -35,7 +32,8 @@ public class InterruptionTest extends Activity {
|
||||
private Scene mScene2;
|
||||
private Scene mScene3;
|
||||
private Scene mScene4;
|
||||
TransitionGroup mSequencedMove = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
TransitionSet mSequencedMove = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -44,24 +42,22 @@ public class InterruptionTest extends Activity {
|
||||
|
||||
ViewGroup sceneRoot = (ViewGroup) findViewById(R.id.sceneRoot);
|
||||
|
||||
mScene1 = new Scene(sceneRoot, R.layout.interruption_inner_1, this);
|
||||
mScene2 = new Scene(sceneRoot, R.layout.interruption_inner_2, this);
|
||||
mScene3 = new Scene(sceneRoot, R.layout.interruption_inner_3, this);
|
||||
mScene4 = new Scene(sceneRoot, R.layout.interruption_inner_4, this);
|
||||
mScene1 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_1, this);
|
||||
mScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_2, this);
|
||||
mScene3 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_3, this);
|
||||
mScene4 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_4, this);
|
||||
|
||||
mScene1RB = (RadioButton) findViewById(R.id.scene1RB);
|
||||
mScene2RB = (RadioButton) findViewById(R.id.scene2RB);
|
||||
mScene3RB = (RadioButton) findViewById(R.id.scene3RB);
|
||||
mScene4RB = (RadioButton) findViewById(R.id.scene4RB);
|
||||
|
||||
sceneRoot.setCurrentScene(mScene1);
|
||||
ChangeBounds changeBounds1 = new ChangeBounds();
|
||||
changeBounds1.addTargetId(R.id.button);
|
||||
ChangeBounds changeBounds2 = new ChangeBounds();
|
||||
changeBounds2.addTargetId(R.id.button1);
|
||||
|
||||
Move move1 = new Move();
|
||||
move1.setTargetIds(R.id.button);
|
||||
Move move2 = new Move();
|
||||
move2.setTargetIds(R.id.button1);
|
||||
|
||||
mSequencedMove.addTransitions(move1, move2);
|
||||
mSequencedMove.addTransition(changeBounds1).addTransition(changeBounds2);
|
||||
mSequencedMove.setDuration(1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,18 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Scene;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Scene;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.view.transition.AutoTransition;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.AutoTransition;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -78,10 +78,11 @@ public class ListViewAddRemove extends Activity {
|
||||
}
|
||||
});
|
||||
final Transition myTransition = new AutoTransition();
|
||||
final TransitionGroup noFadeIn = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
final TransitionSet noFadeIn = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
Fade fadeIn = new Fade(Fade.IN);
|
||||
fadeIn.setDuration(50);
|
||||
noFadeIn.addTransitions(new Fade(Fade.OUT), new Move(), fadeIn);
|
||||
noFadeIn.addTransition(new Fade(Fade.OUT)).addTransition(new ChangeBounds()).addTransition(fadeIn);
|
||||
|
||||
myTransition.addListener(new Transition.TransitionListenerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -19,14 +19,14 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.transition.Scene;
|
||||
import android.widget.TextView;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Slide;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Slide;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class LoginActivity extends Activity {
|
||||
@@ -43,32 +43,33 @@ public class LoginActivity extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mLoginScene = new Scene(mSceneRoot, R.layout.activity_login, this);
|
||||
mPasswordScene = new Scene(mSceneRoot, R.layout.login_password, this);
|
||||
mIncorrectPasswordScene = new Scene(mSceneRoot, R.layout.incorrect_password, this);
|
||||
mUsernameTakenScene = new Scene(mSceneRoot, R.layout.username_taken, this);
|
||||
mSuccessScene = new Scene(mSceneRoot, R.layout.success, this);
|
||||
mNewUserScene = new Scene(mSceneRoot, R.layout.new_user, this);
|
||||
mLoginScene = Scene.getSceneForLayout(mSceneRoot, R.layout.activity_login, this);
|
||||
mPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.login_password, this);
|
||||
mIncorrectPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.incorrect_password, this);
|
||||
mUsernameTakenScene = Scene.getSceneForLayout(mSceneRoot, R.layout.username_taken, this);
|
||||
mSuccessScene = Scene.getSceneForLayout(mSceneRoot, R.layout.success, this);
|
||||
mNewUserScene = Scene.getSceneForLayout(mSceneRoot, R.layout.new_user, this);
|
||||
|
||||
mTransitionManager = new TransitionManager();
|
||||
|
||||
// Custom transitions in/out of NewUser screen - slide in the 2nd password UI
|
||||
TransitionGroup slider = new TransitionGroup();
|
||||
slider.addTransitions(new Slide().setTargetIds(R.id.retype, R.id.retypeEdit));
|
||||
slider.addTransitions(new Recolor().setTargetIds(R.id.password, R.id.passwordEdit));
|
||||
slider.addTransitions(new Fade());
|
||||
TransitionSet slider = new TransitionSet();
|
||||
slider.addTransition(new Slide().addTargetId(R.id.retype).addTargetId(R.id.retypeEdit));
|
||||
slider.addTransition(new Recolor().addTargetId(R.id.password).
|
||||
addTargetId(R.id.passwordEdit));
|
||||
slider.addTransition(new Fade());
|
||||
mTransitionManager.setTransition(mLoginScene, mNewUserScene, slider);
|
||||
mTransitionManager.setTransition(mPasswordScene, mNewUserScene, slider);
|
||||
mTransitionManager.setTransition(mNewUserScene, mLoginScene, slider);
|
||||
mTransitionManager.setTransition(mNewUserScene, mPasswordScene, slider);
|
||||
|
||||
// Custom transitions with recoloring password field
|
||||
Transition colorizer = new Recolor().setTargetIds(R.id.password, R.id.passwordEdit);
|
||||
Transition colorizer = new Recolor().addTargetId(R.id.password).
|
||||
addTargetId(R.id.passwordEdit);
|
||||
mTransitionManager.setTransition(mLoginScene, mPasswordScene, colorizer);
|
||||
mTransitionManager.setTransition(mPasswordScene, mLoginScene, colorizer);
|
||||
|
||||
mCurrentScene = mLoginScene;
|
||||
mSceneRoot.setCurrentScene(mLoginScene);
|
||||
}
|
||||
|
||||
public void applyScene(Scene scene) {
|
||||
|
||||
@@ -19,10 +19,10 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionInflater;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.widget.TextView;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class LoginActivityFromResources extends Activity {
|
||||
@@ -36,7 +36,7 @@ public class LoginActivityFromResources extends Activity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
View container = (View) findViewById(R.id.container);
|
||||
View container = findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
}
|
||||
@@ -50,21 +50,19 @@ public class LoginActivityFromResources extends Activity {
|
||||
if (mTransitionManager == null) {
|
||||
TransitionInflater inflater = TransitionInflater.from(this);
|
||||
|
||||
mLoginScene = inflater.inflateScene(R.scene.login_scene, mSceneRoot);
|
||||
mPasswordScene = inflater.inflateScene(R.scene.password_scene, mSceneRoot);
|
||||
mIncorrectPasswordScene =
|
||||
inflater.inflateScene(R.scene.incorrect_password_scene,mSceneRoot);
|
||||
mUsernameTakenScene =
|
||||
inflater.inflateScene(R.scene.username_taken_scene, mSceneRoot);
|
||||
mSuccessScene = inflater.inflateScene(R.scene.success_scene, mSceneRoot);
|
||||
mNewUserScene = inflater.inflateScene(R.scene.new_user_scene, mSceneRoot);
|
||||
mLoginScene = Scene.getSceneForLayout(mSceneRoot, R.layout.activity_login, this);
|
||||
mPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.login_password, this);
|
||||
mIncorrectPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout
|
||||
.incorrect_password, this);
|
||||
mUsernameTakenScene = Scene.getSceneForLayout(mSceneRoot, R.layout.username_taken, this);
|
||||
mSuccessScene = Scene.getSceneForLayout(mSceneRoot, R.layout.success, this);
|
||||
mNewUserScene = Scene.getSceneForLayout(mSceneRoot, R.layout.new_user, this);
|
||||
|
||||
mTransitionManager =
|
||||
inflater.inflateTransitionManager(R.transition.login_transition_mgr,
|
||||
mSceneRoot);
|
||||
|
||||
mCurrentScene = mLoginScene;
|
||||
mSceneRoot.setCurrentScene(mLoginScene);
|
||||
}
|
||||
TextView textView = (TextView) view;
|
||||
CharSequence text = textView.getText();
|
||||
|
||||
@@ -17,11 +17,11 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
|
||||
public class Reparenting extends Activity {
|
||||
@@ -67,7 +67,7 @@ public class Reparenting extends Activity {
|
||||
newParent.addView(v);
|
||||
}
|
||||
});
|
||||
Move reparent = new Move();
|
||||
ChangeBounds reparent = new ChangeBounds();
|
||||
reparent.setReparent(true);
|
||||
TransitionManager.go(newScene, reparent);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionInflater;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class ResourceLoadingTest extends Activity {
|
||||
@@ -54,7 +54,7 @@ public class ResourceLoadingTest extends Activity {
|
||||
mTransitionManager =
|
||||
inflater.inflateTransitionManager(R.transition.my_transition_mgr,
|
||||
mSceneRoot);
|
||||
Scene loadedScene = inflater.inflateScene(R.scene.my_scene, mSceneRoot);
|
||||
Scene loadedScene = new Scene(mSceneRoot);
|
||||
System.out.println("loadedScene = " + loadedScene);
|
||||
Transition loadedTransition = inflater.inflateTransition(R.transition.my_transition);
|
||||
System.out.println("loadedTransition = " + loadedTransition);
|
||||
@@ -63,11 +63,11 @@ public class ResourceLoadingTest extends Activity {
|
||||
}
|
||||
}
|
||||
if (mCurrentScene == RESULTS_SCREEN) {
|
||||
Scene scene = mInflater.inflateScene(R.scene.search_scene, mSceneRoot);
|
||||
Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mTransitionManager.transitionTo(scene);
|
||||
mCurrentScene = SEARCH_SCREEN;
|
||||
} else {
|
||||
Scene scene = mInflater.inflateScene(R.scene.results_scene, mSceneRoot);
|
||||
Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
mTransitionManager.transitionTo(scene);
|
||||
mCurrentScene = RESULTS_SCREEN;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class ScenesTestAutoTargets extends Activity {
|
||||
@@ -42,11 +42,11 @@ public class ScenesTestAutoTargets extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
|
||||
TransitionGroup transition = new TransitionGroup();
|
||||
transition.addTransitions(new Fade(), new Move(), new Recolor());
|
||||
TransitionSet transition = new TransitionSet();
|
||||
transition.addTransition(new Fade()).addTransition(new ChangeBounds()).addTransition(new Recolor());
|
||||
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transition);
|
||||
|
||||
@@ -20,10 +20,10 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.AutoTransition;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.AutoTransition;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class ScenesTestAutoTransition extends Activity {
|
||||
@@ -40,8 +40,8 @@ public class ScenesTestAutoTransition extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
|
||||
@@ -20,8 +20,8 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class ScenesTestAutoTransition2 extends Activity {
|
||||
@@ -38,8 +38,8 @@ public class ScenesTestAutoTransition2 extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
|
||||
@@ -18,14 +18,14 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Recolor;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Recolor;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class ScenesTestv21 extends Activity {
|
||||
@@ -42,21 +42,22 @@ public class ScenesTestv21 extends Activity {
|
||||
View container = (View) findViewById(R.id.container);
|
||||
mSceneRoot = (ViewGroup) container.getParent();
|
||||
|
||||
mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this);
|
||||
mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
|
||||
mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
|
||||
|
||||
TransitionGroup transitionToResults = new TransitionGroup();
|
||||
TransitionSet transitionToResults = new TransitionSet();
|
||||
Fade fade = new Fade();
|
||||
fade.setTargetIds(R.id.resultsText, R.id.resultsList);
|
||||
fade.addTargetId(R.id.resultsText).addTargetId(R.id.resultsList);
|
||||
fade.setStartDelay(300);
|
||||
transitionToResults.addTransitions(fade);
|
||||
transitionToResults.addTransitions(new Move().setTargetIds(R.id.searchContainer));
|
||||
transitionToResults.addTransitions(new Recolor().setTargetIds(R.id.container));
|
||||
transitionToResults.addTransition(fade);
|
||||
transitionToResults.addTransition(new ChangeBounds().addTargetId(R.id.searchContainer));
|
||||
transitionToResults.addTransition(new Recolor().addTargetId(R.id.container));
|
||||
|
||||
TransitionGroup transitionToSearch = new TransitionGroup();
|
||||
transitionToSearch.addTransitions(new Fade().setTargetIds(R.id.resultsText, R.id.resultsList));
|
||||
transitionToSearch.addTransitions(new Move().setTargetIds(R.id.searchContainer));
|
||||
transitionToSearch.addTransitions(new Recolor().setTargetIds(R.id.container));
|
||||
TransitionSet transitionToSearch = new TransitionSet();
|
||||
transitionToSearch.addTransition(new Fade().addTargetId(R.id.resultsText).
|
||||
addTargetId(R.id.resultsList));
|
||||
transitionToSearch.addTransition(new ChangeBounds().addTargetId(R.id.searchContainer));
|
||||
transitionToSearch.addTransition(new Recolor().addTargetId(R.id.container));
|
||||
mTransitionManager = new TransitionManager();
|
||||
mTransitionManager.setTransition(mSearchScreen, transitionToSearch);
|
||||
mTransitionManager.setTransition(mResultsScreen, transitionToResults);
|
||||
|
||||
@@ -19,13 +19,13 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.Transition;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionSet;
|
||||
import android.widget.Button;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class SequenceTest extends Activity {
|
||||
@@ -33,7 +33,8 @@ public class SequenceTest extends Activity {
|
||||
Button mRemovingButton, mInvisibleButton, mGoneButton;
|
||||
Scene mScene1, mScene2;
|
||||
ViewGroup mSceneRoot;
|
||||
TransitionGroup sequencedFade, reverseSequencedFade;
|
||||
TransitionSet sequencedFade, reverseSequencedFade;
|
||||
Scene mCurrentScene;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -47,27 +48,33 @@ public class SequenceTest extends Activity {
|
||||
mInvisibleButton = (Button) findViewById(R.id.invisibleButton);
|
||||
mGoneButton = (Button) findViewById(R.id.goneButton);
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.fading_test, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.fading_test_scene_2, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_scene_2, this);
|
||||
|
||||
Transition fade1 = new Fade().setTargetIds(R.id.removingButton);
|
||||
Transition fade2 = new Fade().setTargetIds(R.id.invisibleButton);
|
||||
Transition fade3 = new Fade().setTargetIds(R.id.goneButton);
|
||||
TransitionGroup fader = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
fader.addTransitions(fade1, fade2, fade3, new Move());
|
||||
Transition fade1 = new Fade().addTargetId(R.id.removingButton);
|
||||
Transition fade2 = new Fade().addTargetId(R.id.invisibleButton);
|
||||
Transition fade3 = new Fade().addTargetId(R.id.goneButton);
|
||||
TransitionSet fader = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
fader.addTransition(fade1).addTransition(fade2).addTransition(fade3).
|
||||
addTransition(new ChangeBounds());
|
||||
sequencedFade = fader;
|
||||
|
||||
reverseSequencedFade = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
reverseSequencedFade.addTransitions(new Move(), fade3, fade2, fade1);
|
||||
reverseSequencedFade = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
reverseSequencedFade.addTransition(new ChangeBounds()).addTransition(fade3).addTransition(fade2).
|
||||
addTransition(fade1);
|
||||
|
||||
mSceneRoot.setCurrentScene(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
if (mSceneRoot.getCurrentScene() == mScene1) {
|
||||
if (mCurrentScene == mScene1) {
|
||||
TransitionManager.go(mScene2, sequencedFade);
|
||||
mCurrentScene = mScene2;
|
||||
} else {
|
||||
TransitionManager.go(mScene1, reverseSequencedFade);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ package com.android.transitiontests;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.widget.Button;
|
||||
import android.view.transition.Fade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Transition;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
public class SequenceTestSimple extends Activity {
|
||||
@@ -34,7 +34,8 @@ public class SequenceTestSimple extends Activity {
|
||||
Scene mScene1, mScene2;
|
||||
ViewGroup mSceneRoot;
|
||||
Transition sequencedFade;
|
||||
TransitionGroup sequencedFadeReverse;
|
||||
TransitionSet sequencedFadeReverse;
|
||||
Scene mCurrentScene;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -46,25 +47,29 @@ public class SequenceTestSimple extends Activity {
|
||||
|
||||
mRemovingButton = (Button) findViewById(R.id.removingButton);
|
||||
|
||||
mScene1 = new Scene(mSceneRoot, R.layout.fading_test_simple, this);
|
||||
mScene2 = new Scene(mSceneRoot, R.layout.fading_test_simple2, this);
|
||||
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_simple, this);
|
||||
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_simple2, this);
|
||||
|
||||
TransitionGroup fader = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
fader.addTransitions(new Fade().setTargetIds(R.id.removingButton));
|
||||
fader.addTransitions(new Move().setTargetIds(R.id.sceneSwitchButton));
|
||||
TransitionSet fader = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
fader.addTransition(new Fade().addTargetId(R.id.removingButton));
|
||||
fader.addTransition(new ChangeBounds().addTargetId(R.id.sceneSwitchButton));
|
||||
sequencedFade = fader;
|
||||
|
||||
sequencedFadeReverse = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
|
||||
sequencedFadeReverse.addTransitions(new Move().setTargetIds(R.id.sceneSwitchButton));
|
||||
sequencedFadeReverse.addTransitions(new Fade().setTargetIds(R.id.removingButton));
|
||||
sequencedFadeReverse = new TransitionSet().
|
||||
setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
|
||||
sequencedFadeReverse.addTransition(new ChangeBounds().addTargetId(R.id.sceneSwitchButton));
|
||||
sequencedFadeReverse.addTransition(new Fade().addTargetId(R.id.removingButton));
|
||||
|
||||
mSceneRoot.setCurrentScene(mScene1);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
|
||||
public void sendMessage(View view) {
|
||||
if (mSceneRoot.getCurrentScene() == mScene1) {
|
||||
if (mCurrentScene == mScene1) {
|
||||
TransitionManager.go(mScene2, sequencedFade);
|
||||
mCurrentScene = mScene2;
|
||||
} else {
|
||||
TransitionManager.go(mScene1, sequencedFadeReverse);
|
||||
mCurrentScene = mScene1;
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -27,11 +27,11 @@ import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Crossfade;
|
||||
import android.view.transition.Move;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.TransitionGroup;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.Crossfade;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Scene;
|
||||
import android.transition.TransitionSet;
|
||||
import android.transition.TransitionManager;
|
||||
import android.widget.Button;
|
||||
|
||||
import static android.widget.LinearLayout.LayoutParams;
|
||||
@@ -66,8 +66,9 @@ public class SurfaceAndTextureViews extends Activity {
|
||||
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
|
||||
container.addView(mTextureView);
|
||||
|
||||
final TransitionGroup transition = new TransitionGroup();
|
||||
transition.addTransitions(new Move(), new Crossfade().setTargetIds(0, 1, 2));
|
||||
final TransitionSet transition = new TransitionSet();
|
||||
transition.addTransition(new ChangeBounds()).addTransition(new Crossfade().addTargetId(0).
|
||||
addTargetId(1).addTargetId(2));
|
||||
|
||||
toggleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -20,11 +20,11 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.transition.Scene;
|
||||
import android.view.transition.Transition;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.view.transition.TransitionManager;
|
||||
import android.transition.TransitionManager;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
bool isValidResourceType(const String8& type)
|
||||
{
|
||||
return type == "anim" || type == "animator" || type == "interpolator"
|
||||
|| type == "transition" || type == "scene"
|
||||
|| type == "transition"
|
||||
|| type == "drawable" || type == "layout"
|
||||
|| type == "values" || type == "xml" || type == "raw"
|
||||
|| type == "color" || type == "menu" || type == "mipmap";
|
||||
@@ -934,7 +934,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
sp<ResourceTypeSet> animators;
|
||||
sp<ResourceTypeSet> interpolators;
|
||||
sp<ResourceTypeSet> transitions;
|
||||
sp<ResourceTypeSet> scenes;
|
||||
sp<ResourceTypeSet> xmls;
|
||||
sp<ResourceTypeSet> raws;
|
||||
sp<ResourceTypeSet> colors;
|
||||
@@ -947,7 +946,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
ASSIGN_IT(animator);
|
||||
ASSIGN_IT(interpolator);
|
||||
ASSIGN_IT(transition);
|
||||
ASSIGN_IT(scene);
|
||||
ASSIGN_IT(xml);
|
||||
ASSIGN_IT(raw);
|
||||
ASSIGN_IT(color);
|
||||
@@ -971,7 +969,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
!applyFileOverlay(bundle, assets, &animators, "animator") ||
|
||||
!applyFileOverlay(bundle, assets, &interpolators, "interpolator") ||
|
||||
!applyFileOverlay(bundle, assets, &transitions, "transition") ||
|
||||
!applyFileOverlay(bundle, assets, &scenes, "scene") ||
|
||||
!applyFileOverlay(bundle, assets, &xmls, "xml") ||
|
||||
!applyFileOverlay(bundle, assets, &raws, "raw") ||
|
||||
!applyFileOverlay(bundle, assets, &colors, "color") ||
|
||||
@@ -1038,13 +1035,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
}
|
||||
}
|
||||
|
||||
if (scenes != NULL) {
|
||||
err = makeFileResources(bundle, assets, &table, scenes, "scene");
|
||||
if (err != NO_ERROR) {
|
||||
hasErrors = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (interpolators != NULL) {
|
||||
err = makeFileResources(bundle, assets, &table, interpolators, "interpolator");
|
||||
if (err != NO_ERROR) {
|
||||
@@ -1204,21 +1194,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
err = NO_ERROR;
|
||||
}
|
||||
|
||||
if (scenes != NULL) {
|
||||
ResourceDirIterator it(scenes, String8("scene"));
|
||||
while ((err=it.next()) == NO_ERROR) {
|
||||
err = compileXmlFile(assets, it.getFile(), &table, xmlFlags);
|
||||
if (err != NO_ERROR) {
|
||||
hasErrors = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (err < NO_ERROR) {
|
||||
hasErrors = true;
|
||||
}
|
||||
err = NO_ERROR;
|
||||
}
|
||||
|
||||
if (xmls != NULL) {
|
||||
ResourceDirIterator it(xmls, String8("xml"));
|
||||
while ((err=it.next()) == NO_ERROR) {
|
||||
|
||||
Reference in New Issue
Block a user