public class BindingRecyclerViewAdapter<T>
extends <any>
RecyclerView.Adapter that binds items to layouts using the given ItemBinding.
If you give it an ObservableList it will also updated itself based on changes to that
list.| Modifier and Type | Class and Description |
|---|---|
static interface |
BindingRecyclerViewAdapter.ItemIds<T> |
static interface |
BindingRecyclerViewAdapter.ViewHolderFactory |
| Constructor and Description |
|---|
BindingRecyclerViewAdapter() |
BindingRecyclerViewAdapter(<any> itemBinding)
Constructs a new instance with the given item binding.
|
| Modifier and Type | Method and Description |
|---|---|
T |
getAdapterItem(int position) |
<any> |
getItemBinding() |
int |
getItemCount() |
long |
getItemId(int position) |
int |
getItemViewType(int position) |
void |
onAttachedToRecyclerView(RecyclerView recyclerView) |
void |
onBindBinding(ViewDataBinding binding,
int variableId,
int layoutRes,
int position,
T item) |
void |
onBindViewHolder(ViewHolder viewHolder,
int position) |
void |
onBindViewHolder(ViewHolder holder,
int position,
java.util.List<java.lang.Object> payloads) |
ViewDataBinding |
onCreateBinding(LayoutInflater inflater,
int layoutId,
ViewGroup viewGroup) |
ViewHolder |
onCreateViewHolder(ViewDataBinding binding)
Constructs a view holder for the given databinding.
|
ViewHolder |
onCreateViewHolder(ViewGroup viewGroup,
int layoutId) |
void |
onDetachedFromRecyclerView(RecyclerView recyclerView) |
void |
setItemBinding(<any> itemBinding) |
void |
setItemIds(BindingRecyclerViewAdapter.ItemIds<? super T> itemIds)
Set the item id's for the items.
|
void |
setItems(java.util.List<T> items) |
void |
setLifecycleOwner(LifecycleOwner lifecycleOwner)
Sets the lifecycle owner of this adapter to work with
androidx.lifecycle.LiveData. |
void |
setViewHolderFactory(BindingRecyclerViewAdapter.ViewHolderFactory factory)
Set the factory for creating view holders.
|
public BindingRecyclerViewAdapter()
public BindingRecyclerViewAdapter(<any> itemBinding)
public void setItemBinding(<any> itemBinding)
public void setLifecycleOwner(LifecycleOwner lifecycleOwner)
androidx.lifecycle.LiveData.
This is normally not necessary, but due to an androidx limitation, you need to set this if
the containing view is not using databinding.public <any> getItemBinding()
public void setItems(java.util.List<T> items)
public T getAdapterItem(int position)
public ViewDataBinding onCreateBinding(LayoutInflater inflater,
int layoutId,
ViewGroup viewGroup)
public void onBindBinding(ViewDataBinding binding,
int variableId,
int layoutRes,
int position,
T item)
public void onAttachedToRecyclerView(RecyclerView recyclerView)
public void onDetachedFromRecyclerView(RecyclerView recyclerView)
public final ViewHolder onCreateViewHolder(ViewGroup viewGroup,
int layoutId)
public ViewHolder onCreateViewHolder(ViewDataBinding binding)
BindingRecyclerViewAdapter.ViewHolderFactory if provided, otherwise use a default view holder.public final void onBindViewHolder(ViewHolder viewHolder,
int position)
public void onBindViewHolder(ViewHolder holder,
int position,
java.util.List<java.lang.Object> payloads)
public int getItemViewType(int position)
public void setItemIds(BindingRecyclerViewAdapter.ItemIds<? super T> itemIds)
RecyclerView.Adapter#setHasStableIds(boolean) to true.public void setViewHolderFactory(BindingRecyclerViewAdapter.ViewHolderFactory factory)
public int getItemCount()
public long getItemId(int position)