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
Int

Returns the zoom factor used for focus highlighting.

Boolean

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

OnItemViewClickedListener!

Returns the item clicked listener.

VerticalGridPresenter.ViewHolder!

Boolean

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

Unit

Sets the item selected listener.

open Unit
setNumberOfColumns(numColumns: Int)

Sets the number of columns in the vertical grid.

Unit

Sets the item clicked listener.

open Unit

Changes the visibility of views.

Unit

Enable or disable child shadow.

open Boolean

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

Boolean

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

Unit

Enables or disabled rounded corners on children of this row.

OnItemViewSelectedListener!

Returns the item selected listener.

Boolean

Returns true if child shadow is enabled.

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

open Int

Returns the number of columns in the vertical grid.

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 Unit

Unit

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

Protected methods
open Unit

Called after a VerticalGridPresenter.ViewHolder is created.

open VerticalGridPresenter.ViewHolder!

Subclass may override this to inflate a different layout.

open ShadowOverlayHelper.Options!

Create ShadowOverlayHelper Options.

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

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.

getOnItemViewClickedListener

fun getOnItemViewClickedListener(): OnItemViewClickedListener!

Returns the item clicked listener.

onCreateViewHolder

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

areChildRoundedCornersEnabled

fun areChildRoundedCornersEnabled(): Boolean

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

setOnItemViewSelectedListener

fun setOnItemViewSelectedListener(listener: OnItemViewSelectedListener!): Unit

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

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.

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.

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.

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.

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.

enableChildRoundedCorners

fun enableChildRoundedCorners(enable: Boolean): Unit

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

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.

onBindViewHolder

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

getNumberOfColumns

open fun getNumberOfColumns(): Int

Returns the number of columns in the vertical grid.

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.

onUnbindViewHolder

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

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.

Protected methods

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.

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.