Conductor: Separate Enter Exit transition for each controller

Created on 26 May 2017  Â·  18Comments  Â·  Source: bluelinelabs/Conductor

Is this possible to set different enter and exit transition?
For example the _from view_ exit with Fade out and the _to view_ enter with Slide bottom + Fade in.

I couldn't do this with TransitionChangeHandler the whole transition applies on both controllers.

Most helpful comment

I know it's been a while since this was opened, but I'm very close to getting this done! I have a few demos working great. At this point I'm just trying to generalize the solution properly, then I'll push to the snapshot build. Should be a day or so.

All 18 comments

Things like this are the whole reason change handlers were written the way they were. You can do anything you want with them. You'll want to extend AnimatorChangeHandler to accomplish your example.

@EricKuck Does this work with Shared Element out of the box?

AnimatorChangeHandlers are for the animator API. TransitionChangeHandlers are for the Transition API, which is what allows shared element transitions to work.

@EricKuck I'm not sure how this answers my question! 😕
So there is no way to achieve what I'm trying to do? shared element + diffrent enter exit transition for each controller?

He suggests to use TransitionChangeHandler

in getTransition there is a parameter called isPush.

@PaulWoitaschek I have already tried that.
The problem is the transition is applied on both controllers.

protected Transition getTransition(@NonNull ViewGroup container, View from, View to, boolean isPush) {
        TransitionSet transition = new TransitionSet();
        transition.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);

        if (isPush) {
            transition
                    .addTransition(new Fade(Fade.OUT))
                    .addTransition(new TransitionSet()
                            .addTransition(new ChangeTransform())
                            .addTransition(new ChangeBounds())
                            .addTransition(new ChangeClipBounds())
                            .addTransition(new ChangeImageTransform()))
                    .addTransition(new Slide(Gravity.BOTTOM))
            ;
        } else {
            transition
                    .addTransition(new Slide(Gravity.BOTTOM))
                    .addTransition(new TransitionSet()
                            .addTransition(new ChangeTransform())
                            .addTransition(new ChangeBounds())
                            .addTransition(new ChangeClipBounds())
                            .addTransition(new ChangeImageTransform()))
                    .addTransition(new Fade(Fade.IN))
            ;
        }

        return transition;
    }

I'm not asking about pop or push transition, the problem is we define one transition for both controllers(the exiting and entering).
With Activity API you can set Exit transition on the first Activity and a Different transition for the Enter Transition in the second Activity.

ActivityFirst.java

getWindow().setExitTransition(new Fade(Fade.OUT));
getWindow().setReenterTransition(new Fade(Fade.IN));

ActivitySecond.java

getWindow().setEnterTransition(new Slide(Gravity.BOTTOM));

These are completely separate from each other, with TransitionChangeHandler the Fade and Slide transition is applied on the both Controllers either in pop or push.

What you want to do is very possible, but you're not going to get it done using the standard transitions provided by Google. You'll have to write that yourself. I'll look into if there's a way to copy what Google did with Activities and make it work with Views, but I'd be surprised if there was a way to do that. There's a lot of magic happening with Activity transitions that you just can't do with Views/Fragments/Controllers.

@EricKuck Thank you.

This is actually doable with fragments:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            TransitionSet transition = new TransitionSet()
                    .setOrdering(TransitionSet.ORDERING_TOGETHER)
                    .addTransition(new ChangeTransform())
                    .addTransition(new ChangeBounds())
                    .addTransition(new ChangeClipBounds())
                    .addTransition(new ChangeImageTransform());

            fragmentDetails.setSharedElementEnterTransition(transition);
            fragmentDetails.setSharedElementReturnTransition(transition);
            fragmentDetails.setEnterTransition(new Slide(Gravity.BOTTOM));
            this.setExitTransition(new Explode());
        }

        getActivity().getSupportFragmentManager()
                .beginTransaction()
                .addSharedElement(holder.image, "sharedImage")
                .replace(R.id.container, fragmentDetails)
                .addToBackStack(null)
                .commit();

Does this with with support fragments or just native?

On Sat, May 27, 2017, 4:56 AM Pedram notifications@github.com wrote:

@EricKuck https://github.com/erickuck Thank you.

This is actually doable with fragments:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

TransitionSet transition = new TransitionSet

()
.setOrdering(TransitionSet.ORDERING_TOGETHER)
.addTransition(new ChangeTransform())
.addTransition(new ChangeBounds())
.addTransition(new ChangeClipBounds())
.addTransition(new ChangeImageTransform());

        fragmentDetails.setSharedElementEnterTransition(transition);
        fragmentDetails.setSharedElementReturnTransition(transition);
        fragmentDetails.setEnterTransition(new Slide(Gravity.BOTTOM));
        this.setExitTransition(new Explode());
    }

    getActivity().getSupportFragmentManager()
            .beginTransaction()
            .addSharedElement(holder.image, "kittenImage")
            .replace(R.id.container, fragmentDetails)
            .addToBackStack(null)
            .commit();

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/bluelinelabs/Conductor/issues/307#issuecomment-304442063,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB8c8jzc6ANrXk1DoISHsh9aEYpMCRP9ks5r9_MzgaJpZM4NndWY
.

@EricKuck Works with both support and native Fragment

I know it's been a while since this was opened, but I'm very close to getting this done! I have a few demos working great. At this point I'm just trying to generalize the solution properly, then I'll push to the snapshot build. Should be a day or so.

That's great, wating to test it out 😃

If you check out the latest snapshot, I've added SharedElementTransitionChangeHandler, which should fulfill all your needs. Please try it out and let me know if anything is missing or needs to be changed before finalizing the API and pushing a new version.

I have tried it out, I found a few issues:

  1. The waitOnSharedElementNamed(name) doesn't seem to work, in the conductor demo app just uncomment the setTransitionNamelines, transition does not wait.
  1. Starting a Fade Transition causes an overlap with the content behind the toolbar, the toolbar gets hide immediately, I've created a project you can check it out here.

  2. In the sample I've made I have noticed a weird behavior, adding the transition name into ArcFadeMoveChangeHandler causes the transition not to work and it flashes to the next controller, the transition works fine with the old ArcFadeMoveChangeHandler.
    Maybe it's related to the first issue!

Do you have any examples for #1? Works fine here.

The transitions API in general is pretty hard to get right and seems to have lots of weird behavior. What I did was basically mimic the way Google did things for Fragments. If there's a bug with Fragments, there's going to be a bug that I can't fix here too.

Ahh.. You mean you have commented out these four lines here and here and when you click on a city item it doesn't go to the details page?!

True that, Google has always a way to make the developers lives miserable. 😅

@Pedramrn your first issue is now fixed in the latest snapshot.

I ran the project you created for your second issue and didn't see a problem with the toolbar immediately hiding anymore. Pretty sure that's fixed as well.

I'm not sure why the pop transition doesn't hide the images correctly though - do you have any insight on that? I saw that you tried to work around it by setting the visibility when the transition started.

@EricKuck The enter animation is now completely broken with the new SharedElementTransitionChangeHandler in the provided sample.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JakeWharton picture JakeWharton  Â·  7Comments

mradzinski picture mradzinski  Â·  5Comments

vincent-paing picture vincent-paing  Â·  6Comments

lenguyenthanh picture lenguyenthanh  Â·  5Comments

dmarcato picture dmarcato  Â·  4Comments