E - entity element typeVH - view holder typepublic abstract class QueryRecyclerAdapter<E,VH extends RecyclerView.ViewHolder>
extends <any>
implements java.io.Closeable
android.support.v7.widget.RecyclerView.Adapter specifically for
displaying items from a EntityDataStore query. To use extend this class and implement
performQuery() and onBindViewHolder(Object, RecyclerView.ViewHolder, int).| Modifier | Constructor and Description |
|---|---|
protected |
QueryRecyclerAdapter()
Creates a new adapter instance without any type mapping.
|
protected |
QueryRecyclerAdapter(io.requery.meta.EntityModel model,
java.lang.Class<E> type)
Creates a new adapter instance.
|
protected |
QueryRecyclerAdapter(io.requery.meta.Type<E> type)
Creates a new adapter instance mapped to the given type.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Call this to clean up the underlying result.
|
int |
getItemCount() |
long |
getItemId(int position) |
protected int |
getItemViewType(E item)
Return the view type of the item.
|
int |
getItemViewType(int position) |
protected io.requery.sql.ResultSetIterator<E> |
getIterator() |
abstract void |
onBindViewHolder(E item,
VH holder,
int position)
Called to display the data at the specified position for the given item.
|
void |
onBindViewHolder(VH holder,
int position) |
void |
onDetachedFromRecyclerView(RecyclerView recyclerView) |
abstract io.requery.query.Result<E> |
performQuery()
Implement this method with your query operation.
|
void |
queryAsync()
Schedules the query to be run in the background.
|
void |
setExecutor(java.util.concurrent.ExecutorService executor)
Sets the
Executor used for running the query off the main thread. |
void |
setResult(io.requery.sql.ResultSetIterator<E> iterator)
Sets the results the adapter should display.
|
protected QueryRecyclerAdapter(io.requery.meta.EntityModel model,
java.lang.Class<E> type)
model - database entity modeltype - entity class typeprotected QueryRecyclerAdapter()
protected QueryRecyclerAdapter(io.requery.meta.Type<E> type)
type - entity typepublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableprotected io.requery.sql.ResultSetIterator<E> getIterator()
public void setExecutor(java.util.concurrent.ExecutorService executor)
Executor used for running the query off the main thread.executor - ExecutorService to use for the background query.public void setResult(io.requery.sql.ResultSetIterator<E> iterator)
iterator - result set iteratorpublic void queryAsync()
setResult(ResultSetIterator) will be called to update the contents of the adapter.
Note if an Executor was not specified one will be created automatically to run the
query.public abstract io.requery.query.Result<E> performQuery()
setExecutor(ExecutorService)public void onBindViewHolder(VH holder, int position)
public abstract void onBindViewHolder(E item, VH holder, int position)
item - entity element to bind to the viewholder - view holder to be updatedposition - position index of the viewpublic long getItemId(int position)
public int getItemCount()
public int getItemViewType(int position)
protected int getItemViewType(E item)
item - being checkedpublic void onDetachedFromRecyclerView(RecyclerView recyclerView)