Skip to content

Instantly share code, notes, and snippets.

@fnk0
Last active October 16, 2016 08:02
Show Gist options
  • Save fnk0/cbc1653038d2e580341aca923990a51f to your computer and use it in GitHub Desktop.
Save fnk0/cbc1653038d2e580341aca923990a51f to your computer and use it in GitHub Desktop.
MainFragment Part 2.1
public class MainFragment extends BrowseFragment implements OnItemViewSelectedListener,
OnItemViewClickedListener { // Add the OnItemViewClickedListener interface
private void createRows() {
...
// Set the click listener
setOnItemViewClickedListener(this);
}
// Implement the onItemClicked required by the OnItemViewClickedListener interface
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Movie) {
Movie movie = (Movie) item;
Intent i = new Intent(getActivity(), MovieDetailsActivity.class);
// Pass the movie to the activity
i.putExtra(Movie.class.getSimpleName(), movie);
if (itemViewHolder.view instanceof MovieCardView) {
// Pass the ImageView to allow a nice transition
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((MovieCardView) itemViewHolder.view).getPosterIV(),
MovieDetailsFragment.TRANSITION_NAME).toBundle();
getActivity().startActivity(i, bundle);
} else {
startActivity(i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment