public class FastAdapter<Item extends IItem>
extends android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>
| Modifier and Type | Class and Description |
|---|---|
static interface |
FastAdapter.OnBindViewHolderListener |
class |
FastAdapter.OnBindViewHolderListenerImpl |
static interface |
FastAdapter.OnClickListener<Item extends IItem> |
static interface |
FastAdapter.OnCreateViewHolderListener |
class |
FastAdapter.OnCreateViewHolderListenerImpl
default implementation of the OnCreateViewHolderListener
|
static interface |
FastAdapter.OnLongClickListener<Item extends IItem> |
static interface |
FastAdapter.OnTouchListener<Item extends IItem> |
static class |
FastAdapter.RelativeInfo<Item extends IItem>
an internal class to return the IItem and relativePosition and it's adapter at once. used to save one iteration inside the getInternalItem method
|
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
BUNDLE_EXPANDED |
protected static java.lang.String |
BUNDLE_SELECTIONS |
| Constructor and Description |
|---|
FastAdapter()
default CTOR
|
| Modifier and Type | Method and Description |
|---|---|
void |
collapse()
collapses all expanded items
|
void |
collapse(int position)
collapses (closes) the given collapsible item at the given position
|
java.util.List<Item> |
deleteAllSelectedItems()
deletes all current selected items
|
void |
deselect()
deselects all selections
|
void |
deselect(int position)
deselects an item and removes it's position in the selections list
|
void |
deselect(java.lang.Iterable<java.lang.Integer> positions)
deselects all items at the positions in the iteratable
|
void |
expand(int position)
opens the expandable item at the given position
|
IAdapter<Item> |
getAdapter(int position)
Gets the adapter for the given position
|
int[] |
getExpandedItems() |
Item |
getItem(int position)
gets the IItem by a position, from all registered adapters
|
int |
getItemCount()
calculates the total ItemCount over all registered adapters
|
int |
getItemCount(int order)
calculates the item count up to a given (excluding this) order number
|
long |
getItemId(int position)
finds the int ItemId from the IItem which exists at the given position
|
int |
getItemViewType(int position)
finds the int ItemViewType from the IItem which exists at the given position
|
int |
getPosition(Item item)
Searches for the given item and calculates it's global position
|
FastAdapter.RelativeInfo<Item> |
getRelativeInfo(int position)
Internal method to get the Item as ItemHolder which comes with the relative position within it's adapter
Finds the responsible adapter for the given position
|
java.util.Set<Item> |
getSelectedItems() |
java.util.Set<java.lang.Integer> |
getSelections() |
java.util.Map<java.lang.Integer,Item> |
getTypeInstances() |
void |
notifyAdapterDataSetChanged()
wraps notifyDataSetChanged
|
void |
notifyAdapterItemChanged(int position)
wraps notifyItemChanged
|
void |
notifyAdapterItemChanged(int position,
java.lang.Object payload)
wraps notifyItemChanged
|
void |
notifyAdapterItemInserted(int position)
wraps notifyItemInserted
|
void |
notifyAdapterItemMoved(int fromPosition,
int toPosition)
wraps notifyItemMoved
|
void |
notifyAdapterItemRangeChanged(int position,
int itemCount)
wraps notifyItemRangeChanged
|
void |
notifyAdapterItemRangeChanged(int position,
int itemCount,
java.lang.Object payload)
wraps notifyItemRangeChanged
|
void |
notifyAdapterItemRangeInserted(int position,
int itemCount)
wraps notifyItemRangeInserted
|
void |
notifyAdapterItemRangeRemoved(int position,
int itemCount)
wraps notifyItemRangeRemoved
|
void |
notifyAdapterItemRemoved(int position)
wraps notifyItemRemoved
|
void |
onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder,
int position)
Binds the data to the created ViewHolder and sets the listeners to the holder.itemView
|
android.support.v7.widget.RecyclerView.ViewHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
Creates the ViewHolder by the viewType
|
<A extends AbstractAdapter<Item>> |
registerAdapter(A adapter)
registers an AbstractAdapter which will be hooked into the adapter chain
|
void |
registerTypeInstance(Item item)
register a new type into the TypeInstances to be able to efficiently create thew ViewHolders
|
android.os.Bundle |
saveInstanceState(android.os.Bundle savedInstanceState)
add the values to the bundle for saveInstanceState
|
android.os.Bundle |
saveInstanceState(android.os.Bundle savedInstanceState,
java.lang.String prefix)
add the values to the bundle for saveInstanceState
|
void |
select(int position)
selects an item and remembers it's position in the selections list
|
void |
select(int position,
boolean fireEvent)
selects an item and remembers it's position in the selections list
|
void |
select(java.lang.Iterable<java.lang.Integer> positions)
selects all items at the positions in the iteratable
|
void |
toggleExpandable(int position)
toggles the expanded state of the given expandable item at the given position
|
void |
toggleSelection(int position)
toggles the selection of the item at the given position
|
FastAdapter<Item> |
withAllowDeselection(boolean allowDeselection)
If false, a user can't deselect an item via click (you can still do this programmatically)
|
FastAdapter<Item> |
withMultiSelect(boolean multiSelect)
Enable this if you want multiSelection possible in the list
|
FastAdapter<Item> |
withOnBindViewHolderListener(FastAdapter.OnBindViewHolderListener onBindViewHolderListener)
allows you to set an custom OnBindViewHolderListener which is used to bind the view.
|
FastAdapter<Item> |
withOnClickListener(FastAdapter.OnClickListener<Item> onClickListener)
Define the OnClickListener which will be used for a single item
|
FastAdapter<Item> |
withOnCreateViewHolderListener(FastAdapter.OnCreateViewHolderListener onCreateViewHolderListener)
allows you to set a custom OnCreateViewHolderListener which will be used before and after the ViewHolder is created
You may check the OnCreateViewHolderListenerImpl for the default behavior
|
FastAdapter<Item> |
withOnLongClickListener(FastAdapter.OnLongClickListener<Item> onLongClickListener)
Define the OnLongClickListener which will be used for a single item
|
FastAdapter<Item> |
withOnPreClickListener(FastAdapter.OnClickListener<Item> OnPreClickListener)
Define the OnPreClickListener which will be used for a single item and is called after all internal methods are done
|
FastAdapter<Item> |
withOnPreLongClickListener(FastAdapter.OnLongClickListener<Item> OnPreLongClickListener)
Define the OnLongClickListener which will be used for a single item and is called after all internal methods are done
|
FastAdapter<Item> |
withOnTouchListener(FastAdapter.OnTouchListener<Item> onTouchListener)
Define the TouchListener which will be used for a single item
|
FastAdapter<Item> |
withSavedInstanceState(android.os.Bundle savedInstanceState)
re-selects all elements stored in the savedInstanceState
IMPORTANT!
|
FastAdapter<Item> |
withSavedInstanceState(android.os.Bundle savedInstanceState,
java.lang.String prefix)
re-selects all elements stored in the savedInstanceState
IMPORTANT!
|
FastAdapter<Item> |
withSelectOnLongClick(boolean selectOnLongClick)
Disable this if you want the selection on a single tap
|
FastAdapter<Item> |
withSelectWithItemUpdate(boolean selectWithItemUpdate)
select between the different selection behaviors.
|
bindViewHolder, createViewHolder, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserverprotected static final java.lang.String BUNDLE_SELECTIONS
protected static final java.lang.String BUNDLE_EXPANDED
public FastAdapter<Item> withOnClickListener(FastAdapter.OnClickListener<Item> onClickListener)
onClickListener - the OnClickListener which will be used for a single itempublic FastAdapter<Item> withOnPreClickListener(FastAdapter.OnClickListener<Item> OnPreClickListener)
OnPreClickListener - the OnPreClickListener which will be called after a single item was clicked and all internal methods are donepublic FastAdapter<Item> withOnLongClickListener(FastAdapter.OnLongClickListener<Item> onLongClickListener)
onLongClickListener - the OnLongClickListener which will be used for a single itempublic FastAdapter<Item> withOnPreLongClickListener(FastAdapter.OnLongClickListener<Item> OnPreLongClickListener)
OnPreLongClickListener - the OnLongClickListener which will be called after a single item was clicked and all internal methods are donepublic FastAdapter<Item> withOnTouchListener(FastAdapter.OnTouchListener<Item> onTouchListener)
onTouchListener - the TouchListener which will be used for a single itempublic FastAdapter<Item> withOnCreateViewHolderListener(FastAdapter.OnCreateViewHolderListener onCreateViewHolderListener)
onCreateViewHolderListener - the OnCreateViewHolderListener (you may use the OnCreateViewHolderListenerImpl)public FastAdapter<Item> withOnBindViewHolderListener(FastAdapter.OnBindViewHolderListener onBindViewHolderListener)
onBindViewHolderListener - the OnBindViewHolderListenerpublic FastAdapter<Item> withSelectWithItemUpdate(boolean selectWithItemUpdate)
selectWithItemUpdate - true if notifyItemChanged should be called upon selectpublic FastAdapter<Item> withMultiSelect(boolean multiSelect)
multiSelect - true to enable multiSelectpublic FastAdapter<Item> withSelectOnLongClick(boolean selectOnLongClick)
selectOnLongClick - false to do select via single clickpublic FastAdapter<Item> withAllowDeselection(boolean allowDeselection)
allowDeselection - true if a user can deselect an already selected item via clickpublic FastAdapter<Item> withSavedInstanceState(android.os.Bundle savedInstanceState)
savedInstanceState - If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Note: Otherwise it is null.public FastAdapter<Item> withSavedInstanceState(android.os.Bundle savedInstanceState, java.lang.String prefix)
savedInstanceState - If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Note: Otherwise it is null.prefix - a prefix added to the savedInstance key so we can store multiple statespublic <A extends AbstractAdapter<Item>> void registerAdapter(A adapter)
adapter - an adapter which extends the AbstractAdapterpublic void registerTypeInstance(Item item)
item - an IItem which will be shown in the listpublic java.util.Map<java.lang.Integer,Item> getTypeInstances()
public android.support.v7.widget.RecyclerView.ViewHolder onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
onCreateViewHolder in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>parent - the parent view (the RecyclerView)viewType - the current viewType which is boundpublic void onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder,
int position)
onBindViewHolder in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>holder - the viewHolder we bind the data onposition - the global positionpublic int getPosition(Item item)
item - the item which is searched forpublic Item getItem(int position)
position - the global positionpublic FastAdapter.RelativeInfo<Item> getRelativeInfo(int position)
position - the global positionpublic IAdapter<Item> getAdapter(int position)
position - the global positionpublic int getItemViewType(int position)
getItemViewType in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>position - the global positionpublic long getItemId(int position)
getItemId in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>position - the global positionpublic int getItemCount()
getItemCount in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>public int getItemCount(int order)
order - the number up to which the items are countedpublic android.os.Bundle saveInstanceState(android.os.Bundle savedInstanceState)
savedInstanceState - If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Note: Otherwise it is null.public android.os.Bundle saveInstanceState(android.os.Bundle savedInstanceState,
java.lang.String prefix)
savedInstanceState - If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Note: Otherwise it is null.prefix - a prefix added to the savedInstance key so we can store multiple statespublic java.util.Set<java.lang.Integer> getSelections()
public java.util.Set<Item> getSelectedItems()
public void toggleSelection(int position)
position - the global positionpublic void select(java.lang.Iterable<java.lang.Integer> positions)
positions - the global positions to selectpublic void select(int position)
position - the global positionpublic void select(int position,
boolean fireEvent)
position - the global positionfireEvent - true if the onClick listener should be calledpublic void deselect()
public void deselect(java.lang.Iterable<java.lang.Integer> positions)
positions - the global positions to deselectpublic void deselect(int position)
position - the global positionpublic java.util.List<Item> deleteAllSelectedItems()
public int[] getExpandedItems()
public void toggleExpandable(int position)
position - the global positionpublic void collapse()
public void collapse(int position)
position - the global positionpublic void expand(int position)
position - the global positionpublic void notifyAdapterDataSetChanged()
public void notifyAdapterItemInserted(int position)
position - the global positionpublic void notifyAdapterItemRangeInserted(int position,
int itemCount)
position - the global positionitemCount - the count of items insertedpublic void notifyAdapterItemRemoved(int position)
position - the global positionpublic void notifyAdapterItemRangeRemoved(int position,
int itemCount)
position - the global positionitemCount - the count of items removedpublic void notifyAdapterItemMoved(int fromPosition,
int toPosition)
fromPosition - the global fromPositiontoPosition - the global toPositionpublic void notifyAdapterItemChanged(int position)
position - the global positionpublic void notifyAdapterItemChanged(int position,
java.lang.Object payload)
position - the global positionpayload - additional payloadpublic void notifyAdapterItemRangeChanged(int position,
int itemCount)
position - the global positionitemCount - the count of items changedpublic void notifyAdapterItemRangeChanged(int position,
int itemCount,
java.lang.Object payload)
position - the global positionitemCount - the count of items changedpayload - an additional payload