ListRowPresenter

open class ListRowPresenter : RowPresenter
kotlin.Any
   ↳ androidx.leanback.widget.Presenter
   ↳ androidx.leanback.widget.RowPresenter
   ↳ androidx.leanback.widget.ListRowPresenter

ListRowPresenter renders ListRow using a HorizontalGridView hosted in a ListRowView. Hover card Optionally, #setHoverCardPresenterSelector(PresenterSelector) 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(ViewHolder, View). Shadow ListRowPresenter applies a default shadow to each child view. Call #setShadowEnabled(boolean) to disable shadows. A subclass may override and return false in #isUsingDefaultShadow() and replace with its own shadow implementation.

Summary

Nested classes
open

A task on the ListRowPresenter.

open

ViewHolder for the ListRowPresenter.

Inherited constants
Public constructors

Constructs a ListRowPresenter with defaults.

<init>(focusZoomFactor: Int)

Constructs a ListRowPresenter with the given parameters.

<init>(focusZoomFactor: Int, useFocusDimmer: Boolean)

Constructs a ListRowPresenter with the given parameters.

Public methods
open Unit
setRowHeight(rowHeight: Int)

Sets the row height for rows created by this Presenter.

PresenterSelector!

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

open Unit

Unit

Enables or disabled rounded corners on children of this row.

open 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.

Boolean

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

open Unit
setNumRows(numRows: Int)

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

open Int

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

open 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.

open Boolean

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

open Boolean

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

Int

Returns the zoom factor used for focus highlighting.

Boolean

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

Boolean

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

open Unit

Unit

Enables or disables child shadow.

Int

Returns the zoom factor used for focus highlighting.

open Boolean

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

open Int

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

Boolean

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

Boolean

Returns true if child shadow is enabled.

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

Sets the recycled pool size for the given presenter.

Unit

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

open Int

Returns the recycled pool size for the given presenter.

Protected methods
open Unit

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

open Unit

Applies select level to a child.

open RowPresenter.ViewHolder!

open Unit

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

open Unit

open Unit

open ShadowOverlayHelper.Options!

Create ShadowOverlayHelper Options.

open Unit

open Unit

open Unit

Inherited functions

Public constructors

<init>

ListRowPresenter()

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

<init>

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 FocusHighlight#ZOOM_FACTOR_NONE, FocusHighlight#ZOOM_FACTOR_SMALL, FocusHighlight#ZOOM_FACTOR_XSMALL, FocusHighlight#ZOOM_FACTOR_MEDIUM, FocusHighlight#ZOOM_FACTOR_LARGE Dimming on focus defaults to disabled.

<init>

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 FocusHighlight#ZOOM_FACTOR_NONE, FocusHighlight#ZOOM_FACTOR_SMALL, FocusHighlight#ZOOM_FACTOR_XSMALL, FocusHighlight#ZOOM_FACTOR_MEDIUM, FocusHighlight#ZOOM_FACTOR_LARGE
useFocusDimmer Int: determines if the FocusHighlighter will use the dimmer

Public methods

setRowHeight

open 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.

getHoverCardPresenterSelector

fun getHoverCardPresenterSelector(): PresenterSelector!

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

setEntranceTransitionState

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

enableChildRoundedCorners

fun enableChildRoundedCorners(enable: Boolean): Unit

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

setExpandedRowHeight

open 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

fun setHoverCardPresenterSelector(selector: PresenterSelector!): Unit

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

isUsingDefaultSelectEffect

fun isUsingDefaultSelectEffect(): Boolean

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

setNumRows

open fun setNumRows(numRows: Int): Unit

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

getRowHeight

open fun getRowHeight(): Int

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

isUsingDefaultShadow

open 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

open 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(boolean) is called with true.

Parameters
context Context!: Context to retrieve system settings.
Return
Boolean: True if leanback view outline is enabled on the system or false otherwise.

isUsingDefaultListSelectEffect

open 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(ViewHolder, View).

getFocusZoomFactor

fun getFocusZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

isFocusDimmerUsed

fun isFocusDimmerUsed(): Boolean

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

areChildRoundedCornersEnabled

fun areChildRoundedCornersEnabled(): Boolean

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

freeze

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

setShadowEnabled

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.

getZoomFactor

fun getZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

isUsingZOrder

open 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.

getExpandedRowHeight

open fun getExpandedRowHeight(): Int

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

isKeepChildForeground

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.

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

getShadowEnabled

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.

setRecycledPoolSize

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

Sets the recycled pool size for the given presenter.

setKeepChildForeground

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.

getRecycledPoolSize

open fun getRecycledPoolSize(presenter: Presenter!): Int

Returns the recycled pool size for the given presenter.

Protected methods

dispatchItemSelectedListener

protected open 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().

applySelectLevelToChild

protected open 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(RowPresenter.ViewHolder) 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 ListRowPresenter.ViewHolder!: The child of HorizontalGridView to apply select level.

createRowViewHolder

protected open fun createRowViewHolder(parent: ViewGroup!): RowPresenter.ViewHolder!

onSelectLevelChanged

protected open 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(ViewHolder, View).

onUnbindRowViewHolder

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

initializeRowViewHolder

protected open fun initializeRowViewHolder(holder: RowPresenter.ViewHolder!): Unit

createShadowOverlayOptions

protected open fun createShadowOverlayOptions(): ShadowOverlayHelper.Options!

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

Return
ShadowOverlayHelper.Options!: The options to be used for shadow, overlay and rounded corner.

onRowViewExpanded

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

onBindRowViewHolder

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

onRowViewSelected

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