ListRowPresenter


public class ListRowPresenter extends RowPresenter


ListRowPresenter renders ListRow using a HorizontalGridView hosted in a ListRowView.

Hover card

Optionally, setHoverCardPresenterSelector can be used to display a view for the currently focused list item below the rendered list. This view is known as a hover card.

Row selection animation

ListRowPresenter disables RowPresenter's default full row dimming effect and draws a dim overlay on each child individually. A subclass may disable the overlay on each child by overriding isUsingDefaultListSelectEffect to return false and write its own child dim effect in applySelectLevelToChild.

Shadow

ListRowPresenter applies a default shadow to each child view. Call setShadowEnabled to disable shadows. A subclass may override and return false in isUsingDefaultShadow and replace with its own shadow implementation.

Summary

Nested types

A task on the ListRowPresenter.ViewHolder that can select an item by position in the HorizontalGridView and perform an optional item task on it.

ViewHolder for the ListRowPresenter.

Public constructors

Constructs a ListRowPresenter with defaults.

ListRowPresenter(int focusZoomFactor)

Constructs a ListRowPresenter with the given parameters.

ListRowPresenter(int focusZoomFactor, boolean useFocusDimmer)

Constructs a ListRowPresenter with the given parameters.

Public methods

final boolean

Returns true if rounded corners are enabled for children of this row.

final void
enableChildRoundedCorners(boolean enable)

Enables or disabled rounded corners on children of this row.

void
freeze(@NonNull RowPresenter.ViewHolder holder, boolean freeze)

Freezes/unfreezes the row, typically used when a transition starts/ends.

int

Returns the expanded row height for rows created by this Presenter.

final int

Returns the zoom factor used for focus highlighting.

final PresenterSelector

Returns the PresenterSelector used for showing a select object in a hover card.

int

Returns the recycled pool size for the given presenter.

int

Returns the row height for list rows created by this Presenter.

final boolean

Returns true if child shadow is enabled.

final int

This method is deprecated.

use getFocusZoomFactor instead.

final boolean

Returns true if the focus dimmer is used for focus highlighting; false otherwise.

final boolean

Returns true if keeps foreground of child of this row, false otherwise.

boolean

Returns true so that default select effect is applied to each individual child of HorizontalGridView.

final boolean

ListRowPresenter overrides the default select effect of RowPresenter and return false.

boolean

Default implementation returns true if SDK version >= 21, shadow (either static or z-order based) will be applied to each individual child of HorizontalGridView.

boolean

Returns true if leanback view outline is enabled on the system or false otherwise.

boolean

Returns true if SDK >= L, where Z shadow is enabled so that Z order is enabled on each child of horizontal list.

void
setEntranceTransitionState(
    @NonNull RowPresenter.ViewHolder holder,
    boolean afterEntrance
)

Changes the visibility of views.

void
setExpandedRowHeight(int rowHeight)

Sets the expanded row height for rows created by this Presenter.

final void

Sets the PresenterSelector used for showing a select object in a hover card.

final void
setKeepChildForeground(boolean keep)

When ListRowPresenter applies overlay color on the child, it may change child's foreground Drawable.

void
setNumRows(int numRows)

Sets the numbers of rows for rendering the list of items.

void
setRecycledPoolSize(Presenter presenter, int size)

Sets the recycled pool size for the given presenter.

void
setRowHeight(int rowHeight)

Sets the row height for rows created by this Presenter.

final void
setShadowEnabled(boolean enabled)

Enables or disables child shadow.

Protected methods

void
applySelectLevelToChild(
    ListRowPresenter.ViewHolder rowViewHolder,
    View childView
)

Applies select level to a child.

RowPresenter.ViewHolder

Called to create a ViewHolder object for a Row.

ShadowOverlayHelper.Options

Create ShadowOverlayHelper Options.

void
dispatchItemSelectedListener(
    RowPresenter.ViewHolder holder,
    boolean selected
)

Dispatch item selected event using current selected item in the HorizontalGridView.

void

Called after a RowPresenter.ViewHolder is created for a Row.

void

Binds the given row object to the given ViewHolder.

void
onRowViewExpanded(RowPresenter.ViewHolder holder, boolean expanded)

Called when the row view's expanded state changes.

void
onRowViewSelected(RowPresenter.ViewHolder holder, boolean selected)

Called when the given row view changes selection state.

void

Applies select level to header and draws a default color dim over each child of HorizontalGridView.

void

Unbinds the given ViewHolder.

Inherited Constants

From androidx.leanback.widget.RowPresenter
static final int

Don't synchronize row view activated status with selected status or expanded status, application will do its own through setActivated.

static final int

Synchronizes row view's activated status to expand status of the row view holder.

static final int

Sets the row view's activated status to true when both expand and selected are true.

static final int

Synchronizes row view's activated status to selected status of the row view holder.

Inherited methods

From androidx.leanback.widget.FacetProvider
abstract @Nullable Object
getFacet(@NonNull Class<Object> facetClass)

Queries optional implemented facet.

From androidx.leanback.widget.Presenter
static void

Utility method for removing all running animations on a view.

final Object
getFacet(Class<Object> facetClass)

Queries optional implemented facet.

abstract void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @Nullable Object item
)

Binds a View to an item.

void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @NonNull Object item,
    @NonNull List<Object> payloads
)

Binds a View to an item with a list of payloads.

abstract @NonNull Presenter.ViewHolder

Creates a new View.

abstract void

Unbinds a View from an item.

void

Called when a view created by this presenter has been attached to a window.

void

Called when a view created by this presenter has been detached from its window.

final void
setFacet(Class<Object> facetClass, Object facetImpl)

Sets dynamic implemented facet in addition to basic Presenter functions.

void

Called to set a click listener for the given view holder.

From androidx.leanback.widget.RowPresenter
final RowHeaderPresenter

Returns the Presenter used for rendering the header, or null if none has been set.

final RowPresenter.ViewHolder

Returns the RowPresenter.ViewHolder from the given RowPresenter ViewHolder.

final boolean

Returns true if the row selection effect is enabled.

final float

Returns the current select level.

final int

Returns the policy of updating row view activated status.

boolean

Returns true if the Row view should clip its children.

final void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @Nullable Object item
)

Binds a View to an item.

final Presenter.ViewHolder

Creates a new View.

void

Invoked when the row view is attached to the window.

void

Invoked when the row view is detached from the window.

final void

Unbinds a View from an item.

final void

Called when a view created by this presenter has been attached to a window.

final void

Called when a view created by this presenter has been detached from its window.

final void

Sets the Presenter used for rendering the header.

final void
setRowViewExpanded(Presenter.ViewHolder holder, boolean expanded)

Sets the expanded state of a Row view.

final void
setRowViewSelected(Presenter.ViewHolder holder, boolean selected)

Sets the selected state of a Row view.

final void
setSelectEffectEnabled(boolean applyDimOnSelect)

Enables or disables the row selection effect.

final void

Sets the current select level to a value between 0 (unselected) and 1 (selected).

final void
setSyncActivatePolicy(int syncActivatePolicy)

Sets the policy of updating row view activated status.

Public constructors

ListRowPresenter

Added in 1.1.0
public ListRowPresenter()

Constructs a ListRowPresenter with defaults. Uses ZOOM_FACTOR_MEDIUM for focus zooming and disabled dimming on focus.

ListRowPresenter

Added in 1.1.0
public ListRowPresenter(int focusZoomFactor)

Constructs a ListRowPresenter with the given parameters.

Parameters
int focusZoomFactor

Controls the zoom factor used when an item view is focused. One of ZOOM_FACTOR_NONE, ZOOM_FACTOR_SMALL, ZOOM_FACTOR_XSMALL, ZOOM_FACTOR_MEDIUM, ZOOM_FACTOR_LARGE Dimming on focus defaults to disabled.

ListRowPresenter

Added in 1.1.0
public ListRowPresenter(int focusZoomFactor, boolean useFocusDimmer)

Constructs a ListRowPresenter with the given parameters.

Parameters
int focusZoomFactor

Controls the zoom factor used when an item view is focused. One of ZOOM_FACTOR_NONE, ZOOM_FACTOR_SMALL, ZOOM_FACTOR_XSMALL, ZOOM_FACTOR_MEDIUM, ZOOM_FACTOR_LARGE

boolean useFocusDimmer

determines if the FocusHighlighter will use the dimmer

Public methods

areChildRoundedCornersEnabled

Added in 1.1.0
public final boolean areChildRoundedCornersEnabled()

Returns true if rounded corners are enabled for children of this row.

enableChildRoundedCorners

Added in 1.1.0
public final void enableChildRoundedCorners(boolean enable)

Enables or disabled rounded corners on children of this row. Supported on Android SDK >= L.

freeze

public void freeze(@NonNull RowPresenter.ViewHolder holder, boolean freeze)

Freezes/unfreezes the row, typically used when a transition starts/ends. This method is called by the fragment, it should not call it directly by the application.

getExpandedRowHeight

Added in 1.1.0
public int getExpandedRowHeight()

Returns the expanded row height for rows created by this Presenter.

getFocusZoomFactor

Added in 1.1.0
public final int getFocusZoomFactor()

Returns the zoom factor used for focus highlighting.

getHoverCardPresenterSelector

Added in 1.1.0
public final PresenterSelector getHoverCardPresenterSelector()

Returns the PresenterSelector used for showing a select object in a hover card.

getRecycledPoolSize

Added in 1.1.0
public int getRecycledPoolSize(Presenter presenter)

Returns the recycled pool size for the given presenter.

getRowHeight

Added in 1.1.0
public int getRowHeight()

Returns the row height for list rows created by this Presenter.

getShadowEnabled

Added in 1.1.0
public final boolean getShadowEnabled()

Returns true if child shadow is enabled. This is not only for enable/disable default shadow implementation but also subclass must respect this flag.

getZoomFactor

Added in 1.1.0
Deprecated in 1.1.0
public final int getZoomFactor()

Returns the zoom factor used for focus highlighting.

isFocusDimmerUsed

Added in 1.1.0
public final boolean isFocusDimmerUsed()

Returns true if the focus dimmer is used for focus highlighting; false otherwise.

isKeepChildForeground

Added in 1.1.0
public final boolean isKeepChildForeground()

Returns true if keeps foreground of c