Methods Summary |
---|
public void | add(java.lang.Object item)Adds an item to the end of the adapter.
add(mItems.size(), item);
|
public void | add(int index, java.lang.Object item)Inserts an item into this adapter at the specified index.
If the index is >= {@link #size} an exception will be thrown.
mItems.add(index, item);
notifyItemRangeInserted(index, 1);
|
public void | addAll(int index, java.util.Collection items)Adds the objects in the given collection to the adapter, starting at the
given index. If the index is >= {@link #size} an exception will be thrown.
int itemsCount = items.size();
if (itemsCount == 0) {
return;
}
mItems.addAll(index, items);
notifyItemRangeInserted(index, itemsCount);
|
public void | clear()Removes all items from this adapter, leaving it empty.
int itemCount = mItems.size();
if (itemCount == 0) {
return;
}
mItems.clear();
notifyItemRangeRemoved(0, itemCount);
|
public java.lang.Object | get(int index)
return mItems.get(index);
|
public int | indexOf(java.lang.Object item)Returns the index for the first occurrence of item in the adapter, or -1 if
not found.
return mItems.indexOf(item);
|
public void | notifyArrayItemRangeChanged(int positionStart, int itemCount)Notify that the content of a range of items changed. Note that this is
not same as items being added or removed.
notifyItemRangeChanged(positionStart, itemCount);
|
public boolean | remove(java.lang.Object item)Removes the first occurrence of the given item from the adapter.
int index = mItems.indexOf(item);
if (index >= 0) {
mItems.remove(index);
notifyItemRangeRemoved(index, 1);
}
return index >= 0;
|
public int | removeItems(int position, int count)Removes a range of items from the adapter. The range is specified by giving
the starting position and the number of elements to remove.
int itemsToRemove = Math.min(count, mItems.size() - position);
if (itemsToRemove <= 0) {
return 0;
}
for (int i = 0; i < itemsToRemove; i++) {
mItems.remove(position);
}
notifyItemRangeRemoved(position, itemsToRemove);
return itemsToRemove;
|
public void | replace(int position, java.lang.Object item)Replaces item at position with a new item and calls notifyItemRangeChanged()
at the given position. Note that this method does not compare new item to
existing item.
mItems.set(position, item);
notifyItemRangeChanged(position, 1);
|
public int | size()
return mItems.size();
|