summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2014-06-17 10:14:39 -0700
committerGeorge Mount <mount@google.com>2014-06-18 11:13:06 -0700
commit4c20ea29728a80b42487b3ba1600d11d5ea47bcc (patch)
treec41b7386074db7fbe0e32abca35e53509abde4dd
parent6170cca05eb13cfb44c8d13e7a447cd24f27a62c (diff)
downloadframeworks_base-4c20ea29728a80b42487b3ba1600d11d5ea47bcc.zip
frameworks_base-4c20ea29728a80b42487b3ba1600d11d5ea47bcc.tar.gz
frameworks_base-4c20ea29728a80b42487b3ba1600d11d5ea47bcc.tar.bz2
Fix blinking animation during Visibility transitions.
Bug 15618501 Change-Id: I9dff9eb386a4bfb51caec24f3f7cc0fad06ae04c
-rw-r--r--core/java/android/transition/Transition.java52
-rw-r--r--core/java/android/transition/Visibility.java20
2 files changed, 39 insertions, 33 deletions
diff --git a/core/java/android/transition/Transition.java b/core/java/android/transition/Transition.java
index 508769d..e936232 100644
--- a/core/java/android/transition/Transition.java
+++ b/core/java/android/transition/Transition.java
@@ -673,7 +673,7 @@ public abstract class Transition implements Cloneable {
startDelays.put(mAnimators.size(), delay);
minStartDelay = Math.min(delay, minStartDelay);
}
- AnimationInfo info = new AnimationInfo(view, getName(),
+ AnimationInfo info = new AnimationInfo(view, getName(), this,
sceneRoot.getWindowId(), infoValues);
runningAnimators.put(animator, info);
mAnimators.add(animator);
@@ -1587,30 +1587,10 @@ public abstract class Transition implements Cloneable {
AnimationInfo oldInfo = runningAnimators.get(anim);
if (oldInfo != null && oldInfo.view != null &&
oldInfo.view.getContext() == sceneRoot.getContext()) {
- boolean cancel = false;
TransitionValues oldValues = oldInfo.values;
View oldView = oldInfo.view;
TransitionValues newValues = mEndValues.viewValues.get(oldView);
- if (oldValues != null) {
- // if oldValues null, then transition didn't care to stash values,
- // and won't get canceled
- if (newValues != null) {
- 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;
- }
- }
- }
- }
+ boolean cancel = oldInfo.transition.areValuesChanged(oldValues, newValues);
if (cancel) {
if (anim.isRunning() || anim.isStarted()) {
if (DBG) {
@@ -1632,6 +1612,29 @@ public abstract class Transition implements Cloneable {
runAnimators();
}
+ boolean areValuesChanged(TransitionValues oldValues, TransitionValues newValues) {
+ boolean valuesChanged = false;
+ // if oldValues null, then transition didn't care to stash values,
+ // and won't get canceled
+ if (oldValues != null && newValues != null) {
+ 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)) {
+ valuesChanged = true;
+ if (DBG) {
+ Log.d(LOG_TAG, "Transition.playTransition: " +
+ "oldValue != newValue for " + key +
+ ": old, new = " + oldValue + ", " + newValue);
+ }
+ break;
+ }
+ }
+ }
+ return valuesChanged;
+ }
+
/**
* This is a utility method used by subclasses to handle standard parts of
* setting up and running an Animator: it sets the {@link #getDuration()
@@ -2070,12 +2073,15 @@ public abstract class Transition implements Cloneable {
String name;
TransitionValues values;
WindowId windowId;
+ Transition transition;
- AnimationInfo(View view, String name, WindowId windowId, TransitionValues values) {
+ AnimationInfo(View view, String name, Transition transition,
+ WindowId windowId, TransitionValues values) {
this.view = view;
this.name = name;
this.values = values;
this.windowId = windowId;
+ this.transition = transition;
}
}
diff --git a/core/java/android/transition/Visibility.java b/core/java/android/transition/Visibility.java
index c6c8337..947e1a7 100644
--- a/core/java/android/transition/Visibility.java
+++ b/core/java/android/transition/Visibility.java
@@ -331,16 +331,6 @@ public abstract class Visibility extends Transition {
public void onAnimationEnd(Animator animation) {
finalSceneRoot.getOverlay().remove(finalOverlayView);
}
-
- @Override
- public void onAnimationPause(Animator animation) {
- finalSceneRoot.getOverlay().remove(finalOverlayView);
- }
-
- @Override
- public void onAnimationResume(Animator animation) {
- finalSceneRoot.getOverlay().add(finalOverlayView);
- }
});
}
return animator;
@@ -409,6 +399,16 @@ public abstract class Visibility extends Transition {
return overlayView;
}
+ @Override
+ boolean areValuesChanged(TransitionValues oldValues, TransitionValues newValues) {
+ VisibilityInfo changeInfo = getVisibilityChangeInfo(oldValues, newValues);
+ if (oldValues == null && newValues == null) {
+ return false;
+ }
+ return changeInfo.visibilityChange && (changeInfo.startVisibility == View.VISIBLE ||
+ changeInfo.endVisibility == View.VISIBLE);
+ }
+
/**
* The default implementation of this method returns a null Animator. Subclasses should
* override this method to make targets disappear with the desired transition. The