android.support.v17.leanback.widget.PresenterSelector Java Examples

The following examples show how to use android.support.v17.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 leanback-showcase with Apache License 2.0 7 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 leanback-showcase 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: MainFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
private void setupUIElements() {
    setBadgeDrawable(getActivity().getResources().getDrawable(R.drawable.videos_by_google_banner));
    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(getResources().getColor(R.color.fastlane_background));
    // set search icon color
    setSearchAffordanceColor(getResources().getColor(R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
 
Example #4
Source File: PresenterModule.java    From leanback-showcase 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 #5
Source File: CardExampleFragment.java    From leanback-showcase 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 #6
Source File: LiveDataDetailFragmentUiModule.java    From leanback-showcase 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 #7
Source File: MainFragment.java    From leanback-showcase 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 #8
Source File: AdapterModule.java    From leanback-showcase 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 #9
Source File: AdapterModule.java    From leanback-showcase 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 #10
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link PresenterSelector} used to render the row headers.
 *
 * @param headerPresenterSelector The PresenterSelector that will determine
 *        the Presenter for each row header.
 */
public void setHeaderPresenterSelector(PresenterSelector headerPresenterSelector) {
    mHeaderPresenterSelector = headerPresenterSelector;
    if (mHeadersSupportFragment != null) {
        mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
}
 
Example #11
Source File: PageAndListRowFragment.java    From leanback-showcase 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: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link PresenterSelector} used to render the row headers.
 *
 * @param headerPresenterSelector The PresenterSelector that will determine
 *        the Presenter for each row header.
 */
public void setHeaderPresenterSelector(PresenterSelector headerPresenterSelector) {
    mHeaderPresenterSelector = headerPresenterSelector;
    if (mHeadersFragment != null) {
        mHeadersFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
}
 
Example #13
Source File: BaseArrayAdapter.java    From iview-android-tv with MIT License 4 votes vote down vote up
public BaseArrayAdapter(PresenterSelector selector) {
    super(selector);
}
 
Example #14
Source File: SortedObjectAdapter.java    From Amphitheatre with Apache License 2.0 4 votes vote down vote up
public SortedObjectAdapter(Comparator comparator, PresenterSelector presenterSelector) {
    super(presenterSelector);
    mSortedItems = new TreeSet<Object>(comparator);
}
 
Example #15
Source File: BaseRowSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Get the presenter selector used to create and bind views.
 */
public final PresenterSelector getPresenterSelector() {
    return mPresenterSelector;
}
 
Example #16
Source File: BaseRowSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Set the presenter selector used to create and bind views.
 */
public final void setPresenterSelector(PresenterSelector presenterSelector) {
    mPresenterSelector = presenterSelector;
    updateAdapter();
}
 
Example #17
Source File: BaseRowFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Get the presenter selector used to create and bind views.
 */
public final PresenterSelector getPresenterSelector() {
    return mPresenterSelector;
}
 
Example #18
Source File: BaseRowFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Set the presenter selector used to create and bind views.
 */
public final void setPresenterSelector(PresenterSelector presenterSelector) {
    mPresenterSelector = presenterSelector;
    updateAdapter();
}
 
Example #19
Source File: ListAdapter.java    From leanback-showcase 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 #20
Source File: AdapterModule.java    From leanback-showcase 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 #21
Source File: LiveDataDetailFragmentSubComponent.java    From leanback-showcase with Apache License 2.0 votes vote down vote up
PresenterSelector presenterSelector();