本文整理汇总了Java中android.support.v17.leanback.widget.ImageCardView类的典型用法代码示例。如果您正苦于以下问题:Java ImageCardView类的具体用法?Java ImageCardView怎么用?Java ImageCardView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageCardView类属于android.support.v17.leanback.widget包,在下文中一共展示了ImageCardView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
TvShow tvShow = (TvShow) item;
ImageCardView cardView = (ImageCardView) viewHolder.view;
((ImageCardView) viewHolder.view).setTitleText(tvShow.getTitle());
// 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(tvShow.getImage())
.crossFade()
.placeholder(R.color.color_primary)
.error(R.color.color_primary)
.into(cardView.getMainImageView());
}
示例2: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例3: onBindViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@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());
}
}
示例4: onItemClicked
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Movie) {
Movie movie = (Movie) item;
Log.d(TAG, "Item: " + item.toString());
Intent intent = new Intent(getActivity(), DetailsActivity.class);
intent.putExtra(getResources().getString(R.string.movie), mSelectedMovie);
intent.putExtra(getResources().getString(R.string.should_start), true);
startActivity(intent);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
DetailsActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
}
示例5: onBindViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
Episode episode = (Episode) item;
ImageCardView cardView = (ImageCardView) viewHolder.view;
((ImageCardView) viewHolder.view).setTitleText(episode.getName());
// 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(episode.providePosterURL())
.error(R.color.color_primary)
.placeholder(R.color.color_primary)
.crossFade()
.into(cardView.getMainImageView());
}
示例6: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
/*
* This template uses a default image in res/drawable, but the general case for Android TV
* will require your resources in xhdpi. For more information, see
* https://developer.android.com/training/tv/start/layouts.html#density-resources
*/
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例7: onItemClicked
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Movie) {
Log.d(TAG, "Item: " + item.toString());
Intent intent = new Intent(getActivity(), DetailsActivity.class);
intent.putExtra(getResources().getString(R.string.movie), mSelectedMovie);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
DetailsActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
}
示例8: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.default_background);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例9: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.detail_background);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例10: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.detail_background);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
TextView title = (TextView) cardView.findViewById(R.id.title_text);
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, CARD_HEIGHT / 9);
return new ViewHolder(cardView);
}
示例11: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.detail_background);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
TextView title = (TextView) cardView.findViewById(R.id.title_text);
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, mHeight / 9);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例12: onItemClicked
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Video) {
Video video = (Video) item;
Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
intent.putExtra(VideoDetailsActivity.VIDEO, video);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
}
示例13: onItemClicked
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Video) {
Video video = (Video) item;
Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
intent.putExtra(VideoDetailsActivity.VIDEO, video);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
}
示例14: onCreateViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
mDefaultBackgroundColor =
ContextCompat.getColor(parent.getContext(), R.color.default_background);
mSelectedBackgroundColor =
ContextCompat.getColor(parent.getContext(), R.color.selected_background);
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie, null);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例15: onBindViewHolder
import android.support.v17.leanback.widget.ImageCardView; //导入依赖的package包/类
@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)
.error(mDefaultCardImage)
.diskCacheStrategy(NONE)
.into(cardView.getMainImageView());
//obnovit obrazek
}
}