use of android.support.v17.leanback.widget.PresenterSelector in project android-UniversalMusicPlayer by googlesamples.
the class TvPlaybackFragment method addPlaybackControlsRow.
private void addPlaybackControlsRow(MediaMetadataCompat metadata) {
mPlaybackControlsRow = new PlaybackControlsRow(new MutableMediaMetadataHolder(metadata));
mRowsAdapter.add(mPlaybackControlsRow);
resetPlaybackRow();
ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector();
mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
mPlayPauseAction = new PlayPauseAction(getActivity());
mSkipNextAction = new PlaybackControlsRow.SkipNextAction(getActivity());
mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(getActivity());
mPrimaryActionsAdapter.add(mSkipPreviousAction);
mPrimaryActionsAdapter.add(mPlayPauseAction);
mPrimaryActionsAdapter.add(mSkipNextAction);
}
use of android.support.v17.leanback.widget.PresenterSelector in project butter-android by butterproject.
the class TVSearchFragment method createLoadingRow.
private ListRow createLoadingRow() {
final HeaderItem loadingHeader = new HeaderItem(getString(R.string.search_results));
ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
presenterSelector.addClassPresenter(MediaCardItem.class, new MediaCardPresenter(getActivity(), picasso));
presenterSelector.addClassPresenter(LoadingCardItem.class, new LoadingCardPresenter(getActivity()));
ArrayObjectAdapter loadingRowAdapter = new ArrayObjectAdapter(presenterSelector);
loadingRowAdapter.add(new LoadingCardItem());
return new ListRow(loadingHeader, loadingRowAdapter);
}
use of android.support.v17.leanback.widget.PresenterSelector in project butter-android by butterproject.
the class TVMediaGridFragment method setupUi.
private void setupUi() {
VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
gridPresenter.setNumberOfColumns(NUM_COLUMNS);
setGridPresenter(gridPresenter);
ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
presenterSelector.addClassPresenter(MediaCardItem.class, new MediaCardPresenter(getActivity(), picasso));
presenterSelector.addClassPresenter(LoadingCardItem.class, new LoadingCardPresenter(getActivity()));
adapter = new GridPagingAdapter(presenterSelector);
setAdapter(adapter);
pagingManager = new GridPagingManager<>();
pagingManager.init(NUM_COLUMNS, adapter, this);
setOnItemViewClickedListener(this);
setOnItemViewSelectedListener(this);
}
use of android.support.v17.leanback.widget.PresenterSelector in project ring-client-android by savoirfairelinux.
the class MainFragment method createRow.
private Row createRow(String titleSection, List<Card> cards, boolean shadow) {
CardRow row = new CardRow(CardRow.TYPE_DEFAULT, shadow, titleSection, cards);
PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
for (Card card : cards) {
listRowAdapter.add(card);
}
return new CardListRow(new HeaderItem(HEADER_MISC, titleSection), listRowAdapter, row);
}
use of android.support.v17.leanback.widget.PresenterSelector in project ring-client-android by savoirfairelinux.
the class CardPresenterSelector method getPresenter.
@Override
public Presenter getPresenter(Object item) {
if (!(item instanceof Card))
throw new RuntimeException(String.format("The PresenterSelector only supports data items of type '%s'", Card.class.getName()));
Card card = (Card) item;
Presenter presenter = presenters.get(card.getType());
if (presenter == null) {
switch(card.getType()) {
case ABOUT_VERSION:
case ABOUT_CONTRIBUTOR:
case ABOUT_LICENCES:
case ACCOUNT_ADD_DEVICE:
case ACCOUNT_EDIT_PROFILE:
case ACCOUNT_SETTINGS:
presenter = new IconCardPresenter(mContext);
break;
case SEARCH_RESULT:
presenter = new ContactCardPresenter(mContext, R.style.SearchCardTheme);
break;
case CONTACT:
presenter = new ContactCardPresenter(mContext, R.style.ContactCardTheme);
break;
case CONTACT_ONLINE:
presenter = new ContactCardPresenter(mContext, R.style.ContactCardOnlineTheme);
break;
case CONTACT_WITH_USERNAME:
presenter = new ContactCardPresenter(mContext, R.style.ContactCompleteCardTheme);
break;
case CONTACT_WITH_USERNAME_ONLINE:
presenter = new ContactCardPresenter(mContext, R.style.ContactCompleteCardOnlineTheme);
break;
case CONTACT_REQUEST:
presenter = new ContactRequestCardPresenter(mContext, R.style.ContactCardTheme);
break;
case CONTACT_REQUEST_WITH_USERNAME:
presenter = new ContactRequestCardPresenter(mContext, R.style.ContactCompleteCardTheme);
break;
default:
throw new InvalidParameterException("Uncatched card type");
}
}
presenters.put(card.getType(), presenter);
return presenter;
}
Aggregations