Search in sources :

Example 1 with Swappable

use of com.nhaarman.listviewanimations.util.Swappable in project ListViewAnimations by nhaarman.

the class DragAndDropHandler method setAdapterInternal.

/**
 * @throws java.lang.IllegalStateException    if the adapter does not have stable ids.
 * @throws java.lang.IllegalArgumentException if the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
 */
private void setAdapterInternal(@NonNull final ListAdapter adapter) {
    ListAdapter actualAdapter = adapter;
    if (actualAdapter instanceof WrapperListAdapter) {
        actualAdapter = ((WrapperListAdapter) actualAdapter).getWrappedAdapter();
    }
    if (!actualAdapter.hasStableIds()) {
        throw new IllegalStateException("Adapter doesn't have stable ids! Make sure your adapter has stable ids, and override hasStableIds() to return true.");
    }
    if (!(actualAdapter instanceof Swappable)) {
        throw new IllegalArgumentException("Adapter should implement Swappable!");
    }
    mAdapter = actualAdapter;
}
Also used : Swappable(com.nhaarman.listviewanimations.util.Swappable) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)1 WrapperListAdapter (android.widget.WrapperListAdapter)1 Swappable (com.nhaarman.listviewanimations.util.Swappable)1