use of android.support.v17.leanback.widget.OnActionClickedListener in project android-UniversalMusicPlayer by googlesamples.
the class TvPlaybackFragment method setupRows.
private void setupRows() {
PlaybackControlsRowPresenter playbackControlsRowPresenter;
playbackControlsRowPresenter = new PlaybackControlsRowPresenter(new DescriptionPresenter());
playbackControlsRowPresenter.setOnActionClickedListener(new OnActionClickedListener() {
public void onActionClicked(Action action) {
if (getActivity() == null) {
return;
}
MediaControllerCompat controller = getActivity().getSupportMediaController();
if (controller == null) {
return;
}
MediaControllerCompat.TransportControls controls = controller.getTransportControls();
if (action.getId() == mPlayPauseAction.getId()) {
if (mPlayPauseAction.getIndex() == PlayPauseAction.PLAY) {
controls.play();
} else {
controls.pause();
}
} else if (action.getId() == mSkipNextAction.getId()) {
controls.skipToNext();
resetPlaybackRow();
} else if (action.getId() == mSkipPreviousAction.getId()) {
controls.skipToPrevious();
resetPlaybackRow();
}
if (action instanceof PlaybackControlsRow.MultiAction) {
((PlaybackControlsRow.MultiAction) action).nextIndex();
notifyChanged(action);
}
}
});
mPresenterSelector.addClassPresenter(PlaybackControlsRow.class, playbackControlsRowPresenter);
}
Aggregations