Closed keyboardsurfer closed 7 years ago
@keyboardsurfer you're correct I've been inconsistent with how I've set things.
The SimpleActivityA
xml layout was because I wanted the code to be more obvious, but I guess that people should have some experience with Android if they're reading!
The reason I don't call imageView.getTransitionName()
is because I dislike having to wrap things with if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
. If I use a strings.xml
or a string it means I don't have to have it in my code.
On Tue, Feb 28, 2017, 6:57 PM Michael Scamell notifications@github.com wrote:
@keyboardsurfer https://github.com/keyboardsurfer you're correct I've been inconsistent with how I've set things.
The SimpleActivityA xml layout was my fault for not returning it to a @string when i was writing a presentation and wanted the code to be more obvious for the slide.
The reason I don't call imageView.getTransitionName() is because I dislike having to wrap things with if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP). If I use a strings.xml or a string it means I don't have to have it in my code.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mikescamell/shared-element-transitions/issues/2#issuecomment-283129819, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVhLL8MPBS5Z6xv0DTI5fCbPwV36_ktks5rhG4JgaJpZM4MNVac .
Am i missing something @nickbutcher? If I call imageView.getTransitionName()
on API 19 it will crash right?
That call would crash which is why I was suggesting calling
ViewCompat.getTransitionName(imageView)
instead which will API check for
you, or return null.
Ah ok gotcha! Don't think I've ever had to call ViewCompat
that I can remember 🤔 Looks like I'll be using it more often from now on 😄 Thanks for the tip.
The code has now been adjusted to take these comments into account. Thanks again for the suggestions.
In your SimpleActivity example you're setting matching transition names in different (A / B and strings.xml) ways. Instead of doing this you can pass in
imageView.getTransitionName()
into the last param the of ActivityOptionsCompat call.This simplification can be made in several examples.