Java Code Examples for android.support.v17.leanback.widget.ImageCardView#setMainImageDimensions()
The following examples show how to use
android.support.v17.leanback.widget.ImageCardView#setMainImageDimensions() .
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: GameRowPresenter.java From citra_android with GNU General Public License v3.0 | 6 votes |
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { // Create a new view. ImageCardView gameCard = new ImageCardView(parent.getContext()); gameCard.setMainImageAdjustViewBounds(true); gameCard.setMainImageDimensions(48, 48); gameCard.setMainImageScaleType(ImageView.ScaleType.CENTER_CROP); gameCard.setFocusable(true); gameCard.setFocusableInTouchMode(true); // Use that view to create a ViewHolder. return new TvGameViewHolder(gameCard); }
Example 2
Source File: CardPresenter.java From BuildingForAndroidTV with MIT License | 6 votes |
@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()); } }
Example 3
Source File: VideoContentCardPresenter.java From leanback-showcase 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 4
Source File: VideoCardPresenter.java From leanback-showcase 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 5
Source File: CardPresenter.java From leanback-extensions with Apache License 2.0 | 6 votes |
@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()); } }
Example 6
Source File: CardPresenter.java From leanback-homescreen-channels with Apache License 2.0 | 6 votes |
@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()); } }
Example 7
Source File: ImgCardPresenter.java From AndroidTVLauncher with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); if (item instanceof MediaModel) { MediaModel mediaModel = (MediaModel) item; cardView.setTitleText(mediaModel.getTitle()); cardView.setContentText(mediaModel.getContent()); Glide.with(cardView.getMainImageView().getContext()) .load(mediaModel.getImageUrl()) .crossFade() .into(cardView.getMainImageView()); } }
Example 8
Source File: FunctionCardPresenter.java From AndroidTVLauncher with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setMainImageDimensions(CARD_WIDTH,CARD_HEIGHT); FunctionModel functionModel = (FunctionModel) item; cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE); cardView.getMainImageView().setImageResource(functionModel.getIcon()); cardView.setTitleText(functionModel.getName()); }
Example 9
Source File: AppCardPresenter.java From AndroidTVLauncher with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setMainImageDimensions(CARD_WIDTH,CARD_HEIGHT); AppModel appBean = (AppModel) item; cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE); cardView.getMainImageView().setImageDrawable(appBean.getIcon()); cardView.setTitleText(appBean.getName()); }
Example 10
Source File: ApkPresenter.java From TvAppRepo with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { Apk application = (Apk) item; final ImageCardView cardView = (ImageCardView) viewHolder.view; Log.d(TAG, "onBindViewHolder"); if (application.getBanner() != null) { cardView.setTitleText(application.getName()); cardView.setContentText(mContext.getString(R.string.version_number, application.getVersionName())); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); Glide.with(viewHolder.view.getContext()) .load(!application.getBanner().isEmpty() ? application.getBanner() : application.getIcon()) .asBitmap() .into(new BitmapImageViewTarget(cardView.getMainImageView()) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); Palette.generateAsync(resource, new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { // Here's your generated palette if (palette.getDarkVibrantSwatch() != null) { cardView.findViewById(R.id.info_field).setBackgroundColor( palette.getDarkVibrantSwatch().getRgb()); } } }); } }); } }
Example 11
Source File: OptionsCardPresenter.java From TvAppRepo with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { final SettingOption option = (SettingOption) item; final ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setMainImage(option.getDrawable()); cardView.setTitleText(option.getText()); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER); }
Example 12
Source File: DownloadedFilesPresenter.java From TvAppRepo with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { final File downloadedApk = (File) item; final ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setMainImage(contextThemeWrapper.getDrawable(R.drawable.download)); cardView.setTitleText(downloadedApk.getName()); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER); }
Example 13
Source File: SettingsRowPresenter.java From citra_android with GNU General Public License v3.0 | 5 votes |
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { // Create a new view. ImageCardView settingsCard = new ImageCardView(parent.getContext()); settingsCard.setMainImageAdjustViewBounds(true); settingsCard.setMainImageDimensions(192, 160); settingsCard.setFocusable(true); settingsCard.setFocusableInTouchMode(true); // Use that view to create a ViewHolder. return new TvSettingsViewHolder(settingsCard); }
Example 14
Source File: CardPresenter.java From VCL-Android with Apache License 2.0 | 5 votes |
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { ImageCardView cardView = new ImageCardView(sContext); cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); cardView.setBackgroundColor(mRes.getColor(R.color.lb_details_overview_bg_color)); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); return new ViewHolder(cardView); }
Example 15
Source File: EpisodePresenter.java From iview-android-tv with MIT License | 5 votes |
protected ImageCardView getCardView(Context context) { ImageCardView card = new ImageCardView(context); card.setFocusable(true); card.setFocusableInTouchMode(true); card.setMainImageScaleType(ImageView.ScaleType.CENTER_CROP); Point size = getCardSize(context); card.setMainImageDimensions(size.x, size.y); return card; }
Example 16
Source File: OptionsCardPresenter.java From CumulusTV with MIT License | 5 votes |
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { final Option option = (Option) item; final ImageCardView cardView = (ImageCardView) viewHolder.view; if (DEFAULT_BANNER) { cardView.setMainImage(contextThemeWrapper.getDrawable(R.drawable.c_banner_3_2)); } else { cardView.setMainImage(option.getDrawable()); } cardView.setTitleText(option.getText()); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER); cardView.findViewById(R.id.info_field).setBackgroundColor( ContextCompat.getColor(contextThemeWrapper, R.color.colorPrimaryDark)); }
Example 17
Source File: CardPresenter.java From alltv with MIT License | 4 votes |
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { ChannelData tvCh = (ChannelData) item; ImageCardView cardView = (ImageCardView) viewHolder.view; //Log.d(TAG, "onBindViewHolder"); if (tvCh.getStillImageUrl() != null) { ArrayList<EPGData> epgData = tvCh.getEPG(); Date date = new Date(); Boolean isAdultContent = false; for(int i=0; i<epgData.size(); i++) { if(date.compareTo(epgData.get(i).getEndTime()) < 0) { tvCh.setProgramName(epgData.get(i).getProgramName()); isAdultContent = epgData.get(i).isAdultContent(); break; } } if(tvCh.getProgramName().equals("") || isAdultContent) cardView.setTitleText(tvCh.getTitle()); else cardView.setTitleText(tvCh.getTitle() + " - " + tvCh.getProgramName()); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); int ret = tvCh.getFavorite(); if(ret == 0) cardView.setBadgeImage(null); else if(ret == 1) cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.star_icon, null)); else if(ret == 2) cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.wavve_icon_24, null)); else if(ret == 3) cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.tving_icon_24, null)); else if(ret == 4) cardView.setBadgeImage(cardView.getResources().getDrawable(R.drawable.oksusu_icon_24, null)); Picasso.get().load(tvCh.getStillImageUrl()) .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) .into(cardView.getMainImageView()); } }