public class SparseArrayObjectAdapter extends ObjectAdapter
ObjectAdapter
implemented with a SparseArray
.
This class maintains an array of objects where each object is associated
with an integer key which determines its order relative to other objects.ObjectAdapter.DataObserver
NO_ID
Constructor and Description |
---|
SparseArrayObjectAdapter()
Constructs an adapter.
|
SparseArrayObjectAdapter(Presenter presenter)
Constructs an adapter with the given
Presenter . |
SparseArrayObjectAdapter(PresenterSelector presenterSelector)
Constructs an adapter with the given
PresenterSelector . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all items from this adapter, leaving it empty.
|
void |
clear(int key)
Clears the given key and associated item from the adapter.
|
Object |
get(int position)
Returns the item for the given position.
|
int |
indexOf(int key)
Returns the index for the given key in the adapter.
|
int |
indexOf(Object item)
Returns the index for the given item in the adapter.
|
boolean |
isImmediateNotifySupported()
Returns true if the adapter pairs each underlying data change with a call to notify and
false otherwise.
|
Object |
lookup(int key)
Returns the object for the given key, or null if no mapping for that key exists.
|
void |
notifyArrayItemRangeChanged(int positionStart,
int itemCount)
Notify that the content of a range of items changed.
|
void |
set(int key,
Object item)
Sets the item for the given key.
|
int |
size()
Returns the number of items in the adapter.
|
getId, getPresenter, getPresenterSelector, hasStableIds, notifyChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, onHasStableIdsChanged, onPresenterSelectorChanged, registerObserver, setHasStableIds, setPresenterSelector, unregisterAllObservers, unregisterObserver
public SparseArrayObjectAdapter(PresenterSelector presenterSelector)
PresenterSelector
.public SparseArrayObjectAdapter(Presenter presenter)
Presenter
.public SparseArrayObjectAdapter()
public int size()
ObjectAdapter
size
in class ObjectAdapter
public Object get(int position)
ObjectAdapter
get
in class ObjectAdapter
public int indexOf(Object item)
item
- The item to find in the array.public int indexOf(int key)
key
- The key to find in the array.public void notifyArrayItemRangeChanged(int positionStart, int itemCount)
positionStart
- The position of first item that has changed.itemCount
- The count of how many items have changed.public void set(int key, Object item)
key
- The key associated with the item.item
- The item associated with the key.public void clear(int key)
key
- The key to be cleared.public void clear()
public Object lookup(int key)
public boolean isImmediateNotifySupported()
ObjectAdapter
isImmediateNotifySupported
in class ObjectAdapter