ListSelectorAdapter

public abstract class ListSelectorAdapter extends RecyclerView.Adapter<ListSelectorAdapter.ViewHolder>

Fields

mCurrentSingleSelected

protected int mCurrentSingleSelected

mHideCheckBox

protected boolean mHideCheckBox

mOnItemClickListener

protected ListSelectorAdapter.ViewHolder.OnItemClickListener mOnItemClickListener

mOnItemLongClickListener

protected ListSelectorAdapter.ViewHolder.OnItemLongClickListener mOnItemLongClickListener

mOnSelectionChangedListeners

protected Queue<OnSelectionChangedListener> mOnSelectionChangedListeners

mSelectState

protected boolean mSelectState

mSelectedItems

protected SparseBooleanArray mSelectedItems

mSingleSelectable

protected boolean mSingleSelectable

Constructors

ListSelectorAdapter

public ListSelectorAdapter()

Methods

addOnSelectionChangedListener

public void addOnSelectionChangedListener(OnSelectionChangedListener listener)

clearSelectionForAll

public void clearSelectionForAll()

Clear the selection status for all items

deleteAllSelected

public void deleteAllSelected()

deleteSelected

protected void deleteSelected(int id)

getCurrentSingleSelectedItemId

public Integer getCurrentSingleSelectedItemId()

getItemViewResId

protected abstract int getItemViewResId()

getSelectedItemCount

public int getSelectedItemCount()

Count the selected items

Результат:Selected items count

getSelectedItemsIds

public List<Integer> getSelectedItemsIds()

Indicates the list of selected items

Результат:List of selected items ids

getViewHolder

protected abstract ListSelectorAdapter.ViewHolder getViewHolder(View itemView)

hasSelectedItems

public boolean hasSelectedItems()

isSelected

public boolean isSelected(int position)

Indicates if the item at position position is selected

Параметры:
  • position – Position of the item to check
Результат:

true if the item is selected, false otherwise

isSingleSelectable

public boolean isSingleSelectable()

onBindViewHolder

public void onBindViewHolder(ViewHolder holder, int position)

onCreateViewHolder

public final ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

onViewRecycled

public void onViewRecycled(ViewHolder holder)

removeOnSelectionChangedListener

public void removeOnSelectionChangedListener(OnSelectionChangedListener listener)

setOnItemClickListener

public void setOnItemClickListener(ListSelectorAdapter.ViewHolder.OnItemClickListener listener)

setOnItemLongClickListener

public void setOnItemLongClickListener(ListSelectorAdapter.ViewHolder.OnItemLongClickListener listener)

setSelection

public void setSelection(int position, boolean selection)

Set the selection status of the item at a given position to the given state

Параметры:
  • position – Position of the item to toggle the selection status for
  • selection – State for the item at position

setSelectionForAll

public void setSelectionForAll(boolean selection)

setSingleSelectable

public void setSingleSelectable(boolean singleSelectable)

toggleSelection

public void toggleSelection(int position)

Toggle the selection status of the item at a given position

Параметры:
  • position – Position of the item to toggle the selection status for

toggleSelectionForAll

public void toggleSelectionForAll()