VerticalGridPresenter

open class VerticalGridPresenter : Presenter
kotlin.Any
   ↳ androidx.leanback.widget.Presenter
   ↳ androidx.leanback.widget.VerticalGridPresenter

A presenter that renders objects in a VerticalGridView.

Summary

Nested classes

open

ViewHolder for the VerticalGridPresenter.

Public constructors

Constructs a VerticalGridPresenter with defaults.

<init>(focusZoomFactor: Int)

Constructs a VerticalGridPresenter with the given parameters.

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

Constructs a VerticalGridPresenter with the given parameters.

Public methods

Boolean

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

Unit

Enables or disabled rounded corners on children of this row.

Int

Returns the zoom factor used for focus highlighting.

Boolean

Returns true if keeps foreground of child of this grid, the foreground will not be used for overlay color.

open Int

Returns the number of columns in the vertical grid.

OnItemViewClickedListener!

Returns the item clicked listener.

OnItemViewSelectedListener!

Returns the item selected listener.

Boolean

Returns true if child shadow is enabled.

Boolean

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

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

open Boolean

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

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

VerticalGridPresenter.ViewHolder!

open Unit

open Unit

Changes the visibility of views.

Unit

Set if keeps foreground of child of this grid, the foreground will not be used for overlay color.

open Unit
setNumberOfColumns(numColumns: Int)

Sets the number of columns in the vertical grid.

Unit

Sets the item clicked listener.

Unit

Sets the item selected listener.

Unit

Enable or disable child shadow.

Protected methods

open VerticalGridPresenter.ViewHolder!

Subclass may override this to inflate a different layout.

open ShadowOverlayHelper.Options!

Create ShadowOverlayHelper Options.

open Unit

Called after a VerticalGridPresenter.ViewHolder is created.

Inherited functions

Public constructors

<init>

VerticalGridPresenter()

Constructs a VerticalGridPresenter with defaults. Uses FocusHighlight#ZOOM_FACTOR_MEDIUM for focus zooming and enabled dimming on focus.

<init>

VerticalGridPresenter(focusZoomFactor: Int)

Constructs a VerticalGridPresenter 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 enabled dimming on focus.

<init>

VerticalGridPresenter(focusZoomFactor: Int, useFocusDimmer: Boolean)

Constructs a VerticalGridPresenter 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

areChildRoundedCornersEnabled

fun areChildRoundedCornersEnabled(): Boolean

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

enableChildRoundedCorners

fun enableChildRoundedCorners(enable: Boolean): Unit

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

getFocusZoomFactor

fun getFocusZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

getKeepChildForeground

fun getKeepChildForeground(): Boolean

Returns true if keeps foreground of child of this grid, the foreground will not be used for overlay color. Default value is true.

Return
Boolean: True if keeps foreground of child of this grid.

getNumberOfColumns

open fun getNumberOfColumns(): Int

Returns the number of columns in the vertical grid.

getOnItemViewClickedListener

fun getOnItemViewClickedListener(): OnItemViewClickedListener!

Returns the item clicked listener.

getOnItemViewSelectedListener

fun getOnItemViewSelectedListener(): OnItemViewSelectedListener!

Returns the item selected listener.

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.

isFocusDimmerUsed

fun isFocusDimmerUsed(): Boolean

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

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 VerticalGridView. Subclass may return false to disable default implementation of shadow and provide its own.

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 vertical grid. If subclass returns false in isUsingDefaultShadow() and does not use Z-shadow on SDK >= L, it should override isUsingZOrder() return false.

onBindViewHolder

open fun onBindViewHolder(viewHolder: Presenter.ViewHolder!, item: Any!): Unit

onCreateViewHolder

fun onCreateViewHolder(parent: ViewGroup!): VerticalGridPresenter.ViewHolder!

onUnbindViewHolder

open fun onUnbindViewHolder(viewHolder: Presenter.ViewHolder!): Unit

setEntranceTransitionState

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

Changes the visibility of views. The entrance transition will be run against the views that change visibilities. This method is called by the fragment, it should not be called directly by the application.

Parameters
holder VerticalGridPresenter.ViewHolder!: The ViewHolder for the vertical grid.
afterEntrance VerticalGridPresenter.ViewHolder!: true if children of vertical grid participating in entrance transition should be set to visible, false otherwise.

setKeepChildForeground

fun setKeepChildForeground(keep: Boolean): Unit

Set if keeps foreground of child of this grid, the foreground will not be used for overlay color. Default value is true.

Parameters
keep Boolean: True if keep foreground of child of this grid.

setNumberOfColumns

open fun setNumberOfColumns(numColumns: Int): Unit

Sets the number of columns in the vertical grid.

setOnItemViewClickedListener

fun setOnItemViewClickedListener(listener: OnItemViewClickedListener!): Unit

Sets the item clicked listener. OnItemViewClickedListener will override View.OnClickListener that item presenter sets during Presenter#onCreateViewHolder(ViewGroup). So in general, developer should choose one of the listeners but not both.

setOnItemViewSelectedListener

fun setOnItemViewSelectedListener(listener: OnItemViewSelectedListener!): Unit

Sets the item selected listener. Since this is a grid the row parameter is always null.

setShadowEnabled

fun setShadowEnabled(enabled: Boolean): Unit

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

Protected methods

createGridViewHolder

protected open fun createGridViewHolder(parent: ViewGroup!): VerticalGridPresenter.ViewHolder!

Subclass may override this to inflate a different layout.

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.

initializeGridViewHolder

protected open fun initializeGridViewHolder(vh: VerticalGridPresenter.ViewHolder!): Unit

Called after a VerticalGridPresenter.ViewHolder is created. Subclasses may override this method and start by calling super.initializeGridViewHolder(ViewHolder).

Parameters
vh VerticalGridPresenter.ViewHolder!: The ViewHolder to initialize for the vertical grid.