Fix transition being canceled improperly.

Bug 18092208

When a transition is determining whether or not it should be
canceled, the old values and new values are compared. Previously,
the if a value was in the old values, but not in the new values
then the value was considered changed. This discounts that
transitions sometimes don't target views and it may be that
no value was populated.

Change-Id: I8210ba1e44921fadedf9ead571d380ad34e73d3f
This commit is contained in:
George Mount
2014-10-22 14:39:43 -07:00
parent f23b29ad5a
commit cba01b2310
2 changed files with 13 additions and 2 deletions

View File

@@ -1790,6 +1790,10 @@ public abstract class Transition implements Cloneable {
private static boolean isValueChanged(TransitionValues oldValues, TransitionValues newValues,
String key) {
if (oldValues.values.containsKey(key) != newValues.values.containsKey(key)) {
// The transition didn't care about this particular value, so we don't care, either.
return false;
}
Object oldValue = oldValues.values.get(key);
Object newValue = newValues.values.get(key);
boolean changed;

View File

@@ -484,12 +484,19 @@ public abstract class Visibility extends Transition {
@Override
boolean areValuesChanged(TransitionValues oldValues, TransitionValues newValues) {
VisibilityInfo changeInfo = getVisibilityChangeInfo(oldValues, newValues);
if (oldValues == null && newValues == null) {
return false;
}
if (oldValues != null && newValues != null &&
newValues.values.containsKey(PROPNAME_VISIBILITY) !=
oldValues.values.containsKey(PROPNAME_VISIBILITY)) {
// The transition wasn't targeted in either the start or end, so it couldn't
// have changed.
return false;
}
VisibilityInfo changeInfo = getVisibilityChangeInfo(oldValues, newValues);
return changeInfo.visibilityChange && (changeInfo.startVisibility == View.VISIBLE ||
changeInfo.endVisibility == View.VISIBLE);
changeInfo.endVisibility == View.VISIBLE);
}
/**