Last active
March 8, 2016 17:52
-
-
Save fnk0/19e4eb0a8c0211455f62 to your computer and use it in GitHub Desktop.
ActivityTransition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| Define the transitionName in both ImageViews in the source XML and the Destination XML | |
| It is very important for then to match | |
| --> | |
| <android.support.v7.widget.AppCompatImageView | |
| android:id="@+id/myImage" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:fitsSystemWindows="true" | |
| android:scaleType="centerCrop" | |
| app:layout_collapseMode="parallax" | |
| android:transitionName="transitionImage" | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String pictureUrl = extras.getString(Const.EXTRA_IMAGE); | |
| // We still need to Load the image | |
| loadImage(pictureUrl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent intent = new Intent(getActivity(), DestinationActivity.class); | |
| // We want the URL as soon as the other Activity starts to load the image faster | |
| intent.putExtra(Const.EXTRA_IMAGE, pictureURL); | |
| // Check if is Lollipop first | |
| if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| // transitionImageView is the ImageView that will be transitioned | |
| ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), transitionImageView, "transitionImage"); | |
| startActivity(intent, options.toBundle()); | |
| } else { | |
| startActivity(intent); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment