T - type of RealmObject stored in the adapter.VH - type of RecyclerView.ViewHolder used in the adapter.public abstract class RealmRecyclerViewAdapter<T extends io.realm.RealmObject,VH extends android.support.v7.widget.RecyclerView.ViewHolder>
extends android.support.v7.widget.RecyclerView.Adapter<VH>
This adapter will automatically handle any updates to its data and call notifyDataSetChanged() as appropriate. Currently there is no support for RecyclerView's data callback methods like notifyItemInserted(int), notifyItemRemoved(int), notifyItemChanged(int) etc. It means that, there is no possibility to use default data animations.
The RealmAdapter will stop receiving updates if the Realm instance providing the OrderedRealmCollection is
closed.
| Constructor and Description |
|---|
RealmRecyclerViewAdapter(android.content.Context context,
io.realm.OrderedRealmCollection<T> data,
boolean autoUpdate) |
| Modifier and Type | Method and Description |
|---|---|
io.realm.OrderedRealmCollection<T> |
getData()
Returns data associated with this adapter.
|
T |
getItem(int index)
Returns the item associated with the specified position.
|
int |
getItemCount() |
long |
getItemId(int index)
Returns the current ID for an item.
|
void |
onAttachedToRecyclerView(android.support.v7.widget.RecyclerView recyclerView) |
void |
onDetachedFromRecyclerView(android.support.v7.widget.RecyclerView recyclerView) |
void |
updateData(io.realm.OrderedRealmCollection<T> data)
Updates the data associated to the Adapter.
|
bindViewHolder, createViewHolder, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onBindViewHolder, onBindViewHolder, onCreateViewHolder, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserverpublic RealmRecyclerViewAdapter(android.content.Context context,
io.realm.OrderedRealmCollection<T> data,
boolean autoUpdate)
public void onAttachedToRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
onAttachedToRecyclerView in class android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>public void onDetachedFromRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
onDetachedFromRecyclerView in class android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>public long getItemId(int index)
updateData(OrderedRealmCollection) has been called.getItemId in class android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>index - position of item in the adapter.public int getItemCount()
getItemCount in class android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>public T getItem(int index)
null if provided Realm instance by OrderedRealmCollection is closed.index - index of the item.null if adapter data is not valid.public io.realm.OrderedRealmCollection<T> getData()
public void updateData(io.realm.OrderedRealmCollection<T> data)
data - the new OrderedRealmCollection to display.