Java Code Examples for android.support.v17.leanback.widget.ImageCardView#setOnFocusChangeListener()

The following examples show how to use android.support.v17.leanback.widget.ImageCardView#setOnFocusChangeListener() . 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: 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 2
Source File: TvShowsCardPresenter.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 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: IconCardInChannelPublishPresenter.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 5
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;
}