androidx.leanback.widget.ImageCardView Java Examples
The following examples show how to use
androidx.leanback.widget.ImageCardView.
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: VideoCardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Context mContext = parent.getContext(); sDefaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.default_background); sSelectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.selected_background); sDefaultCardImage = parent.getResources().getDrawable(R.drawable.no_cache_no_internet, 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 CardViewHolder(cardView, mContext); }
Example #2
Source File: CardPresenter.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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) .apply(RequestOptions.errorOf(mDefaultCardImage)) .into(cardView.getMainImageView()); } }
Example #3
Source File: CardPresenter.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: VerticalGridFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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); } }
Example #5
Source File: SearchFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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); } else { Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT).show(); } }
Example #6
Source File: VideoDetailsFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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); } }
Example #7
Source File: PlaybackFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@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); } }
Example #8
Source File: CardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@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) .apply(RequestOptions.errorOf(mDefaultCardImage)) .into(cardView.getMainImageView()); } }
Example #9
Source File: CardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: VerticalGridFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@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); } }
Example #11
Source File: SearchFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@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); } else { Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT).show(); } }
Example #12
Source File: VideoDetailsFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@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); } }
Example #13
Source File: PlaybackFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@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); } }
Example #14
Source File: VideoCardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
CardViewHolder(ImageCardView view, Context context) { super(view); mContext = context; Context wrapper = new ContextThemeWrapper(mContext, R.style.MyPopupMenu); mPopupMenu = new PopupMenu(wrapper, view); mPopupMenu.inflate(R.menu.popup_menu); mPopupMenu.setOnMenuItemClickListener(this); view.setOnLongClickListener(this); mOwner = (LifecycleOwner) mContext; mDefaultBackground = mContext.getResources().getDrawable(R.drawable.no_cache_no_internet, null); mDefaultPlaceHolder = new RequestOptions(). placeholder(mDefaultBackground); mCardView = (ImageCardView) CardViewHolder.this.view; Resources resources = mCardView.getContext().getResources(); mCardView.setMainImageDimensions(Math.round( resources.getDimensionPixelSize(R.dimen.card_width)), resources.getDimensionPixelSize(R.dimen.card_height)); mFragmentActivity = (FragmentActivity) context; mViewModel = ViewModelProviders.of(mFragmentActivity).get(VideosViewModel.class); }
Example #15
Source File: SettingsIconPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@Override protected ImageCardView onCreateView() { final ImageCardView imageCardView = super.onCreateView(); imageCardView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { setImageBackground(imageCardView, R.color.settings_card_background_focussed); } else { setImageBackground(imageCardView, R.color.settings_card_background); } } }); setImageBackground(imageCardView, R.color.settings_card_background); return imageCardView; }
Example #16
Source File: VideoContentCardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@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 #17
Source File: VideoContentCardPresenter.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Context context = parent.getContext(); sDefaultBackgroundColor = ContextCompat.getColor(context, R.color.default_background); sSelectedBackgroundColor = ContextCompat.getColor(context, R.color.selected_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); }
Example #18
Source File: CardPresenter.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
@Override public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) { ImageCardView cardView = (ImageCardView) viewHolder.view; // Remove references to images so that the garbage collector can free up memory. cardView.setBadgeImage(null); cardView.setMainImage(null); }
Example #19
Source File: VideoCardViewPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(Card card, final ImageCardView cardView) { super.onBindViewHolder(card, cardView); VideoCard videoCard = (VideoCard) card; Glide.with(getContext()) .asBitmap() .load(videoCard.getImageUrl()) .into(cardView.getMainImageView()); }
Example #20
Source File: CardExampleFragment.java From tv-samples with Apache License 2.0 | 5 votes |
private void setupUi() { setHeadersState(HEADERS_ENABLED); setHeadersTransitionOnBackEnabled(true); setTitle(getString(R.string.card_examples_title)); setOnSearchClickedListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(), getString(R.string.implement_search), Toast.LENGTH_LONG).show(); } }); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder viewHolder, Object item, RowPresenter.ViewHolder viewHolder1, Row row) { if (!(item instanceof Card)) return; if (!(viewHolder.view instanceof ImageCardView)) return; ImageView imageView = ((ImageCardView) viewHolder.view).getMainImageView(); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), imageView, DetailViewExampleFragment.TRANSITION_NAME).toBundle(); Intent intent = new Intent(getActivity().getBaseContext(), DetailViewExampleActivity.class); Card card = (Card) item; int imageResId = card.getLocalImageResourceId(getContext()); intent.putExtra(DetailViewExampleFragment.EXTRA_CARD, imageResId); startActivity(intent, bundle); } }); prepareEntranceTransition(); }
Example #21
Source File: CardPresenter.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
private void updateCardBackgroundColor(ImageCardView view, boolean selected) { int color = selected ? mSelectedBackgroundColor : mDefaultBackgroundColor; // Both background colors should be set because the view's // background is temporarily visible during animations. view.setBackgroundColor(color); view.findViewById(R.id.info_field).setBackgroundColor(color); }
Example #22
Source File: VideoCardPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onUnbindViewHolder(ViewHolder viewHolder) { ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setBadgeImage(null); cardView.setMainImage(null); }
Example #23
Source File: CardViewPresenter.java From xipl with Apache License 2.0 | 5 votes |
@Override public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { ImageCardView imageCardView = new ImageCardView(parent.getContext()); int widthPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_width); int heightPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_height); imageCardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS); imageCardView.setFocusable(true); imageCardView.setFocusableInTouchMode(true); imageCardView.setMainImageDimensions(widthPixels, heightPixels); return (new ViewHolder(imageCardView)); }
Example #24
Source File: CardPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) { ImageCardView cardView = (ImageCardView) viewHolder.view; // Remove references to images so that the garbage collector can free up memory. cardView.setBadgeImage(null); cardView.setMainImage(null); }
Example #25
Source File: CardPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
private void updateCardBackgroundColor(ImageCardView view, boolean selected) { int color = selected ? mSelectedBackgroundColor : mDefaultBackgroundColor; // Both background colors should be set because the view's // background is temporarily visible during animations. view.setBackgroundColor(color); view.findViewById(R.id.info_field).setBackgroundColor(color); }
Example #26
Source File: VideoContentCardPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
private static void updateCardBackgroundColor(ImageCardView view, boolean selected) { int color = selected ? sSelectedBackgroundColor : sDefaultBackgroundColor; // Both background colors should be set because the view's background is temporarily visible // during animations. view.setBackgroundColor(color); view.findViewById(R.id.info_field).setBackgroundColor(color); }
Example #27
Source File: IconCardInChannelPublishPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override protected ImageCardView onCreateView() { final ImageCardView imageCardView = super.onCreateView(); final ImageView image = imageCardView.getMainImageView(); image.setBackgroundResource(R.drawable.icon_focused); image.getBackground().setAlpha(0); imageCardView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { animateIconBackground(image.getBackground(), hasFocus); } }); return imageCardView; }
Example #28
Source File: ImageCardViewPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@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 #29
Source File: ImageCardViewPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override protected ImageCardView onCreateView() { ImageCardView imageCardView = new ImageCardView(getContext()); // imageCardView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Toast.makeText(getContext(), "Clicked on ImageCardView", Toast.LENGTH_SHORT).show(); // } // }); return imageCardView; }
Example #30
Source File: IconCardPresenter.java From tv-samples with Apache License 2.0 | 5 votes |
@Override protected ImageCardView onCreateView() { final ImageCardView imageCardView = super.onCreateView(); final ImageView image = imageCardView.getMainImageView(); image.setBackgroundResource(R.drawable.icon_focused); image.getBackground().setAlpha(0); imageCardView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { animateIconBackground(image.getBackground(), hasFocus); } }); return imageCardView; }