Search in sources :

Example 11 with ImageCardView

use of android.support.v17.leanback.widget.ImageCardView in project butter-android by butterproject.

the class EpisodeCardPresenter method onBindViewHolder.

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    final Episode episode = (Episode) item;
    ViewHolder vh = (ViewHolder) viewHolder;
    vh.setEpisode(episode);
    ImageCardView cardView = vh.getCardView();
    cardView.setTitleText(episode.getTitle());
    cardView.setContentText(String.format(context.getString(R.string.episode_number_format), episode.getEpisode()));
    cardView.setMainImageDimensions(cardWidth, cardHeight);
    vh.updateCardViewImage(episode.getBackdrop());
    cardView.setOnClickListener(view -> {
        if (null != clickListener) {
            clickListener.onEpisodeClicked(episode);
        }
    });
}
Also used : Episode(butter.droid.provider.base.model.Episode) ImageCardView(android.support.v17.leanback.widget.ImageCardView)

Example 12 with ImageCardView

use of android.support.v17.leanback.widget.ImageCardView in project vlc-android by GeoffreyMetais.

the class AsyncImageLoader method updateTargetImage.

public static void updateTargetImage(final Bitmap bitmap, final View target, final ViewDataBinding vdb) {
    if (bitmap == null || bitmap.getWidth() <= 1 || bitmap.getHeight() <= 1)
        return;
    if (vdb != null) {
        vdb.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
        vdb.setVariable(BR.cover, new BitmapDrawable(target.getResources(), bitmap));
        vdb.setVariable(BR.protocol, null);
    } else {
        WorkersKt.runOnMainThread(new Runnable() {

            @Override
            public void run() {
                if (target instanceof ImageView) {
                    final ImageView iv = (ImageView) target;
                    iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
                    iv.setImageBitmap(bitmap);
                    iv.setVisibility(View.VISIBLE);
                } else if (target instanceof TextView) {
                    ViewCompat.setBackground(target, new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
                    ((TextView) target).setText(null);
                } else if (target instanceof ImageCardView) {
                    ((ImageCardView) target).getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
                    ((ImageCardView) target).setMainImage(new BitmapDrawable(target.getResources(), bitmap));
                }
            }
        });
    }
}
Also used : ImageCardView(android.support.v17.leanback.widget.ImageCardView) TextView(android.widget.TextView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView)

Aggregations

ImageCardView (android.support.v17.leanback.widget.ImageCardView)12 ImageView (android.widget.ImageView)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 TextView (android.widget.TextView)2 Episode (butter.droid.provider.base.model.Episode)1