VerticalGridPresenter


class VerticalGridPresenter : Presenter


A presenter that renders objects in a VerticalGridView.

Summary

Nested types

ViewHolder for the VerticalGridPresenter.

Public constructors

Constructs a VerticalGridPresenter with defaults.

VerticalGridPresenter(focusZoomFactor: Int)

Constructs a VerticalGridPresenter with the given parameters.

VerticalGridPresenter(focusZoomFactor: Int, useFocusDimmer: Boolean)

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

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.

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.

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.

Boolean

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

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

Binds a View to an item.

VerticalGridPresenter.ViewHolder

Creates a new View.

Unit

Unbinds a View from an item.

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

Changes the visibility of views.

Unit

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

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 functions

VerticalGridPresenter.ViewHolder

Subclass may override this to inflate a different layout.

ShadowOverlayHelper.Options

Create ShadowOverlayHelper Options.

Unit

Called after a VerticalGridPresenter.ViewHolder is created.

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.

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

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

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.

Public constructors

VerticalGridPresenter

Added in 1.1.0
VerticalGridPresenter()

Constructs a VerticalGridPresenter with defaults. Uses ZOOM_FACTOR_LARGE for focus zooming and enabled dimming on focus.

VerticalGridPresenter

Added in 1.1.0
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 ZOOM_FACTOR_NONE, ZOOM_FACTOR_SMALL, ZOOM_FACTOR_XSMALL, ZOOM_FACTOR_MEDIUM, ZOOM_FACTOR_LARGE enabled dimming on focus.

VerticalGridPresenter

Added in 1.1.0
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 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.

getFocusZoomFactor

Added in 1.1.0
fun getFocusZoomFactor(): Int

Returns the zoom factor used for focus highlighting.

getKeepChildForeground

Added in 1.1.0
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.

Returns
Boolean

True if keeps foreground of child of this grid.

getNumberOfColumns

Added in 1.1.0
fun getNumberOfColumns(): Int

Returns the number of columns in the vertical grid.

getOnItemViewClickedListener

Added in 1.1.0
fun getOnItemViewClickedListener(): OnItemViewClickedListener?

Returns the item clicked listener.

getOnItemViewSelectedListener

Added in 1.1.0
fun getOnItemViewSelectedListener(): OnItemViewSelectedListener?

Returns the item selected listener.

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.

isFocusDimmerUsed

Added in 1.1.0
fun isFocusDimmerUsed(): Boolean

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

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

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

onBindViewHolder

Added in 1.2.0-alpha04
fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any?): Unit

Binds a View to an item.

onCreateViewHolder

Added in 1.2.0-alpha04
fun onCreateViewHolder(parent: ViewGroup): VerticalGridPresenter.ViewHolder

Creates a new View.

onUnbindViewHolder

Added in 1.2.0-alpha04
fun onUnbindViewHolder(viewHolder: Presenter.ViewHolder): Unit

Unbinds a View from an item. Any expensive references may be released here, and any fields that are not bound for every item should be cleared here.

setEntranceTransitionState

Added in 1.1.0
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: Boolean

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

setKeepChildForeground

Added in 1.1.0
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

Added in 1.1.0
fun setNumberOfColumns(numColumns: Int): Unit

Sets the number of columns in the vertical grid.

setOnItemViewClickedListener

Added in 1.1.0
fun setOnItemViewClickedListener(listener: OnItemViewClickedListener?): Unit

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

setOnItemViewSelectedListener

Added in 1.1.0
fun setOnItemViewSelectedListener(listener: OnItemViewSelectedListener?): Unit

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

setShadowEnabled

Added in 1.1.0
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 functions

createGridViewHolder

Added in 1.1.0
protected fun createGridViewHolder(parent: ViewGroup): VerticalGridPresenter.ViewHolder

Subclass may override this to inflate a different layout.

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.

initializeGridViewHolder

Added in 1.1.0
protected 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.