@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); }
@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()); } }
@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); } }
@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()); }
@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()); }
@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); }
@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); } }
@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); }
@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); }
@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); }
@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); }
@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); } }
@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); } }
@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); }
@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 } }
@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(); } }
@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 CardViewHolder(cardView); }
@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()); } }
private void openDetailsActivity(Video video, Presenter.ViewHolder itemViewHolder) { Intent intent = new Intent(getActivity(), VideoDetailsActivity.class); intent.putExtra(VideoDetailsFragment.EXTRA_VIDEO, video); intent.putExtra(VideoDetailsFragment.EXTRA_FORCE_VIDEO_SELECTION, true); View sourceView = null; if (itemViewHolder.view instanceof ImageCardView) { sourceView = ((ImageCardView) itemViewHolder.view).getMainImageView(); } else if (itemViewHolder instanceof ListPresenter.ListViewHolder){ sourceView = ((ListPresenter.ListViewHolder)itemViewHolder).getImageView(); } Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), sourceView, VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivityForResult(intent, ListingActivity.REQUEST_INFO_ACTIVITY, bundle); }
public static void showVideoDetails(Activity activity, Video video, Presenter.ViewHolder itemViewHolder, boolean animate, boolean forceSelection, boolean shouldLoadBackdrop, long listId) { Intent intent = new Intent(activity, VideoDetailsActivity.class); intent.putExtra(VideoDetailsFragment.EXTRA_VIDEO, video); intent.putExtra(VideoDetailsFragment.EXTRA_LIST_ID, listId); intent.putExtra(VideoDetailsFragment.EXTRA_FORCE_VIDEO_SELECTION, forceSelection); intent.putExtra(VideoDetailsFragment.EXTRA_SHOULD_LOAD_BACKDROP,shouldLoadBackdrop); View sourceView = null; if (itemViewHolder.view instanceof ImageCardView) { sourceView = ((ImageCardView) itemViewHolder.view).getMainImageView(); } else if (itemViewHolder instanceof ListPresenter.ListViewHolder){ sourceView = ((ListPresenter.ListViewHolder)itemViewHolder).getImageView(); } if(animate) { Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( activity, sourceView, VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); activity.startActivity(intent,bundle); } else{ activity.startActivity(intent); } }
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { ScraperTrailer box = (ScraperTrailer)item; final VideoViewHolder vh = (VideoViewHolder)viewHolder; final ImageCardView card = vh.getImageCardView(); card.setMainImage(mContext.getResources().getDrawable(TrailerServiceIconFactory.getIconForService(box.mSite)), false); card.setMainImageScaleType(ImageView.ScaleType.CENTER); card.setTitleText(box.mName); Picasso.get() .load(getImageUrl(box)) .resize(getWidth(mContext), getHeight(mContext)) // better resize to card size, since backdrop files are pretty large .centerCrop() .error(R.drawable.filetype_new_image) .into(vh.getImageCardView().getMainImageView()); }
@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()); } }
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Context context = parent.getContext(); mDefaultBackgroundColor = ContextCompat.getColor(context, R.color.primary); mSelectedBackgroundColor = ContextCompat.getColor(context, R.color.primary_dark); mDefaultCardImage = ContextCompat.getDrawable(context, R.drawable.card_default); 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); }
@Override public Presenter.ViewHolder onCreateViewHolder(ViewGroup viewGroup) { if (DEBUG) Log.d(TAG, "onCreateViewHolder"); ImageCardView cardView = new ImageCardView(mMainActivity); cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); cardView.setMainImageAdjustViewBounds(false); Resources res = mMainActivity.getResources(); cardView.setMainImageDimensions( res.getDimensionPixelSize(R.dimen.card_image_layout_width), res.getDimensionPixelSize(R.dimen.card_image_layout_height)); return new Presenter.ViewHolder(cardView); }