public class ListViewAdapter extends RecyclerView.Adapter<ListViewHolder>
RadListView
.
Adapters provide a binding from an app-specific data set to views that are displayed
within a RadListView
.
Constructor and Description |
---|
ListViewAdapter(List items)
Creates an instance of the
ListViewAdapter class. |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Object item)
Inserts the specified object into this
ListViewAdapter
at the specified index. |
void |
add(Object item)
Adds the specified item at the end of the items in
this
ListViewAdapter . |
boolean |
canDeselect(int position)
Determines if the item at the provided position can be deselected.
|
boolean |
canReorder(int position)
Determines if the item at the provided position can be reordered.
|
boolean |
canSelect(int position)
Determines if the item at the provided position is selectable.
|
boolean |
canSwipe(int position)
Determines if the item at the provided position can be swiped.
|
Object |
getItem(int position)
Return the item on the provided position.
|
Object |
getItem(long id)
Return the item with the provided id.
|
int |
getItemCount() |
long |
getItemId(int position) |
long |
getItemId(Object item)
Return the id of the item that is provided.
|
List |
getItems()
Gets the list of items handled by this adapter instance.
|
int |
getPosition(long id)
Return the position of the item with the provided id.
|
int |
getPosition(Object searchItem)
Return the position of the item that is provided.
|
void |
notifyLoadingFinished()
Notify an instance of
LoadOnDemandBehavior if attached,
that the loading operation is complete. |
void |
notifyRefreshFinished()
Notify an instance of
SwipeRefreshBehavior if attached,
that the refresh operation is complete. |
void |
notifySwipeExecuteFinished()
Notify an instance of
SwipeExecuteBehavior if attached,
that the execute operation is complete so that the item can hide the swipe content. |
void |
onBindSwipeContentHolder(ListViewHolder holder,
int position)
Called by
RadListView to display the swipe content
behind an item at the specified position. |
void |
onBindViewHolder(ListViewHolder holder,
int position) |
ListViewHolder |
onCreateSwipeContentHolder(ViewGroup parent)
Called when
RadListView needs a
new ListViewHolder to present any swipe content. |
ListViewHolder |
onCreateViewHolder(ViewGroup parent,
int viewType) |
Object |
remove(int index)
Removes the object at the specified index from the list
of items in this
ListViewAdapter . |
boolean |
remove(Object item)
Removes the first occurrence of the specified object from the list
of items in this
ListViewAdapter . |
boolean |
reorderItem(int oldPosition,
int newPosition)
Provides the reorder operation as requested by an
ItemReorderBehavior instance. |
void |
setItems(List items)
Sets a new list of items to be handled by this adapter instance.
|
bindViewHolder, createViewHolder, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
public ListViewAdapter(List items)
ListViewAdapter
class.items
- a list of items that will be handled by this adapterpublic void add(Object item)
ListViewAdapter
.item
- the object to add.public void add(int index, Object item)
ListViewAdapter
at the specified index. The object is inserted before the current element at the
specified index.index
- the index at which to insert.item
- the object to add.public boolean remove(Object item)
ListViewAdapter
.item
- the object to remove.public Object remove(int index)
ListViewAdapter
.index
- the index of the object to remove.public void notifyLoadingFinished()
LoadOnDemandBehavior
if attached,
that the loading operation is complete.LoadOnDemandBehavior
public void notifyRefreshFinished()
SwipeRefreshBehavior
if attached,
that the refresh operation is complete.SwipeRefreshBehavior
public boolean canSelect(int position)
SelectionBehavior
public boolean canDeselect(int position)
SelectionBehavior
public boolean canSwipe(int position)
SwipeRefreshBehavior
public ListViewHolder onCreateSwipeContentHolder(ViewGroup parent)
RadListView
needs a
new ListViewHolder
to present any swipe content.
Note that the default holder that is created contains a
FrameLayout
with two children of type LinearLayout
.
The first is aligned to the left and the second is aligned to the right. In most cases you won't
need to override this method as you can simply add your desired content to each of the
child layouts in order to show that content when the user swipes to the right or to the left.
parent
- The ViewGroup into which the new View will be added after it is bound to
an adapter position.SwipeExecuteBehavior
,
onBindSwipeContentHolder(ListViewHolder, int)
public void onBindSwipeContentHolder(ListViewHolder holder, int position)
RadListView
to display the swipe content
behind an item at the specified position. This method
should update the contents of the RecyclerView.ViewHolder.itemView
to reflect the swipe content behind the item at the given position.
Note that the default holder that is created in the original
onCreateSwipeContentHolder(android.view.ViewGroup)
method contains a
FrameLayout
with two children of type LinearLayout
.
The first is aligned to the left and the second is aligned to the right. In most cases you won't
need to override onCreateSwipeContentHolder(android.view.ViewGroup)
as you can simply
add your desired content to each of the child layouts in order to show that content
when the user swipes to the right or to the left.
holder
- The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set.position
- The position of the item within the adapter's data set.SwipeExecuteBehavior
,
onCreateSwipeContentHolder(android.view.ViewGroup)
public void notifySwipeExecuteFinished()
SwipeExecuteBehavior
if attached,
that the execute operation is complete so that the item can hide the swipe content.SwipeRefreshBehavior
public boolean canReorder(int position)
ItemReorderBehavior
public boolean reorderItem(int oldPosition, int newPosition)
ItemReorderBehavior
instance.ItemReorderBehavior
public List getItems()
setItems(java.util.List)
public void setItems(List items)
getItems()
public Object getItem(long id)
id
- the item id to querypublic Object getItem(int position)
position
- the position of the itempublic int getPosition(long id)
INVALID_ID
if an item with that id is not found.id
- the item id to querypublic int getPosition(Object searchItem)
-1
if the item is not found.searchItem
- the item to querypublic long getItemId(Object item)
-1
if the item is not found.item
- the item to querypublic ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
onCreateViewHolder
in class RecyclerView.Adapter<ListViewHolder>
public void onBindViewHolder(ListViewHolder holder, int position)
onBindViewHolder
in class RecyclerView.Adapter<ListViewHolder>
public int getItemCount()
getItemCount
in class RecyclerView.Adapter<ListViewHolder>
public long getItemId(int position)
getItemId
in class RecyclerView.Adapter<ListViewHolder>