androidx.leanback.widget.PresenterSelector Java Examples

The following examples show how to use androidx.leanback.widget.PresenterSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoGridExampleFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private void setupRowAdapter() {
    VerticalGridPresenter videoGridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    videoGridPresenter.setNumberOfColumns(COLUMNS);
    // note: The click listeners must be called before setGridPresenter for the event listeners
    // to be properly registered on the viewholders.
    setOnItemViewSelectedListener(this);
    setOnItemViewClickedListener(this);
    setGridPresenter(videoGridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    // VideoCardViewPresenter videoCardViewPresenter = new VideoCardViewPresenter(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
        }
    }, 1000);
}
 
Example #2
Source File: GridExampleFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private void setupRowAdapter() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    gridPresenter.setNumberOfColumns(COLUMNS);
    setGridPresenter(gridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
            startEntranceTransition();
        }
    }, 1000);
}
 
Example #3
Source File: CardExampleFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private Row createCardRow(final CardRow cardRow) {
    switch (cardRow.getType()) {
        case CardRow.TYPE_SECTION_HEADER:
            return new SectionRow(new HeaderItem(cardRow.getTitle()));
        case CardRow.TYPE_DIVIDER:
            return new DividerRow();
        case CardRow.TYPE_DEFAULT:
        default:
            // Build main row using the ImageCardViewPresenter.
            PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
            for (Card card : cardRow.getCards()) {
                listRowAdapter.add(card);
            }
            return new CardListRow(new HeaderItem(cardRow.getTitle()), listRowAdapter, cardRow);
    }
}
 
Example #4
Source File: LiveDataDetailFragmentUiModule.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Provides
@PerFragment
public FullWidthDetailsOverviewSharedElementHelper provideHelper(Activity activity,
        PresenterSelector mPs, DetailsOverviewRow row, OnActionClickedListener listener) {
    FullWidthDetailsOverviewSharedElementHelper mHelper =
            new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(activity,
            LiveDataDetailActivity.SHARED_ELEMENT_NAME);

    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setListener(mHelper);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setParticipatingEntranceTransition(false);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setOnActionClickedListener(listener);
    return mHelper;

}
 
Example #5
Source File: PresenterModule.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@PerFragment
@Provides
PresenterSelector providePresenterSelector(final Map<Class<?>, Presenter> map) {

    return new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            Class<?> cls = item.getClass();
            return map.get(cls);
        }

        @Override
        public Presenter[] getPresenters() {
            return map.values().toArray(new Presenter[map.size()]);
        }
    };
}
 
Example #6
Source File: MainFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
private void setupUIElements() {
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.videos_by_google_banner, null));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);

    // Set fastLane (or headers) background color
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
 
Example #7
Source File: MainFragment.java    From androidtv-Leanback with Apache License 2.0 6 votes vote down vote up
private void setupUIElements() {
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.videos_by_google_banner, null));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);

    // Set fastLane (or headers) background color
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
 
Example #8
Source File: MainFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private ListRow createCardRow(CardRow cardRow) {
    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cardRow.getCards()) {
        listRowAdapter.add(card);
    }
    return new ListRow(listRowAdapter);
}
 
Example #9
Source File: AdapterModule.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@DetailFragmentArrayObjectAdapterForRowsQualifier
@PerFragment
@Provides
ArrayObjectAdapter provideRowsArrayObjectAdapter(DetailsOverviewRow detailsOverviewRow, ListRow relatedRow, PresenterSelector mps) {
    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(mps);
    rowsAdapter.add(detailsOverviewRow);
    rowsAdapter.add(relatedRow);
    return rowsAdapter;
}
 
Example #10
Source File: AdapterModule.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@SearchFragmentArrayObjectAdapterForRowsQualifier
@PerFragment
@Provides
ArrayObjectAdapter provideRowsArrayObjectAdapterInSearchFragment( ListRow relatedRow, PresenterSelector mps) {
    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(mps.getPresenter(relatedRow));

    rowsAdapter.add(relatedRow);
    return rowsAdapter;
}
 
Example #11
Source File: PageAndListRowFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private Row createCardRow(CardRow cardRow) {
    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cardRow.getCards()) {
        adapter.add(card);
    }

    HeaderItem headerItem = new HeaderItem(cardRow.getTitle());
    return new CardListRow(headerItem, adapter, cardRow);
}
 
Example #12
Source File: ItemRowAdapter.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
public ItemRowAdapter(ItemQuery query, int chunkSize, boolean preferParentThumb, boolean staticHeight, PresenterSelector presenter, ArrayObjectAdapter parent, QueryType queryType) {
    super(presenter);
    mParent = parent;
    mQuery = query;
    mQuery.setUserId(TvApp.getApplication().getCurrentUser().getId());
    this.chunkSize = chunkSize;
    this.preferParentThumb = preferParentThumb;
    this.staticHeight = staticHeight;
    if (chunkSize > 0) {
        mQuery.setLimit(chunkSize);
    }
    this.queryType = queryType;
    add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading)));
}
 
Example #13
Source File: AdapterModule.java    From tv-samples with Apache License 2.0 4 votes vote down vote up
@ListAdapterForRelatedRowQualifier
@PerFragment
@Provides
ListAdapter<VideoEntity> provideRelatedAdapter(PresenterSelector mps) {
    return new ListAdapter<>(mps.getPresenter(new VideoEntity()));
}
 
Example #14
Source File: ListAdapter.java    From tv-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an adapter with the given {@link PresenterSelector}.
 */
public ListAdapter(PresenterSelector presenterSelector) {
    super(presenterSelector);
}
 
Example #15
Source File: LiveDataDetailFragmentSubComponent.java    From tv-samples with Apache License 2.0 votes vote down vote up
PresenterSelector presenterSelector();