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);
}
});
}
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));
}
}
});
}
}
Aggregations