java.lang.Object | ||
↳ | android.support.v17.leanback.widget.Presenter | |
↳ | android.support.v17.leanback.widget.RowPresenter |
Known Direct Subclasses |
An abstract Presenter
that renders a Row
.
RowPresenter.ViewHolder
and override createRowViewHolder(ViewGroup)
and initializeRowViewHolder(ViewHolder)
. The subclass must use layout id
"row_content" for the widget that will be aligned to the title of any HeadersFragment
that may exist in the parent fragment. RowPresenter contains an optional and
replaceable RowHeaderPresenter
that renders the header. You can disable
the default rendering or replace the Presenter with a new header presenter
by calling setHeaderPresenter(RowHeaderPresenter)
.
setRowViewSelected(Presenter.ViewHolder, boolean)
. The event
is triggered immediately when there is a row selection change before the selection
animation is started. Selected status may control activated status of the row (see
"Activated status" below).
Subclasses of RowPresenter may override onRowViewSelected(ViewHolder, boolean)
.
setRowViewExpanded(Presenter.ViewHolder, boolean)
when BrowseFragment hides fast lane on the left.
The event is triggered immediately before the expand animation is started.
Row title is shown when row is expanded. Expanded status may control activated status
of the row (see "Activated status" below).
Subclasses of RowPresenter may override onRowViewExpanded(ViewHolder, boolean)
.
setActivated(boolean)
.
The activated status is typically used to control BaseCardView
info region visibility.
The row's activated status can be controlled by selected status and/or expanded status.
Call setSyncActivatePolicy(int)
and choose one of the four policies:
SYNC_ACTIVATED_TO_EXPANDED
Activated status is synced with row expanded statusSYNC_ACTIVATED_TO_SELECTED
Activated status is synced with row selected statusSYNC_ACTIVATED_TO_EXPANDED_AND_SELECTED
Activated status is set to true
when both expanded and selected status are trueSYNC_ACTIVATED_CUSTOM
Activated status is not controlled by selected status
or expanded status, application can control activated status by its own.
Application should call setActivated(boolean)
to change
activated status of row view.
OnItemViewSelectedListener
and OnItemViewClickedListener
.
If a subclass wants to add its own View.OnFocusChangeListener
or
View.OnClickListener
, it must do that in createRowViewHolder(ViewGroup)
to be properly chained by the library. Adding View listeners after
createRowViewHolder(ViewGroup)
is undefined and may result in
incorrect behavior by the library's listeners.
When a user scrolls through rows, a fragment will initiate animation and call
setSelectLevel(Presenter.ViewHolder, float)
with float value between
0 and 1. By default, the RowPresenter draws a dim overlay on top of the row
view for views that are not selected. Subclasses may override this default effect
by having isUsingDefaultSelectEffect()
return false and overriding
onSelectLevelChanged(ViewHolder)
to apply a different selection effect.
Call setSelectEffectEnabled(boolean)
to enable/disable the select effect,
This will not only enable/disable the default dim effect but also subclasses must
respect this flag as well.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RowPresenter.ViewHolder |
A ViewHolder for a Row .
|
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | SYNC_ACTIVATED_CUSTOM |
Don't synchronize row view activated status with selected status or expanded status,
application will do its own through setActivated(boolean) .
|
|||||||||
int | SYNC_ACTIVATED_TO_EXPANDED | Synchronizes row view's activated status to expand status of the row view holder. | |||||||||
int | SYNC_ACTIVATED_TO_EXPANDED_AND_SELECTED | Sets the row view's activated status to true when both expand and selected are true. | |||||||||
int | SYNC_ACTIVATED_TO_SELECTED | Synchronizes row view's activated status to selected status of the row view holder. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a RowPresenter.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if the Row view can draw outside its bounds.
| |||||||||||
Freezes/unfreezes the row, typically used when a transition starts/ends.
| |||||||||||
Returns the Presenter used for rendering the header, or null if none has been
set.
| |||||||||||
Returns the
RowPresenter.ViewHolder from the given RowPresenter
ViewHolder.
| |||||||||||
Returns true if the row selection effect is enabled.
| |||||||||||
Returns the current select level.
| |||||||||||
Returns the policy of updating row view activated status.
| |||||||||||
Returns true if this RowPresenter is using the default dimming effect.
| |||||||||||
Binds a
View to an item.
| |||||||||||
Creates a new
View .
| |||||||||||
Unbinds a
View from an item.
| |||||||||||
Called when a view created by this presenter has been attached to a window.
| |||||||||||
Called when a view created by this presenter has been detached from its window.
| |||||||||||
Changes the visibility of views.
| |||||||||||
Sets the Presenter used for rendering the header.
| |||||||||||
Sets the expanded state of a Row view.
| |||||||||||
Sets the selected state of a Row view.
| |||||||||||
Enables or disables the row selection effect.
| |||||||||||
Sets the current select level to a value between 0 (unselected) and 1 (selected).
| |||||||||||
Sets the policy of updating row view activated status.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called to create a ViewHolder object for a Row.
| |||||||||||
This method is only called from
onRowViewSelected(ViewHolder, boolean) onRowViewSelected.
| |||||||||||
Called after a
RowPresenter.ViewHolder is created for a Row.
| |||||||||||
Returns true if the Row view should clip it's children.
| |||||||||||
Binds the given row object to the given ViewHolder.
| |||||||||||
Invoked when the row view is attached to the window.
| |||||||||||
Invoked when the row view is detached from the window.
| |||||||||||
Called when the row view's expanded state changes.
| |||||||||||
Called when the given row view changes selection state.
| |||||||||||
Callback when the select level changes.
| |||||||||||
Unbinds the given ViewHolder.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v17.leanback.widget.Presenter
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.support.v17.leanback.widget.FacetProvider
|
Don't synchronize row view activated status with selected status or expanded status,
application will do its own through setActivated(boolean)
.
Synchronizes row view's activated status to expand status of the row view holder.
Sets the row view's activated status to true when both expand and selected are true.
Synchronizes row view's activated status to selected status of the row view holder.
Constructs a RowPresenter.
Returns true if the Row view can draw outside its bounds.
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.
Returns the Presenter used for rendering the header, or null if none has been set.
Returns the RowPresenter.ViewHolder
from the given RowPresenter
ViewHolder.
Returns true if the row selection effect is enabled. This value not only determines whether the default dim implementation is used, but subclasses must also respect this flag.
Returns the current select level. The value will be between 0 (unselected) and 1 (selected).
Returns the policy of updating row view activated status. Can be one of:
SYNC_ACTIVATED_TO_EXPANDED
SYNC_ACTIVATED_TO_SELECTED
SYNC_ACTIVATED_TO_EXPANDED_AND_SELECTED
SYNC_ACTIVATED_CUSTOM
Returns true if this RowPresenter is using the default dimming effect.
A subclass may (most likely) return false and
override onSelectLevelChanged(ViewHolder)
.
Binds a View
to an item.
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.
Called when a view created by this presenter has been attached to a window.
This can be used as a reasonable signal that the view is about to be seen
by the user. If the adapter previously freed any resources in
onViewDetachedFromWindow(ViewHolder)
those resources should be restored here.
holder | Holder of the view being attached |
---|
Called when a view created by this presenter has been detached from its window.
Becoming detached from the window is not necessarily a permanent condition; the consumer of an presenter's views may choose to cache views offscreen while they are not visible, attaching and detaching them as appropriate.
Any view property animations should be cancelled here or the view may fail to be recycled.holder | Holder of the view being detached |
---|
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 call it directly by the application.
Sets the Presenter used for rendering the header. Can be null to disable header rendering. The method must be called before creating any Row Views.
Sets the expanded state of a Row view.
holder | The Row ViewHolder to set expanded state on. |
---|---|
expanded | True if the Row is expanded, false otherwise. |
Sets the selected state of a Row view.
holder | The Row ViewHolder to set expanded state on. |
---|---|
selected | True if the Row is expanded, false otherwise. |
Enables or disables the row selection effect. This will not only affect the default dim effect, but subclasses must respect this flag as well.
Sets the current select level to a value between 0 (unselected) and 1 (selected).
Subclasses may override onSelectLevelChanged(ViewHolder)
to
respond to changes in the selected level.
Sets the policy of updating row view activated status. Can be one of:
SYNC_ACTIVATED_TO_EXPANDED
SYNC_ACTIVATED_TO_SELECTED
SYNC_ACTIVATED_TO_EXPANDED_AND_SELECTED
SYNC_ACTIVATED_CUSTOM
Called to create a ViewHolder object for a Row. Subclasses will override this method to return a different concrete ViewHolder object.
parent | The parent View for the Row's view holder. |
---|
This method is only called from
onRowViewSelected(ViewHolder, boolean)
onRowViewSelected.
The default behavior is to signal row selected events with a null item parameter.
A Subclass of RowPresenter having child items should override this method and dispatch
events with item information.
Called after a RowPresenter.ViewHolder
is created for a Row.
Subclasses may override this method and start by calling
super.initializeRowViewHolder(ViewHolder).
vh | The ViewHolder to initialize for the Row. |
---|
Returns true if the Row view should clip it's children. The clipChildren
flag is set on view in initializeRowViewHolder(ViewHolder)
. Note that
Slide transition or explode transition need turn off clipChildren.
Default value is false.
Binds the given row object to the given ViewHolder.
Invoked when the row view is attached to the window.
Invoked when the row view is detached from the window.
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.
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.
Callback when the select level changes. The default implementation applies
the select level to setSelectLevel(RowHeaderPresenter.ViewHolder, float)
when getSelectEffectEnabled()
is true. Subclasses may override
this function and implement a different select effect. In this case,
the method isUsingDefaultSelectEffect()
should also be overridden to disable
the default dimming effect.