Search in sources :

Example 1 with OnItemViewClickedListener

use of android.support.v17.leanback.widget.OnItemViewClickedListener in project android-UniversalMusicPlayer by googlesamples.

the class TvBrowseFragment method setupEventListeners.

private void setupEventListeners() {
    setOnItemViewClickedListener(new OnItemViewClickedListener() {

        @Override
        public void onItemClicked(Presenter.ViewHolder viewHolder, Object clickedItem, RowPresenter.ViewHolder viewHolder2, Row row) {
            if (clickedItem instanceof MediaBrowserCompat.MediaItem) {
                MediaItem item = (MediaItem) clickedItem;
                if (item.isPlayable()) {
                    LogHelper.w(TAG, "Ignoring click on PLAYABLE MediaItem in" + "TvBrowseFragment. mediaId=", item.getMediaId());
                    return;
                }
                Intent intent = new Intent(getActivity(), TvVerticalGridActivity.class);
                intent.putExtra(TvBrowseActivity.SAVED_MEDIA_ID, item.getMediaId());
                intent.putExtra(TvBrowseActivity.BROWSE_TITLE, item.getDescription().getTitle());
                startActivity(intent);
            } else if (clickedItem instanceof MediaSessionCompat.QueueItem) {
                MediaSessionCompat.QueueItem item = (MediaSessionCompat.QueueItem) clickedItem;
                MediaControllerCompat mediaController = getActivity().getSupportMediaController();
                if (!QueueHelper.isQueueItemPlaying(getActivity(), item)) {
                    mediaController.getTransportControls().skipToQueueItem(item.getQueueId());
                }
                Intent intent = new Intent(getActivity(), TvPlaybackActivity.class);
                startActivity(intent);
            }
        }
    });
    setOnSearchClickedListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            LogHelper.d(TAG, "In-app search");
            // TODO: implement in-app search
            Intent intent = new Intent(getActivity(), TvBrowseActivity.class);
            startActivity(intent);
        }
    });
}
Also used : Intent(android.content.Intent) OnItemViewClickedListener(android.support.v17.leanback.widget.OnItemViewClickedListener) MediaSessionCompat(android.support.v4.media.session.MediaSessionCompat) View(android.view.View) MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) MediaItem(android.support.v4.media.MediaBrowserCompat.MediaItem) RowPresenter(android.support.v17.leanback.widget.RowPresenter) Presenter(android.support.v17.leanback.widget.Presenter) ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) MediaItem(android.support.v4.media.MediaBrowserCompat.MediaItem) ListRow(android.support.v17.leanback.widget.ListRow) Row(android.support.v17.leanback.widget.Row) MediaControllerCompat(android.support.v4.media.session.MediaControllerCompat) RowPresenter(android.support.v17.leanback.widget.RowPresenter) ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter)

Aggregations

Intent (android.content.Intent)1 ListRow (android.support.v17.leanback.widget.ListRow)1 ListRowPresenter (android.support.v17.leanback.widget.ListRowPresenter)1 OnItemViewClickedListener (android.support.v17.leanback.widget.OnItemViewClickedListener)1 Presenter (android.support.v17.leanback.widget.Presenter)1 Row (android.support.v17.leanback.widget.Row)1 RowPresenter (android.support.v17.leanback.widget.RowPresenter)1 MediaBrowserCompat (android.support.v4.media.MediaBrowserCompat)1 MediaItem (android.support.v4.media.MediaBrowserCompat.MediaItem)1 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)1 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)1 View (android.view.View)1