Skip to content

Instantly share code, notes, and snippets.

@aldoKelvianto
Last active February 16, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldoKelvianto/fe7d845331e3b1085d563cd9aac7ff9c to your computer and use it in GitHub Desktop.
Save aldoKelvianto/fe7d845331e3b1085d563cd9aac7ff9c to your computer and use it in GitHub Desktop.
<!--
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