Did you try to bind animation listener to the shared element view inside onMapSharedElements
? ViewCompat.animate(view)
will give you either a new or cached ViewPropertyAnimator(Compat)
and then binding the animation listener should be trivial. I haven't tried it, though.
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
super.onMapSharedElements(names, sharedElements);
View keySharedElementView = sharedElements.get("keySharedElement");
if(keySharedElementView != null){
ViewCompat.animate(keySharedElementView).setListener(new ViewPropertyAnimatorListenerAdapter(){
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
}
});
}
}
});
What about adding Transition.Listener
to the shared element transition?
Transition sharedElementEnterTransition = getWindow().getSharedElementEnterTransition();
sharedElementEnterTransition.addListener(new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(android.support.transition.Transition transition) {
super.onTransitionEnd(transition);
}
});
TransitionListenerAdapter
is just an empty implementation of theTransition.TransitionListener
interface. It is likely taken from a public project by @alex-lockwood : github.com/alexjlockwood/activity-transitions/blob/master/app/… – Crank