FacetProvider


interface FacetProvider

Known direct subclasses
GuidedActionsStylist.ViewHolder

ViewHolder caches information about the action item layouts' subviews.

ItemBridgeAdapter.ViewHolder

ViewHolder for the ItemBridgeAdapter.

Presenter.ViewHolder

ViewHolder can be subclassed and used to cache any view accessors needed to improve binding performance (for example, results of findViewById) without needing to subclass a View.

Presenter

A Presenter is used to generate Views and bind Objects to them on demand.

Known indirect subclasses
AbstractDetailsDescriptionPresenter.ViewHolder

The ViewHolder for the AbstractDetailsDescriptionPresenter.

AbstractDetailsDescriptionPresenter

An abstract Presenter for rendering a detailed description of an item.

AbstractMediaItemPresenter.ViewHolder

The ViewHolder for the AbstractMediaItemPresenter.

AbstractMediaItemPresenter

Abstract Presenter class for rendering media items in a playlist format.

AbstractMediaListHeaderPresenter.ViewHolder

The ViewHolder for the AbstractMediaListHeaderPresenter.

AbstractMediaListHeaderPresenter

Abstract presenter class for rendering the header for a list of media items in a playlist.

DetailsOverviewLogoPresenter.ViewHolder

ViewHolder for Logo view of DetailsOverviewRow.

DetailsOverviewLogoPresenter

Presenter that responsible to create a ImageView and bind to DetailsOverviewRow.

DetailsOverviewRowPresenter.ViewHolder

A ViewHolder for the DetailsOverviewRow.

DetailsOverviewRowPresenter

This class is deprecated.

Use FullWidthDetailsOverviewRowPresenter

DividerPresenter

DividerPresenter provides a default presentation for DividerRow in HeadersFragment.

FullWidthDetailsOverviewRowPresenter.ViewHolder

A ViewHolder for the DetailsOverviewRow.

FullWidthDetailsOverviewRowPresenter

Renders a DetailsOverviewRow to display an overview of an item.

ListRowPresenter.ViewHolder

ViewHolder for the ListRowPresenter.

ListRowPresenter

ListRowPresenter renders ListRow using a HorizontalGridView hosted in a ListRowView.

PlaybackControlsRowPresenter.ViewHolder

A ViewHolder for the PlaybackControlsRow.

PlaybackControlsRowPresenter

A PlaybackControlsRowPresenter renders a PlaybackControlsRow to display a series of playback control buttons.

PlaybackRowPresenter.ViewHolder

This container is used for trapping click events and passing them to the playback controls.

PlaybackRowPresenter

Subclass of RowPresenter that can define the desired behavior when the view reappears.

PlaybackTransportRowPresenter.ViewHolder

A ViewHolder for the PlaybackControlsRow supporting seek UI.

PlaybackTransportRowPresenter

A PlaybackTransportRowPresenter renders a PlaybackControlsRow to display a series of playback control buttons.

RowHeaderPresenter.ViewHolder

A ViewHolder for the RowHeaderPresenter.

RowHeaderPresenter

RowHeaderPresenter provides a default presentation for HeaderItem using a RowHeaderView and optionally a TextView for description.

RowPresenter.ViewHolder

A ViewHolder for a Row.

RowPresenter

An abstract Presenter that renders an Object in RowsFragment, the object can be subclass Row or a generic one.

VerticalGridPresenter.ViewHolder

ViewHolder for the VerticalGridPresenter.

VerticalGridPresenter

A presenter that renders objects in a VerticalGridView.


This is the query interface to supply optional features(aka facets) on an object without the need of letting the object to subclass or implement java interfaces. Facets allow leanback to re-compose optional features from leanback ViewHolder to RecyclerView ViewHolder. A typical "facet" class is ItemAlignmentFacet that defines how to align a ViewHolder inside VerticalGridView or HorizontalGridView. A FacetProvider could be retrieved from two sources by VerticalGridView/HorizontalGridView in the following order.

  • ViewHolder based facet:

    RecyclerView.ViewHolder can implement FacetProvider. If app uses leanback Presenter.ViewHolder, the facet of Presenter.ViewHolder will be relayed by ItemBridgeAdapter.ViewHolder which is a wrapper of Presenter.ViewHolder. ViewHolder based facet is used less frequently than item view type based facet because in most cases ViewHolders of same type share the same alignment definition.

    For example, app calls viewHolder.setFacet(ItemAlignmentFacet.class, itemAlignmentFacet) to set alignment of the ViewHolder instance.

  • RecyclerView item view type based facet:

    RecyclerView.Adapter can implement FacetProviderAdapter which returns FacetProvider for each item view type. If app uses leanback ObjectAdapter and Presenter, app wraps the ObjectAdapter and Presenter using ItemBridgeAdapter. The implementation of getFacetProvider will return the FacetProvider implemented by Presenter which is mapped to the item view type.

    For example, app calls presenter.setFacet(ItemAlignmentFacet.class, itemAlignmentFacet) to set alignment of all ViewHolders created by this Presenter.

Summary

Public functions

Any?
getFacet(facetClass: Class<Any!>)

Queries optional implemented facet.

Public functions

getFacet

Added in 1.0.0-alpha03
fun getFacet(facetClass: Class<Any!>): Any?

Queries optional implemented facet.

Parameters
facetClass: Class<Any!>

Facet classes to query, examples are: class of ItemAlignmentFacet.

Returns
Any?

Facet implementation for the facetClass or null if feature not implemented.