Skip to content

Shared element transitions improvements#504

Merged
UweTrottmann merged 2 commits into
UweTrottmann:devfrom
cbeyls:dev
Jan 25, 2017
Merged

Shared element transitions improvements#504
UweTrottmann merged 2 commits into
UweTrottmann:devfrom
cbeyls:dev

Conversation

@cbeyls
Copy link
Copy Markdown
Contributor

@cbeyls cbeyls commented Jan 25, 2017

These commits fix 2 issues with the poster shared element transitions:

  1. The adapter position is replaced with a stable id for the transition name. This allows to match the correct poster even if the items have changed position after the activity has been re-created.

  2. When MoviesActivity is re-created, the transition is postponed until after the next layout pass. This gives a chance to the adapters to repopulate the posters, since adapter population is asynchronous. Thanks to this, the poster animation will also work properly after changing the orientation in the details page then navigating back to MoviesActivity, which doesn't work currently.

@UweTrottmann
Copy link
Copy Markdown
Owner

Thank you so much! I was about to give up on the transition animations due to those issues. I am curious: are you aware of any official examples or documentation on this?

Expect to see this in the next SeriesGuide release.

@UweTrottmann UweTrottmann added this to the SeriesGuide 35 milestone Jan 25, 2017
@UweTrottmann UweTrottmann added the enhancement New feature or request label Jan 25, 2017
@UweTrottmann UweTrottmann merged commit 2cb42d7 into UweTrottmann:dev Jan 25, 2017
@cbeyls
Copy link
Copy Markdown
Contributor Author

cbeyls commented Jan 25, 2017

I'm not aware of official examples but I've read a few blog posts from George Mount about activity transitions and how to postpone them when necessary. I also faced the same issue in one of my own apps. When using a transition with a list, in some cases the transition waits for the list to be populated, in some cases not, so it's better to manually delay it.
You may alternatively use a PreDrawListener or something similar but I found out a simple "post" works fine.
Of course the animation will still not play properly if the loader needs to restart (if the application was fully stopped for example) but that's an acceptable trade-off.

UweTrottmann added a commit that referenced this pull request May 2, 2026
Changes in #504 are not
legally significant. But still attribute the person that proposed it.
UweTrottmann added a commit that referenced this pull request May 2, 2026
Changes in #504 are not
legally significant. But still attribute the person that proposed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants