belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
Presenter
public
abstract
class
Presenter
extends Object
implements
FacetProvider
java.lang.Object | |
↳ | android.support.v17.leanback.widget.Presenter |
Known Direct Subclasses |
Known Indirect Subclasses |
A Presenter is used to generate View
s 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
:
public class StringTextViewPresenter extends Presenter { // This class does not need a custom ViewHolder, since it does not use // a complex layout. @Override public ViewHolder onCreateViewHolder(ViewGroup parent) { return new ViewHolder(new TextView(parent.getContext())); } @Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { String str = (String) item; TextView textView = (TextView) viewHolder.mView; textView.setText(item); } @Override public void onUnbindViewHolder(ViewHolder viewHolder) { // Nothing to unbind for TextView, but if this viewHolder had // allocated bitmaps, they can be released here. } }
setFacet(Class, Object)
. Supported facets:
ItemAlignmentFacet
is used by HorizontalGridView
and
VerticalGridView
to customize child alignment.
Summary
Nested classes | |
---|---|
class |
Presenter.ViewHolder
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. |
class |
Presenter.ViewHolderTask
Base class to perform a task on Presenter.ViewHolder. |
Public constructors | |
---|---|
Presenter()
|
Public methods | |
---|---|
final
Object
|
getFacet(Class<?> facetClass)
Queries optional implemented facet. |
abstract
void
|
onBindViewHolder(Presenter.ViewHolder viewHolder, Object item)
Binds a |
void
|
onBindViewHolder(Presenter.ViewHolder viewHolder, Object item, List<Object> payloads)
Binds a |
abstract
Presenter.ViewHolder
|
onCreateViewHolder(ViewGroup parent)
Creates a new |
abstract
void
|
onUnbindViewHolder(Presenter.ViewHolder viewHolder)
Unbinds a |
void
|
onViewAttachedToWindow(Presenter.ViewHolder holder)
Called when a view created by this presenter has been attached to a window. |
void
|
onViewDetachedFromWindow(Presenter.ViewHolder holder)
Called when a view created by this presenter has been detached from its window. |
final
void
|
setFacet(Class<?> facetClass, Object facetImpl)
Sets dynamic implemented facet in addition to basic Presenter functions. |
void
|
setOnClickListener(Presenter.ViewHolder holder, View.OnClickListener listener)
Called to set a click listener for the given view holder. |
Protected methods | |
---|---|
static
void
|
cancelAnimationsRecursive(View view)
Utility method for removing all running animations on a view. |
Inherited methods | |
---|---|
From
class
java.lang.Object
| |
From
interface
android.support.v17.leanback.widget.FacetProvider
|
Public constructors
Public methods
getFacet
Object getFacet (Class<?> facetClass)
Queries optional implemented facet.
Parameters | |
---|---|
facetClass |
Class : Facet classes to query, examples are: class of
ItemAlignmentFacet . |
Returns | |
---|---|
Object |
Facet implementation for the facetClass or null if feature not implemented. |
onBindViewHolder
void onBindViewHolder (Presenter.ViewHolder viewHolder, Object item)
Binds a View
to an item.
Parameters | |
---|---|
viewHolder |
Presenter.ViewHolder |
item |
Object |
onBindViewHolder
void onBindViewHolder (Presenter.ViewHolder viewHolder, Object item, List<Object> payloads)
Binds a View
to an item with a list of payloads.
Parameters | |
---|---|
viewHolder |
Presenter.ViewHolder : The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set. |
item |
Object : The item which should be bound to view holder. |
payloads |
List : A non-null list of merged payloads. Can be empty list if requires full
update.
|
onCreateViewHolder
Presenter.ViewHolder onCreateViewHolder (ViewGroup parent)
Creates a new View
.
Parameters | |
---|---|
parent |
ViewGroup |
Returns | |
---|---|
Presenter.ViewHolder |
onUnbindViewHolder
void onUnbindViewHolder (Presenter.ViewHolder viewHolder)
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.
Parameters | |
---|---|
viewHolder |
Presenter.ViewHolder |
onViewAttachedToWindow
void onViewAttachedToWindow (Presenter.ViewHolder holder)
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
|
onViewDetachedFromWindow
void onViewDetachedFromWindow (Presenter.ViewHolder holder)
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
|
setFacet
void setFacet (Class<?> facetClass, Object facetImpl)
Sets dynamic implemented facet in addition to basic Presenter functions.
Parameters | |
---|---|
facetClass |
Class : Facet classes to query, can be class of ItemAlignmentFacet . |
facetImpl |
Object : Facet implementation.
|
setOnClickListener
void setOnClickListener (Presenter.ViewHolder holder, View.OnClickListener listener)
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.
|
Protected methods
cancelAnimationsRecursive
void cancelAnimationsRecursive (View view)
Utility method for removing all running animations on a view.
Parameters | |
---|---|
view |
View |
Interfaces
- BaseGridView.OnKeyInterceptListener
- BaseGridView.OnMotionInterceptListener
- BaseGridView.OnTouchInterceptListener
- BaseGridView.OnUnhandledKeyListener
- BaseOnItemViewClickedListener
- BaseOnItemViewSelectedListener
- BrowseFrameLayout.OnChildFocusListener
- BrowseFrameLayout.OnFocusSearchListener
- FacetProvider
- FacetProviderAdapter
- FocusHighlight
- FragmentAnimationProvider
- ImeKeyMonitor
- ImeKeyMonitor.ImeKeyListener
- MultiActionsProvider
- OnActionClickedListener
- OnChildLaidOutListener
- OnChildSelectedListener
- OnItemViewClickedListener
- OnItemViewSelectedListener
- PlaybackSeekUi
- SearchBar.SearchBarListener
- SearchBar.SearchBarPermissionListener
- SearchEditText.OnKeyboardDismissListener
- SpeechRecognitionCallback
- TitleViewAdapter.Provider
- ViewHolderTask
Classes
- AbstractDetailsDescriptionPresenter
- AbstractDetailsDescriptionPresenter.ViewHolder
- AbstractMediaItemPresenter
- AbstractMediaItemPresenter.ViewHolder
- AbstractMediaListHeaderPresenter
- AbstractMediaListHeaderPresenter.ViewHolder
- Action
- ArrayObjectAdapter
- BaseCardView
- BaseCardView.LayoutParams
- BaseGridView
- BrowseFrameLayout
- ClassPresenterSelector
- ControlButtonPresenterSelector
- CursorObjectAdapter
- DetailsOverviewLogoPresenter
- DetailsOverviewLogoPresenter.ViewHolder
- DetailsOverviewRow
- DetailsOverviewRow.Listener
- DetailsOverviewRowPresenter
- DetailsOverviewRowPresenter.ViewHolder
- DetailsParallax
- DiffCallback
- DividerPresenter
- DividerRow
- FocusHighlightHelper
- FullWidthDetailsOverviewRowPresenter
- FullWidthDetailsOverviewRowPresenter.Listener
- FullWidthDetailsOverviewRowPresenter.ViewHolder
- FullWidthDetailsOverviewRowPresenter.ViewHolder.DetailsOverviewRowListener
- FullWidthDetailsOverviewSharedElementHelper
- GuidanceStylist
- GuidanceStylist.Guidance
- GuidedAction
- GuidedAction.Builder
- GuidedAction.BuilderBase
- GuidedActionDiffCallback
- GuidedActionEditText
- GuidedActionsStylist
- GuidedActionsStylist.ViewHolder
- GuidedDatePickerAction
- GuidedDatePickerAction.Builder
- GuidedDatePickerAction.BuilderBase
- HeaderItem
- HorizontalGridView
- HorizontalHoverCardSwitcher
- ImageCardView
- ItemAlignmentFacet
- ItemAlignmentFacet.ItemAlignmentDef
- ItemBridgeAdapter
- ItemBridgeAdapter.AdapterListener
- ItemBridgeAdapter.ViewHolder
- ItemBridgeAdapter.Wrapper
- ItemBridgeAdapterShadowOverlayWrapper
- ListRow
- ListRowHoverCardView
- ListRowPresenter
- ListRowPresenter.SelectItemViewHolderTask
- ListRowPresenter.ViewHolder
- ListRowView
- MultiActionsProvider.MultiAction
- ObjectAdapter
- ObjectAdapter.DataObserver
- OnChildViewHolderSelectedListener
- PageRow
- Parallax
- Parallax.FloatProperty
- Parallax.IntProperty
- Parallax.PropertyMarkerValue
- ParallaxEffect
- ParallaxTarget
- ParallaxTarget.DirectPropertyTarget
- ParallaxTarget.PropertyValuesHolderTarget
- PlaybackControlsRow
- PlaybackControlsRow.ClosedCaptioningAction
- PlaybackControlsRow.FastForwardAction
- PlaybackControlsRow.HighQualityAction
- PlaybackControlsRow.MoreActions
- PlaybackControlsRow.MultiAction
- PlaybackControlsRow.OnPlaybackProgressCallback
- PlaybackControlsRow.PictureInPictureAction
- PlaybackControlsRow.PlayPauseAction
- PlaybackControlsRow.RepeatAction
- PlaybackControlsRow.RewindAction
- PlaybackControlsRow.ShuffleAction
- PlaybackControlsRow.SkipNextAction
- PlaybackControlsRow.SkipPreviousAction
- PlaybackControlsRow.ThumbsAction
- PlaybackControlsRow.ThumbsDownAction
- PlaybackControlsRow.ThumbsUpAction
- PlaybackControlsRowPresenter
- PlaybackControlsRowPresenter.ViewHolder
- PlaybackRowPresenter
- PlaybackRowPresenter.ViewHolder
- PlaybackSeekDataProvider
- PlaybackSeekDataProvider.ResultCallback
- PlaybackSeekUi.Client
- PlaybackTransportRowPresenter
- PlaybackTransportRowPresenter.ViewHolder
- Presenter
- Presenter.ViewHolder
- Presenter.ViewHolderTask
- PresenterSelector
- PresenterSwitcher
- RecyclerViewParallax
- RecyclerViewParallax.ChildPositionProperty
- Row
- RowHeaderPresenter
- RowHeaderPresenter.ViewHolder
- RowHeaderView
- RowPresenter
- RowPresenter.ViewHolder
- SearchBar
- SearchEditText
- SearchOrbView
- SearchOrbView.Colors
- SectionRow
- ShadowOverlayContainer
- ShadowOverlayHelper
- ShadowOverlayHelper.Builder
- ShadowOverlayHelper.Options
- SinglePresenterSelector
- SparseArrayObjectAdapter
- SpeechOrbView
- TitleHelper
- TitleView
- TitleViewAdapter
- VerticalGridPresenter
- VerticalGridPresenter.ViewHolder
- VerticalGridView
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.
Last updated 2024-04-11 UTC.