Last active
October 12, 2016 00:09
-
-
Save fnk0/bf39e90c6815a44ea4d420cee0399dc1 to your computer and use it in GitHub Desktop.
Adding the OnItemViewSelectedListener
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 { | |
| private void createRows() { | |
| ... | |
| setOnItemViewSelectedListener(this); | |
| } | |
| @Override | |
| public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { | |
| // Check if the item is a movie | |
| if (item instanceof Movie) { | |
| Movie movie = (Movie) item; | |
| // Check if the movie has a backdrop | |
| if(movie.getBackdropPath() != null) { | |
| mBackgroundManager.loadImage(HttpClientModule.BACKDROP_URL + movie.getBackdropPath()); | |
| } else { | |
| // If there is no backdrop for the movie we just use a default one | |
| mBackgroundManager.setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.material_bg)); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment