A PlaybackTransportRowPresenter renders a PlaybackControlsRow to display a
series of playback control buttons.
A Presenter is used to generate Views and bind Objects to them on
demand. It is closely related to the concept of an RecyclerView.Adapter, but is
not position-based. The leanback framework implements the adapter concept using
ObjectAdapter which refers to a Presenter (or PresenterSelector) instance.
Presenters should be stateless. Presenters typically extend Presenter.ViewHolder to store all
necessary view state information, such as references to child views to be used when
binding to avoid expensive calls to findViewById(int).
A trivial Presenter that takes a string and renders it into a TextView:
ViewHolder can be subclassed and used to cache any view accessors needed
to improve binding performance (for example, results of findViewById)
without needing to subclass a View.
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.
Parameters
holder
Presenter.ViewHolder: 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.
Parameters
holder
Presenter.ViewHolder: Holder of the view being detached
Called to set a click listener for the given view holder.
The default implementation sets the click listener on the root view in the view holder.
If the root view isn't focusable this method should be overridden to set the listener
on the appropriate focusable child view(s).
Parameters
holder
Presenter.ViewHolder: The view holder containing the view(s) on which the listener should be set.
listener
View.OnClickListener: The click listener to be set.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.