@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { ArtworkHolder holder = (ArtworkHolder) item; ViewHolder vh = (ViewHolder) viewHolder; ImageCardView cardView = vh.getCardView(); Context context = cardView.getContext(); cardView.setTitleText(holder.getTitle()); cardView.setMainImageDimensions(266, 400); cardView.setInfoAreaBackgroundColor(Utils.getColor(context, R.color.primary_color)); vh.updateCardViewImage(cardView.getContext(), holder.getPosterUrl()); }
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { super.onBindViewHolder(viewHolder, item); final CardViewHolder cardViewHolder = (CardViewHolder) viewHolder; final ImageCardView imageCardView = cardViewHolder.getImageCardView(); AlbumSimple albumSimple = (AlbumSimple) item; // name imageCardView.setTitleText(albumSimple.name); // Load real album (not simple) from API SpotifyTvApplication app = SpotifyTvApplication.getInstance(); app.getSpotifyService() .getAlbum( albumSimple.id, new Callback<Album>() { @Override public void success(final Album album, Response response) { // artists final StringBuilder artists = new StringBuilder(); for (ArtistSimple artist : album.artists) { if (artists.length() > 0) { artists.append(", "); } artists.append(artist.name); } // image final String imageUrl = album.images.get(0).url; // run on UI thread imageCardView.post( new Runnable() { @Override public void run() { imageCardView.setContentText(artists); cardViewHolder.updateCardViewImage(URI.create(imageUrl)); } }); } @Override public void failure(RetrofitError error) {} }); }
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { Movie movie = (Movie) item; ImageCardView cardView = (ImageCardView) viewHolder.view; Log.d(TAG, "onBindViewHolder"); if (movie.getCardImageUrl() != null) { cardView.setTitleText(movie.getTitle()); cardView.setContentText(movie.getStudio()); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); Glide.with(viewHolder.view.getContext()) .load(movie.getCardImageUrl()) .centerCrop() .error(mDefaultCardImage) .into(cardView.getMainImageView()); } }