T - type of RealmModel stored in the adapter.S - type of RecyclerView.ViewHolder used in the adapter.public abstract class RealmRecyclerViewAdapter<T extends io.realm.RealmModel,S extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<S>
This adapter will automatically handle any updates to its data and call notifyDataSetChanged(),
notifyItemInserted(), notifyItemRemoved() or notifyItemRangeChanged( as appropriate.
The RealmAdapter will stop receiving updates if the Realm instance providing the OrderedRealmCollection is
closed.
| Constructor and Description |
|---|
RealmRecyclerViewAdapter(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(RecyclerView recyclerView) |
void |
onDetachedFromRecyclerView(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 void onAttachedToRecyclerView(RecyclerView recyclerView)
onAttachedToRecyclerView in class RecyclerView.Adapter<S extends RecyclerView.ViewHolder>public void onDetachedFromRecyclerView(RecyclerView recyclerView)
onDetachedFromRecyclerView in class RecyclerView.Adapter<S extends RecyclerView.ViewHolder>public long getItemId(int index)
updateData(OrderedRealmCollection) has been called.getItemId in class RecyclerView.Adapter<S extends RecyclerView.ViewHolder>index - position of item in the adapter.public int getItemCount()
getItemCount in class RecyclerView.Adapter<S extends RecyclerView.ViewHolder>@Nullable 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.@Nullable public io.realm.OrderedRealmCollection<T> getData()
public void updateData(@Nullable io.realm.OrderedRealmCollection<T> data)
data - the new OrderedRealmCollection to display.