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

The following examples show how to use android.support.v17.leanback.widget.ImageCardView#setTitleText() . 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: FunctionCardPresenter.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);
    FunctionModel functionModel = (FunctionModel) item;
    cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE);
    cardView.getMainImageView().setImageResource(functionModel.getIcon());
    cardView.setTitleText(functionModel.getName());
}
 
Example 8
Source File: AppCardPresenter.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);
    AppModel appBean = (AppModel) item;
    cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE);
    cardView.getMainImageView().setImageDrawable(appBean.getIcon());
    cardView.setTitleText(appBean.getName());
}
 
Example 9
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 10
Source File: OptionsCardPresenter.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    final SettingOption option = (SettingOption) item;
    final ImageCardView cardView = (ImageCardView) viewHolder.view;
    cardView.setMainImage(option.getDrawable());
    cardView.setTitleText(option.getText());
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
}
 
Example 11
Source File: DownloadedFilesPresenter.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    final File downloadedApk = (File) item;
    final ImageCardView cardView = (ImageCardView) viewHolder.view;
    cardView.setMainImage(contextThemeWrapper.getDrawable(R.drawable.download));
    cardView.setTitleText(downloadedApk.getName());
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
}
 
Example 12
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());
    }
}
 
Example 13
Source File: OptionsCardPresenter.java    From CumulusTV with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    final Option option = (Option) item;
    final ImageCardView cardView = (ImageCardView) viewHolder.view;
    if (DEFAULT_BANNER) {
        cardView.setMainImage(contextThemeWrapper.getDrawable(R.drawable.c_banner_3_2));
    } else {
        cardView.setMainImage(option.getDrawable());
    }
    cardView.setTitleText(option.getText());
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
    cardView.findViewById(R.id.info_field).setBackgroundColor(
            ContextCompat.getColor(contextThemeWrapper, R.color.colorPrimaryDark));
}
 
Example 14
Source File: CardPresenter.java    From alltv with MIT License 4 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {

    ChannelData tvCh = (ChannelData) item;
    ImageCardView cardView = (ImageCardView) viewHolder.view;

    //Log.d(TAG, "onBindViewHolder");

    if (tvCh.getStillImageUrl() != null) {

        ArrayList<EPGData> epgData = tvCh.getEPG();
        Date date = new Date();

        Boolean isAdultContent = false;

        for(int i=0; i<epgData.size(); i++) {
            if(date.compareTo(epgData.get(i).getEndTime()) < 0) {
                tvCh.setProgramName(epgData.get(i).getProgramName());
                isAdultContent = epgData.get(i).isAdultContent();
                break;
            }
        }

        if(tvCh.getProgramName().equals("") || isAdultContent)
            cardView.setTitleText(tvCh.getTitle());
        else
            cardView.setTitleText(tvCh.getTitle() + " - " + tvCh.getProgramName());

        cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);

        int ret = tvCh.getFavorite();

        if(ret == 0)
            cardView.setBadgeImage(null);
        else if(ret == 1)
            cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.star_icon, null));
        else if(ret == 2)
            cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.wavve_icon_24, null));
        else if(ret == 3)
            cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.tving_icon_24, null));
        else if(ret == 4)
            cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.oksusu_icon_24, null));

        Picasso.get().load(tvCh.getStillImageUrl())
                .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
                .into(cardView.getMainImageView());

    }
}