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

The following examples show how to use android.support.v17.leanback.widget.ImageCardView#setFocusableInTouchMode() . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: CardPresenter.java    From leanback-homescreen-channels 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 CardViewHolder(cardView);
}
 
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
Source File: EpisodePresenter.java    From iview-android-tv with MIT License 5 votes vote down vote up
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 17
Source File: CardPresenter.java    From CumulusTV with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    mContext = parent.getContext();
    sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);

    ImageCardView cardView = new ImageCardView(mContext);

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}
 
Example 18
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 19
Source File: CardPresenter.java    From alltv with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    // Log.d(TAG, "onCreateViewHolder");

    sDefaultBackgroundColor =
            ContextCompat.getColor(parent.getContext(), R.color.default_background);
    sSelectedBackgroundColor =
            ContextCompat.getColor(parent.getContext(), 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
     */

    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 20
Source File: VideoPlayerView.java    From iview-android-tv with MIT License 4 votes vote down vote up
public VideoPlayerView(Context context, PlaybackControls controller, View root) {
    mContext = context;
    mediaController = controller;
    shutterView = root.findViewById(R.id.shutter);
    videoFrame = (AspectRatioFrameLayout) root.findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) root.findViewById(R.id.surface_view);
    debugTextView = (TextView) root.findViewById(R.id.debug_text_view);
    debugView = root.findViewById(R.id.debug_view);
    statusTextView = (TextView) root.findViewById(R.id.status);
    playerStateTextView = (TextView) root.findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) root.findViewById(R.id.subtitles);
    nextEpisodeCard = root.findViewById(R.id.next_episode_card);
    episodeDetails = root.findViewById(R.id.episode_details);
    episodeTitle = (TextView) root.findViewById(R.id.episode_title);
    seriesTitle = (TextView) root.findViewById(R.id.series_title);
    duration = (TextView) root.findViewById(R.id.duration);

    ImageCardView card = (ImageCardView) root.findViewById(R.id.next_episode);
    card.setFocusable(true);
    card.setFocusableInTouchMode(true);
    card.setInfoVisibility(View.VISIBLE);
    card.setExtraVisibility(View.VISIBLE);
    card.setInfoAreaBackgroundColor(context.getResources().getColor(R.color.black_900));
    Point size = new Point(context.getResources().getDimensionPixelSize(R.dimen.card_width),
            context.getResources().getDimensionPixelSize(R.dimen.card_height));
    nextEpisode = new EpisodeCardView(context, card, size, false);
    nextEpisode.getImageCardView().setCardType(BaseCardView.CARD_TYPE_INFO_OVER);

    debugView.setVisibility(View.GONE);

    root.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return handleTouchEvents(view, motionEvent);
        }
    });
    root.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return handleKeyEvents(v, keyCode, event);
        }
    });
}