Last active
October 16, 2016 08:02
-
-
Save fnk0/cbc1653038d2e580341aca923990a51f to your computer and use it in GitHub Desktop.
MainFragment Part 2.1
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
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