public abstract class BaseBindingAdapter<T extends AdapterItem,U extends androidx.databinding.ViewDataBinding,V extends BaseHandlers,VM extends androidx.lifecycle.ViewModel,VH extends BaseViewHolder>
extends androidx.recyclerview.widget.RecyclerView.Adapter<VH>
RecyclerView
and its' data
using a ViewModel and data bindingModifier and Type | Class and Description |
---|---|
(package private) class |
BaseBindingAdapter.BaseDiffCallback
Class to determine what has changed in our list
|
Modifier and Type | Field and Description |
---|---|
private androidx.recyclerview.widget.AsyncListDiffer<T> |
mDiffer
Helper to handle List changes
|
private V |
mHandlers
Our event handlers
|
private int |
mlayoutId
Our layout
|
protected androidx.lifecycle.LifecycleOwner |
mLifecycleOwner
Our LifecycleOwner
|
private VHAdapterFactory<VH,U> |
mVHFactory
Factory to create a typed ViewHolder
|
private VMAdapterFactory<VM,T> |
mVMFactory
Factory to create a typed ViewModel
|
private java.lang.String |
TAG
Class identifier
|
Modifier | Constructor and Description |
---|---|
protected |
BaseBindingAdapter(VHAdapterFactory<VH,U> holderFactory,
VMAdapterFactory<VM,T> modelFactory,
int layoutId,
androidx.lifecycle.LifecycleOwner owner,
V handlers) |
Modifier and Type | Method and Description |
---|---|
private T |
getItem(int position) |
int |
getItemCount() |
long |
getItemId(int position) |
void |
onBindViewHolder(VH holder,
int position) |
VH |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType) |
void |
submitList(java.util.List<T> list)
Pass a new List to the AdapterHelper.
|
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
private final java.lang.String TAG
protected final androidx.lifecycle.LifecycleOwner mLifecycleOwner
private final int mlayoutId
private final V extends BaseHandlers mHandlers
private final androidx.recyclerview.widget.AsyncListDiffer<T extends AdapterItem> mDiffer
private final VHAdapterFactory<VH extends BaseViewHolder,U extends androidx.databinding.ViewDataBinding> mVHFactory
private final VMAdapterFactory<VM extends androidx.lifecycle.ViewModel,T extends AdapterItem> mVMFactory
protected BaseBindingAdapter(VHAdapterFactory<VH,U> holderFactory, VMAdapterFactory<VM,T> modelFactory, int layoutId, androidx.lifecycle.LifecycleOwner owner, V handlers)
@NonNull public VH onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
onCreateViewHolder
in class androidx.recyclerview.widget.RecyclerView.Adapter<VH extends BaseViewHolder>
public void onBindViewHolder(@NonNull VH holder, int position)
onBindViewHolder
in class androidx.recyclerview.widget.RecyclerView.Adapter<VH extends BaseViewHolder>
public int getItemCount()
getItemCount
in class androidx.recyclerview.widget.RecyclerView.Adapter<VH extends BaseViewHolder>
public long getItemId(int position)
getItemId
in class androidx.recyclerview.widget.RecyclerView.Adapter<VH extends BaseViewHolder>
public void submitList(java.util.List<T> list)
If a List is already present, a diff will be computed asynchronously on a background thread. When the diff is computed, it will be applied, and the new List will be swapped in.
list
- The new List.private T getItem(int position)