Java Code Examples for android.support.v17.leanback.widget.ImageCardView#setContentText()

The following examples show how to use android.support.v17.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: CardPresenter.java    From leanback-homescreen-channels with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    Clip clip = (Clip) item;
    if (clip.getCardImageUrl() != null) {
        ImageCardView cardView = (ImageCardView) viewHolder.view;
        Resources resources = cardView.getContext().getResources();
        cardView.setTitleText(clip.getTitle());
        cardView.setContentText(clip.getDescription());
        float widthMultiplier = getWidthMultplier(clip.getAspectRatio());
        int cardWidth = Math.round(resources.getDimensionPixelSize(R.dimen.card_width)
                * widthMultiplier);
        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 leanback-extensions with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example 3
Source File: VideoContentCardPresenter.java    From leanback-showcase 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 4
Source File: CardPresenter.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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());
    }
}
 
Example 5
Source File: VideoCardViewPresenter.java    From leanback-assistant with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    Movie movie = (Movie) item;
    ImageCardView view = (ImageCardView) viewHolder.view;

    view.setTitleText(movie.getTitle());
    view.setContentText(movie.getDescription());

    Glide.with(mContext).load(movie.getCardImage()).asBitmap().into(view.getMainImageView());
}
 
Example 6
Source File: ImgCardPresenter.java    From AndroidTVLauncher with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    ImageCardView cardView = (ImageCardView) viewHolder.view;
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    if (item instanceof MediaModel) {
        MediaModel mediaModel = (MediaModel) item;
        cardView.setTitleText(mediaModel.getTitle());
        cardView.setContentText(mediaModel.getContent());
        Glide.with(cardView.getMainImageView().getContext())
                .load(mediaModel.getImageUrl())
                .crossFade()
                .into(cardView.getMainImageView());
    }
}
 
Example 7
Source File: ApkPresenter.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    Apk application = (Apk) item;
    final ImageCardView cardView = (ImageCardView) viewHolder.view;

    Log.d(TAG, "onBindViewHolder");
    if (application.getBanner() != null) {
        cardView.setTitleText(application.getName());
        cardView.setContentText(mContext.getString(R.string.version_number, application.getVersionName()));
        cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
        Glide.with(viewHolder.view.getContext())
                .load(!application.getBanner().isEmpty() ? application.getBanner() : application.getIcon())
                .asBitmap()
                .into(new BitmapImageViewTarget(cardView.getMainImageView()) {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        super.onResourceReady(resource, glideAnimation);
                        Palette.generateAsync(resource, new Palette.PaletteAsyncListener() {
                            @Override
                            public void onGenerated(Palette palette) {
                                // Here's your generated palette
                                if (palette.getDarkVibrantSwatch() != null) {
                                    cardView.findViewById(R.id.info_field).setBackgroundColor(
                                            palette.getDarkVibrantSwatch().getRgb());
                                }
                            }
                        });
                    }
                });
    }
}
 
Example 8
Source File: ImageCardViewPresenter.java    From leanback-showcase 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());
    }
}