ListRowPresenter


class ListRowPresenter : 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(focusZoomFactor: Int)

Constructs a ListRowPresenter with the given parameters.

ListRowPresenter(focusZoomFactor: Int, useFocusDimmer: Boolean)

Constructs a ListRowPresenter with the given parameters.

Public functions

Boolean

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

Unit

Enables or disabled rounded corners on children of this row.

Unit

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

Int

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

Int

Returns the zoom factor used for focus highlighting.

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.

Boolean

Returns true if child shadow is enabled.

Int

This function is deprecated.

use getFocusZoomFactor instead.

Boolean

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

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.

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.

Unit
setEntranceTransitionState(
    holder: RowPresenter.ViewHolder,
    afterEntrance: Boolean
)

Changes the visibility of views.

Unit

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

Unit

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

Unit

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

Unit
setNumRows(numRows: Int)

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

Unit
setRecycledPoolSize(presenter: Presenter!, size: Int)

Sets the recycled pool size for the given presenter.

Unit
setRowHeight(rowHeight: Int)

Sets the row height for rows created by this Presenter.

Unit

Enables or disables child shadow.

Protected functions

Unit
applySelectLevelToChild(
    rowViewHolder: ListRowPresenter.ViewHolder!,
    childView: View!
)

Applies select level to a child.

RowPresenter.ViewHolder!

Called to create a ViewHolder object for a Row.

ShadowOverlayHelper.Options!

Create ShadowOverlayHelper Options.

Unit
dispatchItemSelectedListener(
    holder: RowPresenter.ViewHolder!,
    selected: Boolean
)

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

Unit

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

Unit

Binds the given row object to the given ViewHolder.

Unit

Called when the row view's expanded state changes.

Unit

Called when the given row view changes selection state.

Unit

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

Unit

Unbinds the given ViewHolder.

Inherited Constants

From androidx.leanback.widget.RowPresenter
const Int

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

const Int

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

const Int

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

const Int

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

Inherited functions

From androidx.leanback.widget.FacetProvider
abstract Any?
getFacet(facetClass: Class<Any!>)

Queries optional implemented facet.

From androidx.leanback.widget.Presenter
java-static Unit

Utility method for removing all running animations on a view.

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

Queries optional implemented facet.

abstract Unit
onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any?)

Binds a View to an item.

Unit
onBindViewHolder(
    viewHolder: Presenter.ViewHolder,
    item: Any,
    payloads: (Mutable)List<Any!>
)

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

abstract Presenter.ViewHolder

Creates a new View.

abstract Unit

Unbinds a View from an item.

Unit

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

Unit

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

Unit
setFacet(facetClass: Class<Any!>!, facetImpl: Any!)

Sets dynamic implemented facet in addition to basic Presenter functions.

Unit
setOnClickListener(
    holder: Presenter.ViewHolder!,
    listener: View.OnClickListener!
)

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

From androidx.leanback.widget.RowPresenter
RowHeaderPresenter!

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

RowPresenter.ViewHolder!

Returns the RowPresenter.ViewHolder from the given RowPresenter ViewHolder.

Boolean

Returns true if the row selection effect is enabled.

Float

Returns the current select level.

Int

Returns the policy of updating row view activated status.

Boolean

Returns true if the Row view should clip its children.

Unit
onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any?)

Binds a View to an item.

Presenter.ViewHolder!

Creates a new View.

Unit

Invoked when the row view is attached to the window.

Unit

Invoked when the row view is detached from the window.

Unit

Unbinds a View from an item.

Unit

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

Unit

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

Unit

Sets the Presenter used for rendering the header.

Unit

Sets the expanded state of a Row view.

Unit

Sets the selected state of a Row view.

Unit
setSelectEffectEnabled(applyDimOnSelect: Boolean)

Enables or disables the row selection effect.

Unit

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

Unit
setSyncActivatePolicy(syncActivatePolicy: Int)

Sets the policy of updating row view activated status.

Public constructors

ListRowPresenter

Added in 1.1.0
ListRowPresenter()

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

ListRowPresenter

Added in 1.1.0
ListRowPresenter(focusZoomFactor: Int)

Constructs a ListRowPresenter with the given parameters.

Parameters
focusZoomFactor: Int

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
ListRowPresenter(focusZoomFactor: Int, useFocusDimmer: Boolean)

Constructs a ListRowPresenter with the given parameters.

Parameters
focusZoomFactor: Int

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

useFocusDimmer: Boolean

determines if the FocusHighlighter will use the dimmer

Public functions

areChildRoundedCornersEnabled

Added in 1.1.0
fun areChildRoundedCornersEnabled(): Boolean

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

enableChildRoundedCorners

Added in 1.1.0
fun enableChildRoundedCorners(enable: Boolean): Unit

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

freeze

fun freeze(holder: RowPresenter.ViewHolder, freeze: Boolean): Unit

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
fun getExpandedRowHeight(): Int

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

getFocusZoomFactor

Added in 1.1.0
fun getFocusZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

getHoverCardPresenterSelector

Added in 1.1.0
fun getHoverCardPresenterSelector(): PresenterSelector!

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

getRecycledPoolSize

Added in 1.1.0
fun getRecycledPoolSize(presenter: Presenter!): Int

Returns the recycled pool size for the given presenter.

getRowHeight

Added in 1.1.0
fun getRowHeight(): Int

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

getShadowEnabled

Added in 1.1.0
fun getShadowEnabled(): Boolean

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
fun getZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

isFocusDimmerUsed

Added in 1.1.0
fun isFocusDimmerUsed(): Boolean

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

isKeepChildForeground

Added in 1.1.0
fun isKeepChildForeground(): Boolean

Returns true if keeps foreground of child of this row, false otherwise. When ListRowPresenter applies overlay color on the child, it may change child's foreground Drawable. If application uses child's foreground for other purposes such as ripple effect, it needs tell ListRowPresenter to keep the child's foreground. The default value is true.

Returns
Boolean

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

isUsingDefaultListSelectEffect

Added in 1.1.0
fun isUsingDefaultListSelectEffect(): Boolean

Returns true so that default select effect is applied to each individual child of HorizontalGridView. Subclass may return false to disable the default implementation and implement applySelectLevelToChild.

isUsingDefaultSelectEffect

Added in 1.2.0-alpha04
fun isUsingDefaultSelectEffect(): Boolean

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

isUsingDefaultShadow

Added in 1.1.0
fun isUsingDefaultShadow(): 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. Subclass may return false to disable default implementation of shadow and provide its own.

isUsingOutlineClipping

Added in 1.1.0
fun isUsingOutlineClipping(context: Context!): Boolean

Returns true if leanback view outline is enabled on the system or false otherwise. When false, rounded corner will not be enabled even enableChildRoundedCorners is called with true.

Parameters
context: Context!

Context to retrieve system settings.

Returns
Boolean

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

isUsingZOrder

Added in 1.1.0
fun isUsingZOrder(context: Context!): Boolean

Returns true if SDK >= L, where Z shadow is enabled so that Z order is enabled on each child of horizontal list. If subclass returns false in isUsingDefaultShadow() and does not use Z-shadow on SDK >= L, it should override isUsingZOrder() return false.

setEntranceTransitionState

fun setEntranceTransitionState(
    holder: RowPresenter.ViewHolder,
    afterEntrance: Boolean
): Unit

Changes the visibility of views. The entrance transition will be run against the views that change visibilities. A subclass may override and begin with calling super.setEntranceTransitionState(). This method is called by the fragment, it should not be called directly by the application.

Parameters
holder: RowPresenter.ViewHolder

The ViewHolder of the row.

afterEntrance: Boolean

true if children of row participating in entrance transition should be set to visible, false otherwise.

setExpandedRowHeight

Added in 1.1.0
fun setExpandedRowHeight(rowHeight: Int): Unit

Sets the expanded row height for rows created by this Presenter. If not set, expanded rows have the same height as unexpanded rows.

Parameters
rowHeight: Int

The row height in to use when the row is expanded, in pixels, or WRAP_CONTENT, or 0 to use the default.

setHoverCardPresenterSelector

Added in 1.1.0
fun setHoverCardPresenterSelector(selector: PresenterSelector!): Unit

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

setKeepChildForeground

Added in 1.1.0
fun setKeepChildForeground(keep: Boolean): Unit

When ListRowPresenter applies overlay color on the child, it may change child's foreground Drawable. If application uses child's foreground for other purposes such as ripple effect, it needs tell ListRowPresenter to keep the child's foreground. The default value is true.

Parameters
keep: Boolean

true if keep foreground of child of this row, false ListRowPresenter might change the foreground of the child.

setNumRows

Added in 1.1.0
fun setNumRows(numRows: Int): Unit

Sets the numbers of rows for rendering the list of items. By default, it is set to 1.

setRecycledPoolSize

Added in 1.1.0
fun setRecycledPoolSize(presenter: Presenter!, size: Int): Unit

Sets the recycled pool size for the given presenter.

setRowHeight

Added in 1.1.0
fun setRowHeight(rowHeight: Int): Unit

Sets the row height for rows created by this Presenter. Rows created before calling this method will not be updated.

Parameters
rowHeight: Int

Row height in pixels, or WRAP_CONTENT, or 0 to use the default height.

setShadowEnabled

Added in 1.1.0
fun setShadowEnabled(enabled: Boolean): Unit

Enables or disables child shadow. This is not only for enable/disable default shadow implementation but also subclass must respect this flag.

Protected functions

applySelectLevelToChild

Added in 1.1.0
protected fun applySelectLevelToChild(
    rowViewHolder: ListRowPresenter.ViewHolder!,
    childView: View!
): Unit

Applies select level to a child. Default implementation draws a default color dim over each child of HorizontalGridView. This method is called on all children in onSelectLevelChanged and when a child is attached to HorizontalGridView.

Subclass may disable the default implementation by override isUsingDefaultListSelectEffect to return false and deal with the individual item select level by itself.

Parameters
rowViewHolder: ListRowPresenter.ViewHolder!

The ViewHolder of the Row

childView: View!

The child of HorizontalGridView to apply select level.

createRowViewHolder

Added in 1.2.0-alpha04
protected fun createRowViewHolder(parent: ViewGroup!): RowPresenter.ViewHolder!

Called to create a ViewHolder object for a Row. Subclasses will override this method to return a different concrete ViewHolder object.

Parameters
parent: ViewGroup!

The parent View for the Row's view holder.

Returns
RowPresenter.ViewHolder!

A ViewHolder for the Row's View.

createShadowOverlayOptions

Added in 1.1.0
protected fun createShadowOverlayOptions(): ShadowOverlayHelper.Options!

Create ShadowOverlayHelper Options. Subclass may override. e.g. return new ShadowOverlayHelper.Options().roundedCornerRadius(10);

Returns
ShadowOverlayHelper.Options!

The options to be used for shadow, overlay and rounded corner.

dispatchItemSelectedListener

protected fun dispatchItemSelectedListener(
    holder: RowPresenter.ViewHolder!,
    selected: Boolean
): Unit

Dispatch item selected event using current selected item in the HorizontalGridView. The method should only be called from onRowViewSelected().

initializeRowViewHolder

protected fun initializeRowViewHolder(vh: RowPresenter.ViewHolder!): Unit

Called after a RowPresenter.ViewHolder is created for a Row. Subclasses may override this method and start by calling super.initializeRowViewHolder(ViewHolder).

Parameters
vh: RowPresenter.ViewHolder!

The ViewHolder to initialize for the Row.

onBindRowViewHolder

protected fun onBindRowViewHolder(holder: RowPresenter.ViewHolder, item: Any): Unit

Binds the given row object to the given ViewHolder. Derived classes of RowPresenter overriding onBindRowViewHolder must call through the super class's implementation of this method.

onRowViewExpanded

protected fun onRowViewExpanded(holder: RowPresenter.ViewHolder!, expanded: Boolean): Unit

Called when the row view's expanded state changes. A subclass may override this method to respond to expanded state changes of a Row. The default implementation will hide/show the header view. Subclasses may make visual changes to the Row View but must not create animation on the Row view.

onRowViewSelected

protected fun onRowViewSelected(holder: RowPresenter.ViewHolder!, selected: Boolean): Unit

Called when the given row view changes selection state. A subclass may override this to respond to selected state changes of a Row. A subclass may make visual changes to Row view but must not create animation on the Row view.

onSelectLevelChanged

protected fun onSelectLevelChanged(holder: RowPresenter.ViewHolder!): Unit

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

Subclass may override this method and starts with calling super if it has views to apply select effect other than header and HorizontalGridView. To override the default color dim over each child of HorizontalGridView, app should override isUsingDefaultListSelectEffect to return false and override applySelectLevelToChild.

onUnbindRowViewHolder

protected fun onUnbindRowViewHolder(holder: RowPresenter.ViewHolder): Unit

Unbinds the given ViewHolder. Derived classes of RowPresenter overriding onUnbindRowViewHolder must call through the super class's implementation of this method.