lgvalle/Material-Animations

DetailActivity3 enterTransition and returnTransition Listeners.

RlagoMan opened this issue · 2 comments

Hello,
First of all, thanks for this useful code!
I've found that the listeners set to enterTransition and returnTransition in DetailActivity3#setupEnterAnimations() and DetailActivity3#setupExitAnimations() are both called when DetailActivity3 starts and also when back is pressed.
In fact, returnTransition is called first.
Using your layout no problem were observed, but using a different layout (more complex) or concatenating different effects may cause problems, for example when setting the visibility/invisibility of the child views.
The only solution I've found is to call setupExitAnimations() when enterTransition ends:

        final Transition enterTransition = getWindow().getSharedElementEnterTransition();
        enterTransition.addListener(new Transition.TransitionListener() {
            ...
            @Override
            public void onTransitionEnd(Transition transition) {
                animateRevealShow(bgViewGroup);
                enterTransition.removeListener(this);
                setupExitAnimations();
            }
            ...
        });

Have you ever faced this situation?

@RlagoMan
The solution is easy: remove enterTransition listener on onTransitionEnd callback:

public void onTransitionEnd(Transition transition) {
                transition.removeListener(this);

                animateRevealShow(bgViewGroup);
                enterTransition.removeListener(this);
                setupExitAnimations();
            }

There is a full working example here: https://github.com/lgvalle/Material-Animations/blob/master/app%2Fsrc%2Fmain%2Fjava%2Fcom%2Flgvalle%2Fmaterial_animations%2FRevealActivity.java

Hi,
Thanks for the reply. That's what I've made and it is working.

Best regards!
El 13/9/2015 22:46, "Luis G. Valle" notifications@github.com escribió:

@RlagoMan https://github.com/RlagoMan

The solution is easy: remove enterTransition listener on onTransitionEnd
callback:

public void onTransitionEnd(Transition transition) {
transition.removeListener(this);

            animateRevealShow(bgViewGroup);
            enterTransition.removeListener(this);
            setupExitAnimations();
        }

There is a full working example here:
https://github.com/lgvalle/Material-Animations/blob/master/app%2Fsrc%2Fmain%2Fjava%2Fcom%2Flgvalle%2Fmaterial_animations%2FRevealActivity.java


Reply to this email directly or view it on GitHub
#12 (comment)
.