android.support.v17.leanback.widget.ImageCardView Java Examples

The following examples show how to use android.support.v17.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: CardPresenter.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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);
}
 
Example #2
Source File: VideoContentCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: CardPresenter.java    From Amphitheatre with Apache License 2.0 6 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    final ImageCardView cardView = new ImageCardView(mContext);

    cardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, final boolean isFocused) {
            setFocusState(cardView, isFocused, view);
        }
    });

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    cardView.setBackgroundColor(mContext.getResources().getColor(R.color.fastlane_background));
    return new ViewHolder(cardView);
}
 
Example #4
Source File: CardPresenter.java    From leanback-extensions with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: VideoContentCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: SearchFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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, "Movie: " + movie.toString());
        Intent intent = new Intent(getActivity(), MovieDetailsActivity.class);
        intent.putExtra(MovieDetailsActivity.MOVIE, movie);

        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(),
                ((ImageCardView) itemViewHolder.view).getMainImageView(),
                MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
        getActivity().startActivity(intent, bundle);
    } else {
        Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT)
                .show();
    }
}
 
Example #7
Source File: SettingsIconPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: MainFragment.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, final Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {

    if (item instanceof Apk) {
        Apk application = (Apk) item;
        Log.d(TAG, "Item: " + item.toString());
        Intent intent = new Intent(getActivity(), DetailsActivity.class);
        intent.putExtra(DetailsActivity.APPLICATION, application.toString());

        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(),
                ((ImageCardView) itemViewHolder.view).getMainImageView(),
                DetailsActivity.SHARED_ELEMENT_NAME).toBundle();
        getActivity().startActivity(intent, bundle);
    } else if (item instanceof SettingOption) {
        ((SettingOption) item).getClickListener().onClick();
    } else if (item instanceof File) {
        Log.d(TAG, "Open file " + ((File) item).getAbsolutePath());
        mApkDownloadHelper.install((File) item);
    } else if (item instanceof ResolveInfo) {
        GenerateShortcutHelper.begin(mMainActivity, (ResolveInfo) item);
    }
}
 
Example #9
Source File: VideoCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: ApkPresenter.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
@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) {
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    return new ViewHolder(cardView);
}
 
Example #11
Source File: CustomRowsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);

	loadVideoData();
	setCustomPadding();
	setOnItemViewClickedListener(new OnItemViewClickedListener() {
		@Override
		public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
			Movie movie = (Movie) item;
			Intent intent = new Intent(getActivity(), MovieDetailsActivity.class);
			intent.putExtra(MovieDetailsActivity.MOVIE, movie);

			Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
					getActivity(),
					((ImageCardView) itemViewHolder.view).getMainImageView(),
					MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
			getActivity().startActivity(intent, bundle);
		}
	});
}
 
Example #12
Source File: CardPresenter.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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 #13
Source File: GameRowPresenter.java    From citra_android with GNU General Public License v3.0 6 votes vote down vote up
@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 #14
Source File: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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(), MovieDetailsActivity.class);
        intent.putExtra(MovieDetailsActivity.MOVIE, movie);

        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(),
                ((ImageCardView) itemViewHolder.view).getMainImageView(),
                MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
        getActivity().startActivity(intent, bundle);
    }
}
 
Example #15
Source File: VideoCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: CardPresenter.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageCardView cardView = new ImageCardView( parent.getContext() );
    cardView.setFocusable( true );
    cardView.setFocusableInTouchMode( true );
    return new ViewHolder(cardView);
}
 
Example #17
Source File: CardPresenter.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View view) {
    super(view);
    mCardView = (ImageCardView) view;
    mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(mCardView.getContext());

    Utils.checkPrefs(mSharedPrefs);
}
 
Example #18
Source File: CardPresenter.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@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 #19
Source File: CardPresenter.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");
    mContext = parent.getContext();

    ImageCardView cardView = new ImageCardView(mContext);
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    cardView.setBackgroundColor(mContext.getResources().getColor(R.color.fastlane_background));
    return new ViewHolder(cardView);
}
 
Example #20
Source File: ImageCardViewPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: VideoCardViewPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: IconCardPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@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 #23
Source File: DownloadedFilesPresenter.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
@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 #24
Source File: EpisodeCardView.java    From iview-android-tv with MIT License 5 votes vote down vote up
public EpisodeCardView(Context context, ImageCardView view, Point s, boolean showCover) {
    super(view);
    mContext = context;
    card = view;
    size = s;
    canShowCover = showCover;
    addProgressBar(context, view);
}
 
Example #25
Source File: CardPresenter.java    From alltv with MIT License 5 votes vote down vote up
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 #26
Source File: CardPresenter.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup) {

    Log.d("onCreateViewHolder", "creating viewholder");
    mContext = viewGroup.getContext();
    ImageCardView cardView = new ImageCardView(mContext);
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    ((TextView) cardView.findViewById(R.id.content_text)).setTextColor(Color.LTGRAY);
    return new ViewHolder(cardView);
}
 
Example #27
Source File: VideoContentCardPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: VideoCardPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onUnbindViewHolder(ViewHolder viewHolder) {
    ImageCardView cardView = (ImageCardView) viewHolder.view;

    cardView.setBadgeImage(null);
    cardView.setMainImage(null);
}
 
Example #29
Source File: CardPresenter.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");
    mContext = parent.getContext();

    ImageCardView cardView = new ImageCardView(mContext);
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    cardView.setBackgroundColor(mContext.getResources().getColor(R.color.fastlane_background));
    return new ViewHolder(cardView);
}
 
Example #30
Source File: CategoryPresenter.java    From iview-android-tv with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageCardView card = new ImageCardView(parent.getContext());
    card.setFocusable(true);
    card.setFocusableInTouchMode(true);
    return new CategoryCardView(parent.getContext(), card);
}