belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
ItemBridgeAdapter
public
class
ItemBridgeAdapter
extends Adapter
implements
FacetProviderAdapter
java.lang.Object | ||
↳ | android.support.v7.widget.RecyclerView.Adapter | |
↳ | android.support.v17.leanback.widget.ItemBridgeAdapter |
Bridge from Presenter
to RecyclerView.Adapter
. Public to allow use by third
party Presenters.
Summary
Nested classes | |
---|---|
class |
ItemBridgeAdapter.AdapterListener
Interface for listening to ViewHolder operations. |
class |
ItemBridgeAdapter.ViewHolder
ViewHolder for the ItemBridgeAdapter. |
class |
ItemBridgeAdapter.Wrapper
Interface for wrapping a view created by a Presenter into another view. |
Public constructors | |
---|---|
ItemBridgeAdapter(ObjectAdapter adapter, PresenterSelector presenterSelector)
|
|
ItemBridgeAdapter(ObjectAdapter adapter)
|
|
ItemBridgeAdapter()
|
Public methods | |
---|---|
void
|
clear()
Clears the adapter. |
FacetProvider
|
getFacetProvider(int type)
Queries |
int
|
getItemCount()
Returns the total number of items in the data set held by the adapter. |
long
|
getItemId(int position)
Return the stable ID for the item at |
int
|
getItemViewType(int position)
Return the view type of the item at |
ArrayList<Presenter>
|
getPresenterMapper()
Returns the presenter mapper array. |
ItemBridgeAdapter.Wrapper
|
getWrapper()
Returns the |
final
void
|
onBindViewHolder(RecyclerView.ViewHolder holder, int position)
Called by RecyclerView to display the data at the specified position. |
final
void
|
onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads)
Called by RecyclerView to display the data at the specified position. |
final
RecyclerView.ViewHolder
|
onCreateViewHolder(ViewGroup parent, int viewType)
|
final
void
|
onViewAttachedToWindow(RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been attached to a window. |
final
void
|
onViewDetachedFromWindow(RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been detached from its window. |
final
void
|
onViewRecycled(RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been recycled. |
void
|
setAdapter(ObjectAdapter adapter)
Sets the |
void
|
setAdapterListener(ItemBridgeAdapter.AdapterListener listener)
Sets the AdapterListener. |
void
|
setPresenter(PresenterSelector presenterSelector)
Changes Presenter that creates and binds the view. |
void
|
setPresenterMapper(ArrayList<Presenter> presenters)
Sets the presenter mapper array. |
void
|
setWrapper(ItemBridgeAdapter.Wrapper wrapper)
Sets the |
Protected methods | |
---|---|
void
|
onAddPresenter(Presenter presenter, int type)
Called when presenter is added to Adapter. |
void
|
onAttachedToWindow(ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been attached to window. |
void
|
onBind(ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been bound to data. |
void
|
onCreate(ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder is created. |
void
|
onDetachedFromWindow(ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been detached from window. |
void
|
onUnbind(ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been unbound from data. |
Inherited methods | |
---|---|
From
class
android.support.v7.widget.RecyclerView.Adapter
| |
From
class
java.lang.Object
| |
From
interface
android.support.v17.leanback.widget.FacetProviderAdapter
|
Public constructors
ItemBridgeAdapter
ItemBridgeAdapter (ObjectAdapter adapter, PresenterSelector presenterSelector)
Parameters | |
---|---|
adapter |
ObjectAdapter |
presenterSelector |
PresenterSelector |
ItemBridgeAdapter
ItemBridgeAdapter (ObjectAdapter adapter)
Parameters | |
---|---|
adapter |
ObjectAdapter |
Public methods
getFacetProvider
FacetProvider getFacetProvider (int type)
Queries FacetProvider
for a given type within Adapter.
Parameters | |
---|---|
type |
int : type of the item. |
Returns | |
---|---|
FacetProvider |
Facet provider for the type. |
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
Returns | |
---|---|
int |
The total number of items in this adapter. |
getItemId
long getItemId (int position)
Return the stable ID for the item at position
. If hasStableIds()
would return false this method should return NO_ID
. The default implementation
of this method returns NO_ID
.
Parameters | |
---|---|
position |
int : Adapter position to query |
Returns | |
---|---|
long |
the stable ID of the item at position |
getItemViewType
int getItemViewType (int position)
Return the view type of the item at position
for the purposes
of view recycling.
The default implementation of this method returns 0, making the assumption of a single view type for the adapter. Unlike ListView adapters, types need not be contiguous. Consider using id resources to uniquely identify item view types.
Parameters | |
---|---|
position |
int : position to query |
Returns | |
---|---|
int |
integer value identifying the type of the view needed to represent the item at
position . Type codes need not be contiguous.
|
getPresenterMapper
ArrayList<Presenter> getPresenterMapper ()
Returns the presenter mapper array.
Returns | |
---|---|
ArrayList<Presenter> |
getWrapper
ItemBridgeAdapter.Wrapper getWrapper ()
Returns the ItemBridgeAdapter.Wrapper
.
Returns | |
---|---|
ItemBridgeAdapter.Wrapper |
onBindViewHolder
void onBindViewHolder (RecyclerView.ViewHolder holder, int position)
Called by RecyclerView to display the data at the specified position. This method should
update the contents of the itemView
to reflect the item at the given
position.
Note that unlike ListView
, RecyclerView will not call this method
again if the position of the item changes in the data set unless the item itself is
invalidated or the new position cannot be determined. For this reason, you should only
use the position
parameter while acquiring the related data item inside
this method and should not keep a copy of it. If you need the position of an item later
on (e.g. in a click listener), use getAdapterPosition()
which will
have the updated adapter position.
Override onBindViewHolder(ViewHolder, int, List)
instead if Adapter can
handle efficient partial bind.
Parameters | |
---|---|
holder |
RecyclerView.ViewHolder : The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set. |
position |
int : The position of the item within the adapter's data set.
|
onBindViewHolder
void onBindViewHolder (RecyclerView.ViewHolder holder, int position, List payloads)
Called by RecyclerView to display the data at the specified position. This method
should update the contents of the itemView
to reflect the item at
the given position.
Note that unlike ListView
, RecyclerView will not call this method
again if the position of the item changes in the data set unless the item itself is
invalidated or the new position cannot be determined. For this reason, you should only
use the position
parameter while acquiring the related data item inside
this method and should not keep a copy of it. If you need the position of an item later
on (e.g. in a click listener), use getAdapterPosition()
which will
have the updated adapter position.
Partial bind vs full bind:
The payloads parameter is a merge list from notifyItemChanged(int, Object)
or
notifyItemRangeChanged(int, int, Object)
. If the payloads list is not empty,
the ViewHolder is currently bound to old data and Adapter may run an efficient partial
update using the payload info. If the payload is empty, Adapter must run a full bind.
Adapter should not assume that the payload passed in notify methods will be received by
onBindViewHolder(). For example when the view is not attached to the screen, the
payload in notifyItemChange() will be simply dropped.
Parameters | |
---|---|
holder |
RecyclerView.ViewHolder : The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set. |
position |
int : The position of the item within the adapter's data set. |
payloads |
List : A non-null list of merged payloads. Can be empty list if requires full
update.
|
onCreateViewHolder
RecyclerView.ViewHolder onCreateViewHolder (ViewGroup parent, int viewType)
View.OnFocusChangeListener
that assigned in
onCreateViewHolder(ViewGroup)
may be chained, user should never change
View.OnFocusChangeListener
after that.
Parameters | |
---|---|
parent |
ViewGroup : The ViewGroup into which the new View will be added after it is bound to
an adapter position. |
viewType |
int : The view type of the new View. |
Returns | |
---|---|
RecyclerView.ViewHolder |
A new ViewHolder that holds a View of the given view type. |
onViewAttachedToWindow
void onViewAttachedToWindow (RecyclerView.ViewHolder holder)
Called when a view created by this adapter 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
those resources should be restored here.
Parameters | |
---|---|
holder |
RecyclerView.ViewHolder : Holder of the view being attached
|
onViewDetachedFromWindow
void onViewDetachedFromWindow (RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been detached from its window.
Becoming detached from the window is not necessarily a permanent condition; the consumer of an Adapter's views may choose to cache views offscreen while they are not visible, attaching and detaching them as appropriate.
Parameters | |
---|---|
holder |
RecyclerView.ViewHolder : Holder of the view being detached
|
onViewRecycled
void onViewRecycled (RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been recycled.
A view is recycled when a RecyclerView.LayoutManager
decides that it no longer
needs to be attached to its parent RecyclerView
. This can be because it has
fallen out of visibility or a set of cached views represented by views still
attached to the parent RecyclerView. If an item view has large or expensive data
bound to it such as large bitmaps, this may be a good place to release those
resources.
RecyclerView calls this method right before clearing ViewHolder's internal data and
sending it to RecycledViewPool. This way, if ViewHolder was holding valid information
before being recycled, you can call getAdapterPosition()
to get
its adapter position.
Parameters | |
---|---|
holder |
RecyclerView.ViewHolder : The ViewHolder for the view being recycled
|
setAdapter
void setAdapter (ObjectAdapter adapter)
Sets the ObjectAdapter
.
Parameters | |
---|---|
adapter |
ObjectAdapter |
setAdapterListener
void setAdapterListener (ItemBridgeAdapter.AdapterListener listener)
Sets the AdapterListener.
Parameters | |
---|---|
listener |
ItemBridgeAdapter.AdapterListener |
setPresenter
void setPresenter (PresenterSelector presenterSelector)
Changes Presenter that creates and binds the view.
Parameters | |
---|---|
presenterSelector |
PresenterSelector : Presenter that creates and binds the view.
|
setPresenterMapper
void setPresenterMapper (ArrayList<Presenter> presenters)
Sets the presenter mapper array.
Parameters | |
---|---|
presenters |
ArrayList |
setWrapper
void setWrapper (ItemBridgeAdapter.Wrapper wrapper)
Sets the ItemBridgeAdapter.Wrapper
.
Parameters | |
---|---|
wrapper |
ItemBridgeAdapter.Wrapper |
Protected methods
onAddPresenter
void onAddPresenter (Presenter presenter, int type)
Called when presenter is added to Adapter.
Parameters | |
---|---|
presenter |
Presenter |
type |
int |
onAttachedToWindow
void onAttachedToWindow (ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been attached to window.
Parameters | |
---|---|
viewHolder |
ItemBridgeAdapter.ViewHolder |
onBind
void onBind (ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been bound to data.
Parameters | |
---|---|
viewHolder |
ItemBridgeAdapter.ViewHolder |
onCreate
void onCreate (ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder is created.
Parameters | |
---|---|
viewHolder |
ItemBridgeAdapter.ViewHolder |
onDetachedFromWindow
void onDetachedFromWindow (ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been detached from window.
Parameters | |
---|---|
viewHolder |
ItemBridgeAdapter.ViewHolder |
onUnbind
void onUnbind (ItemBridgeAdapter.ViewHolder viewHolder)
Called when ViewHolder has been unbound from data.
Parameters | |
---|---|
viewHolder |
ItemBridgeAdapter.ViewHolder |
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.