Merge "Add end functionality to LayoutTransition"

This commit is contained in:
Chet Haase
2011-09-07 14:59:52 -07:00
committed by Android (Google) Code Review
2 changed files with 33 additions and 8 deletions

View File

@@ -793,7 +793,9 @@ public class LayoutTransition {
* @hide
*/
public void startChangingAnimations() {
for (Animator anim : currentChangingAnimations.values()) {
LinkedHashMap<View, Animator> currentAnimCopy =
(LinkedHashMap<View, Animator>) currentChangingAnimations.clone();
for (Animator anim : currentAnimCopy.values()) {
if (anim instanceof ObjectAnimator) {
((ObjectAnimator) anim).setCurrentPlayTime(0);
}
@@ -801,6 +803,23 @@ public class LayoutTransition {
}
}
/**
* Ends the animations that are set up for a CHANGING transition. This is a variant of
* startChangingAnimations() which is called when the window the transition is playing in
* is not visible. We need to make sure the animations put their targets in their end states
* and that the transition finishes to remove any mid-process state (such as isRunning()).
*
* @hide
*/
public void endChangingAnimations() {
LinkedHashMap<View, Animator> currentAnimCopy =
(LinkedHashMap<View, Animator>) currentChangingAnimations.clone();
for (Animator anim : currentAnimCopy.values()) {
anim.start();
anim.end();
}
}
/**
* Returns true if animations are running which animate layout-related properties. This
* essentially means that either CHANGE_APPEARING or CHANGE_DISAPPEARING animations

View File

@@ -1575,13 +1575,13 @@ public final class ViewRootImpl extends Handler implements ViewParent,
boolean cancelDraw = attachInfo.mTreeObserver.dispatchOnPreDraw() ||
viewVisibility != View.VISIBLE;
if (mPendingTransitions != null && mPendingTransitions.size() > 0) {
for (int i = 0; i < mPendingTransitions.size(); ++i) {
mPendingTransitions.get(i).startChangingAnimations();
}
mPendingTransitions.clear();
}
if (!cancelDraw && !newSurface) {
if (mPendingTransitions != null && mPendingTransitions.size() > 0) {
for (int i = 0; i < mPendingTransitions.size(); ++i) {
mPendingTransitions.get(i).startChangingAnimations();
}
mPendingTransitions.clear();
}
mFullRedrawNeeded = false;
final long drawStartTime;
@@ -1619,7 +1619,13 @@ public final class ViewRootImpl extends Handler implements ViewParent,
}
}
} else {
// End any pending transitions on this non-visible window
if (mPendingTransitions != null && mPendingTransitions.size() > 0) {
for (int i = 0; i < mPendingTransitions.size(); ++i) {
mPendingTransitions.get(i).endChangingAnimations();
}
mPendingTransitions.clear();
}
// We were supposed to report when we are done drawing. Since we canceled the
// draw, remember it here.
if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {