Java Code Examples for androidx.leanback.widget.ImageCardView#setContentText()

The following examples show how to use androidx.leanback.widget.ImageCardView#setContentText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoContentCardPresenter.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    VideoContent clip = (VideoContent) item;
    if (clip.getCardImageUrl() != null) {
        ImageCardView cardView = (ImageCardView) viewHolder.view;
        Resources resources = cardView.getContext().getResources();
        cardView.setTitleText(clip.getTitle());
        cardView.setContentText(clip.getDescription());
        int cardWidth = Math.round(resources.getDimensionPixelSize(R.dimen.card_width)
        );
        int cardHeight = resources.getDimensionPixelSize(R.dimen.card_height);
        cardView.setMainImageDimensions(cardWidth, cardHeight);
        Glide.with(viewHolder.view.getContext())
                .load(clip.getCardImageUrl())
                .into(cardView.getMainImageView());
    }
}
 
Example 2
Source File: CardPresenter.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    Video video = (Video) item;

    ImageCardView cardView = (ImageCardView) viewHolder.view;
    cardView.setTitleText(video.title);
    cardView.setContentText(video.studio);

    if (video.cardImageUrl != null) {
        // Set card size from dimension resources.
        Resources res = cardView.getResources();
        int width = res.getDimensionPixelSize(R.dimen.card_width);
        int height = res.getDimensionPixelSize(R.dimen.card_height);
        cardView.setMainImageDimensions(width, height);

        Glide.with(cardView.getContext())
                .load(video.cardImageUrl)
                .apply(RequestOptions.errorOf(mDefaultCardImage))
                .into(cardView.getMainImageView());
    }
}
 
Example 3
Source File: CardPresenter.java    From androidtv-Leanback with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    Video video = (Video) item;

    ImageCardView cardView = (ImageCardView) viewHolder.view;
    cardView.setTitleText(video.title);
    cardView.setContentText(video.studio);

    if (video.cardImageUrl != null) {
        // Set card size from dimension resources.
        Resources res = cardView.getResources();
        int width = res.getDimensionPixelSize(R.dimen.card_width);
        int height = res.getDimensionPixelSize(R.dimen.card_height);
        cardView.setMainImageDimensions(width, height);

        Glide.with(cardView.getContext())
                .load(video.cardImageUrl)
                .apply(RequestOptions.errorOf(mDefaultCardImage))
                .into(cardView.getMainImageView());
    }
}
 
Example 4
Source File: ImageCardViewPresenter.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(Card card, final ImageCardView cardView) {
    cardView.setTag(card);
    cardView.setTitleText(card.getTitle());
    cardView.setContentText(card.getDescription());
    if (card.getLocalImageResourceName() != null) {
        int resourceId = getContext().getResources()
                .getIdentifier(card.getLocalImageResourceName(),
                        "drawable", getContext().getPackageName());
        Glide.with(getContext())
                .asBitmap()
                .load(resourceId)
                .into(cardView.getMainImageView());
    }
}