Search in sources :

Example 1 with PresenterSelector

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);
}
Also used : SkipPreviousAction(android.support.v17.leanback.widget.PlaybackControlsRow.SkipPreviousAction) PlayPauseAction(android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) SkipNextAction(android.support.v17.leanback.widget.PlaybackControlsRow.SkipNextAction) ControlButtonPresenterSelector(android.support.v17.leanback.widget.ControlButtonPresenterSelector) PlaybackControlsRow(android.support.v17.leanback.widget.PlaybackControlsRow)

Example 2 with PresenterSelector

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);
}
Also used : LoadingCardPresenter(butter.droid.tv.presenters.LoadingCardPresenter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) LoadingCardItem(butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem) ClassPresenterSelector(android.support.v17.leanback.widget.ClassPresenterSelector) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter) ListRow(android.support.v17.leanback.widget.ListRow)

Example 3 with PresenterSelector

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);
}
Also used : GridPagingAdapter(butter.droid.tv.manager.internal.paging.GridPagingAdapter) VerticalGridPresenter(android.support.v17.leanback.widget.VerticalGridPresenter) LoadingCardPresenter(butter.droid.tv.presenters.LoadingCardPresenter) ClassPresenterSelector(android.support.v17.leanback.widget.ClassPresenterSelector) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter)

Example 4 with PresenterSelector

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);
}
Also used : CardPresenterSelector(cx.ring.tv.cards.CardPresenterSelector) ShadowRowPresenterSelector(cx.ring.tv.cards.ShadowRowPresenterSelector) PresenterSelector(android.support.v17.leanback.widget.PresenterSelector) CardListRow(cx.ring.tv.cards.CardListRow) CardRow(cx.ring.tv.cards.CardRow) CardPresenterSelector(cx.ring.tv.cards.CardPresenterSelector) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) VCard(ezvcard.VCard) IconCard(cx.ring.tv.cards.iconcards.IconCard) ContactRequestCard(cx.ring.tv.cards.contactrequests.ContactRequestCard) ContactCard(cx.ring.tv.cards.contacts.ContactCard) Card(cx.ring.tv.cards.Card)

Example 5 with PresenterSelector

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;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ContactRequestCardPresenter(cx.ring.tv.cards.contactrequests.ContactRequestCardPresenter) ContactCardPresenter(cx.ring.tv.cards.contacts.ContactCardPresenter) IconCardPresenter(cx.ring.tv.cards.iconcards.IconCardPresenter) Presenter(android.support.v17.leanback.widget.Presenter) ContactRequestCardPresenter(cx.ring.tv.cards.contactrequests.ContactRequestCardPresenter) IconCardPresenter(cx.ring.tv.cards.iconcards.IconCardPresenter) ContactCardPresenter(cx.ring.tv.cards.contacts.ContactCardPresenter)

Aggregations

ArrayObjectAdapter (android.support.v17.leanback.widget.ArrayObjectAdapter)5 ClassPresenterSelector (android.support.v17.leanback.widget.ClassPresenterSelector)4 HeaderItem (android.support.v17.leanback.widget.HeaderItem)3 LoadingCardPresenter (butter.droid.tv.presenters.LoadingCardPresenter)3 MediaCardPresenter (butter.droid.tv.presenters.MediaCardPresenter)3 ListRow (android.support.v17.leanback.widget.ListRow)2 LoadingCardItem (butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem)2 Context (android.content.Context)1 ControlButtonPresenterSelector (android.support.v17.leanback.widget.ControlButtonPresenterSelector)1 DetailsOverviewRow (android.support.v17.leanback.widget.DetailsOverviewRow)1 PlaybackControlsRow (android.support.v17.leanback.widget.PlaybackControlsRow)1 PlayPauseAction (android.support.v17.leanback.widget.PlaybackControlsRow.PlayPauseAction)1 SkipNextAction (android.support.v17.leanback.widget.PlaybackControlsRow.SkipNextAction)1 SkipPreviousAction (android.support.v17.leanback.widget.PlaybackControlsRow.SkipPreviousAction)1 Presenter (android.support.v17.leanback.widget.Presenter)1 PresenterSelector (android.support.v17.leanback.widget.PresenterSelector)1 VerticalGridPresenter (android.support.v17.leanback.widget.VerticalGridPresenter)1 GridPagingAdapter (butter.droid.tv.manager.internal.paging.GridPagingAdapter)1 Card (cx.ring.tv.cards.Card)1 CardListRow (cx.ring.tv.cards.CardListRow)1