Skip to content

Instantly share code, notes, and snippets.

@fnk0
Last active October 12, 2016 00:09
Show Gist options
  • Select an option

  • Save fnk0/bf39e90c6815a44ea4d420cee0399dc1 to your computer and use it in GitHub Desktop.

Select an option

Save fnk0/bf39e90c6815a44ea4d420cee0399dc1 to your computer and use it in GitHub Desktop.
Adding the OnItemViewSelectedListener
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