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);
}
});
}
Aggregations