Add start/endTransition events for CHANGE transitions
There was already a mechanism for sending out events for LayoutTransition when animations started or ended, but the implementation only sent out events for the appearing/disappearing animations. This fix provides callbacks to listeners for the CHANGE_APPEARING and CHANGE_DISAPPEARING transitions, too. Change-Id: Icfb8cc1c20d2df3e4a817255e96c9d0e94c1d8c4
This commit is contained in:
@@ -600,6 +600,18 @@ public class LayoutTransition {
|
||||
// Remove the animation from the cache when it ends
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
private boolean canceled = false;
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
if (mListeners != null) {
|
||||
for (TransitionListener listener : mListeners) {
|
||||
listener.startTransition(LayoutTransition.this, parent, child,
|
||||
changeReason == APPEARING ?
|
||||
CHANGE_APPEARING : CHANGE_DISAPPEARING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
// we remove canceled animations immediately, not here
|
||||
@@ -607,11 +619,19 @@ public class LayoutTransition {
|
||||
child.removeOnLayoutChangeListener(listener);
|
||||
layoutChangeListenerMap.remove(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (!canceled) {
|
||||
currentChangingAnimations.remove(child);
|
||||
}
|
||||
if (mListeners != null) {
|
||||
for (TransitionListener listener : mListeners) {
|
||||
listener.endTransition(LayoutTransition.this, parent, child,
|
||||
changeReason == APPEARING ?
|
||||
CHANGE_APPEARING : CHANGE_DISAPPEARING);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user