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 String[] sTransitionProperties = {
+ private static final String[] sTransitionProperties = {
PROPNAME_BOUNDS,
PROPNAME_PARENT,
PROPNAME_WINDOW_X,
*/
public static final int CHANGE_BEHAVIOR_OUT_IN = 3;
+ private static final String[] sTransitionProperties = {
+ PROPNAME_TEXT
+ };
+
/**
* Sets the type of changing animation that will be run, one of
* {@link #CHANGE_BEHAVIOR_KEEP} and {@link #CHANGE_BEHAVIOR_OUT_IN}.
}
@Override
+ public String[] getTransitionProperties() {
+ return sTransitionProperties;
+ }
+
+ @Override
protected void captureValues(TransitionValues values, boolean start) {
if (values.view instanceof TextView) {
TextView textview = (TextView) values.view;
final TextView view = (TextView) endValues.view;
Map<String, Object> startVals = startValues.values;
Map<String, Object> endVals = endValues.values;
- String startText = (String) startVals.get(PROPNAME_TEXT);
+ final String startText = (String) startVals.get(PROPNAME_TEXT);
final String endText = (String) endVals.get(PROPNAME_TEXT);
if (!startText.equals(endText)) {
view.setText(startText);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- view.setText(endText);
+ if (startText.equals(view.getText())) {
+ // Only set if it hasn't been changed since anim started
+ view.setText(endText);
+ }
}
});
} else {
outAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- view.setText(endText);
+ if (startText.equals(view.getText())) {
+ // Only set if it hasn't been changed since anim started
+ view.setText(endText);
+ }
}
});
}
anim = inAnim;
}
}
+ TransitionListener transitionListener = new TransitionListenerAdapter() {
+ boolean mCanceled = false;
+
+ @Override
+ public void onTransitionPause(Transition transition) {
+ view.setText(endText);
+ }
+
+ @Override
+ public void onTransitionResume(Transition transition) {
+ view.setText(startText);
+ }
+ };
+ addListener(transitionListener);
return anim;
}
return null;
for (int i = numOldAnims - 1; i >= 0; i--) {
Animator anim = runningAnimators.keyAt(i);
if (anim != null) {
- anim.resume();
AnimationInfo oldInfo = runningAnimators.get(anim);
if (oldInfo != null) {
boolean cancel = false;
View oldView = oldInfo.view;
TransitionValues newValues = mEndValues.viewValues != null ?
mEndValues.viewValues.get(oldView) : null;
- if (oldValues == null || newValues == null) {
- if (oldValues != null || newValues != null) {
+ if (oldValues != null) {
+ // if oldValues null, then transition didn't care to stash values,
+ // and won't get canceled
+ if (newValues == null) {
cancel = true;
- }
- } else {
- for (String key : oldValues.values.keySet()) {
- Object oldValue = oldValues.values.get(key);
- Object newValue = newValues.values.get(key);
- if ((oldValue == null && newValue != null) ||
- (oldValue != null && !oldValue.equals(newValue))) {
- cancel = true;
- if (DBG) {
- Log.d(LOG_TAG, "Transition.play: oldValue != newValue for " +
- key + ": old, new = " + oldValue + ", " + newValue);
+ } else {
+ for (String key : oldValues.values.keySet()) {
+ Object oldValue = oldValues.values.get(key);
+ Object newValue = newValues.values.get(key);
+ if (oldValue != null && newValue != null &&
+ !oldValue.equals(newValue)) {
+ cancel = true;
+ if (DBG) {
+ Log.d(LOG_TAG, "Transition.playTransition: " +
+ "oldValue != newValue for " + key +
+ ": old, new = " + oldValue + ", " + newValue);
+ }
+ break;
}
- break;
}
}
}
final ArrayMap<ViewGroup, ArrayList<Transition>> runningTransitions =
getRunningTransitions();
ArrayList<Transition> currentTransitions = runningTransitions.get(sceneRoot);
+ ArrayList<Transition> previousRunningTransitions = null;
if (currentTransitions == null) {
currentTransitions = new ArrayList<Transition>();
runningTransitions.put(sceneRoot, currentTransitions);
+ } else if (currentTransitions.size() > 0) {
+ previousRunningTransitions = new ArrayList<Transition>(currentTransitions);
}
currentTransitions.add(transition);
transition.addListener(new Transition.TransitionListenerAdapter() {
}
});
transition.captureValues(sceneRoot, false);
+ if (previousRunningTransitions != null) {
+ for (Transition runningTransition : previousRunningTransitions) {
+ runningTransition.resume();
+ }
+ }
transition.playTransition(sceneRoot);
// Returning false from onPreDraw() skips the current frame. This is
private static final String PROPNAME_VISIBILITY = "android:visibility:visibility";
private static final String PROPNAME_PARENT = "android:visibility:parent";
- private static String[] sTransitionProperties = {
+ private static final String[] sTransitionProperties = {
PROPNAME_VISIBILITY,
PROPNAME_PARENT,
};