Last active
February 16, 2017 14:03
-
-
Save aldoKelvianto/fe7d845331e3b1085d563cd9aac7ff9c to your computer and use it in GitHub Desktop.
This file contains 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
<!-- | |
ListActivity.java | |
--> | |
@Override public void onAnimalClick(View view, Animal animal) { | |
ImageView ivTarget = (ImageView) view.findViewById(R.id.iv_image); | |
Intent intent = getBundledIntent(animal); | |
launchDetailActivity(ivTarget, intent); | |
} | |
private void launchDetailActivity(View view, Intent intent) { | |
if (isSupportActivityTransition()) { | |
ActivityOptionsCompat option = | |
ActivityOptionsCompat.makeSceneTransitionAnimation(ListActivity.this, view, | |
"animalImage"); | |
startActivity(intent, option.toBundle()); | |
} | |
} | |
private Intent getBundledIntent(Animal animal) { | |
Intent intent = new Intent(this, DetailActivity.class); | |
intent.putExtra(DetailActivity.EXTRA_ANIMAL_RES_ID, animal); | |
return intent; | |
} | |
<!-- | |
DetailActivity.java | |
--> | |
// get the image res from bundle | |
AnimalGenerator.Animal animal = getIntent().getParcelableExtra(EXTRA_ANIMAL_RES_ID); | |
activityDetailBinding.setAnimal(animal); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment