# ListAdapter

Artifact: [androidx.recyclerview:recyclerview](https://developer.android.com/jetpack/androidx/releases/recyclerview) [View Source](https://cs.android.com/search?q=file:androidx/recyclerview/widget/ListAdapter.java+class:androidx.recyclerview.widget.ListAdapter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***


```
abstract class ListAdapter<T, VH : RecyclerView.ViewHolder?> : RecyclerView.Adapter<VH!>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter)\<VH!\> ||
|   | ↳ | [androidx.recyclerview.widget.ListAdapter](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter) |

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter` base class for presenting List data in a `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView`, including computing diffs between Lists on a background thread.

This class is a convenience wrapper around `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListDiffer` that implements Adapter common default behavior for item access and counting.

While using a LiveData is an easy way to provide data to the adapter, it isn't required - you can use `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>)` when new lists are available.

A complete usage pattern with Room would look like this:

```kotlin
@Dao
interface UserDao {
    @Query("SELECT * FROM user ORDER BY lastName ASC")
    public abstract LiveData<List<User>> usersByLastName();
}

class MyViewModel extends ViewModel {
    public final LiveData<List<User>> usersList;
    public MyViewModel(UserDao userDao) {
        usersList = userDao.usersByLastName();
    }
}

class MyActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        MyViewModel viewModel = new ViewModelProvider(this).get(MyViewModel.class);
        RecyclerView recyclerView = findViewById(R.id.user_list);
        UserAdapter<User> adapter = new UserAdapter();
        viewModel.usersList.observe(this, list -> adapter.submitList(list));
        recyclerView.setAdapter(adapter);
    }
}

class UserAdapter extends ListAdapter<User, UserViewHolder> {
    public UserAdapter() {
        super(User.DIFF_CALLBACK);
    }
    @Override
    public void onBindViewHolder(UserViewHolder holder, int position) {
        holder.bindTo(getItem(position));
    }
    public static final DiffUtil.ItemCallback<User> DIFF_CALLBACK =
            new DiffUtil.ItemCallback<User>() {
        @Override
        public boolean areItemsTheSame(
                @NonNull User oldUser, @NonNull User newUser) {
            // User properties may have changed if reloaded from the DB, but ID is fixed
            return oldUser.getId() == newUser.getId();
        }
        @Override
        public boolean areContentsTheSame(
                @NonNull User oldUser, @NonNull User newUser) {
            // NOTE: if you use equals, your object must properly override Object#equals()
            // Incorrectly returning false here will result in too many animations.
            return oldUser.equals(newUser);
        }
    }
}
```
Advanced users that wish for more control over adapter behavior, or to provide a specific base class should refer to `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListDiffer`, which provides custom mapping from diff events to adapter positions.

| Parameters |
|---|---|
| `<T>` | Type of the Lists this Adapter will receive. |
| `<VH : https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder?>` | A class that extends ViewHolder that will be used by the adapter. |

## Summary

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#ListAdapter(androidx.recyclerview.widget.AsyncDifferConfig<T>)(config: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncDifferConfig<T!>)` |
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#ListAdapter(androidx.recyclerview.widget.DiffUtil.ItemCallback<T>)(diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T!>)` |

| ### Public functions |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#getCurrentList()()` Get the current List - any diffing to present this list has already been computed and dispatched via the ListUpdateCallback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#getItemCount()()` Returns the total number of items in the data set held by the adapter. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#onCurrentListChanged(java.util.List<T>,java.util.List<T>)( previousList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>, currentList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!> )` Called when the current List is updated. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>)(list: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>?)` Submits a new list to be diffed, and displayed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>,java.lang.Runnable)(list: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>?, commitCallback: https://developer.android.com/reference/java/lang/Runnable.html?)` Set the new list to be displayed. |

| ### Protected functions |
|---|---|
| `T!` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#getItem(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

### Inherited functions

From [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#bindViewHolder(VH,int)(holder: VH, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

This method internally calls `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int)` to update the `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder` contents with the item at the given position and also sets up some private fields to be used by RecyclerView.
`VH` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#createViewHolder(android.view.ViewGroup,int)(parent: https://developer.android.com/reference/android/view/ViewGroup.html, viewType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

This method calls `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onCreateViewHolder(android.view.ViewGroup,int)` to create a new `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder` and initializes some private fields to be used by RecyclerView.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#findRelativeAdapterPositionIn(androidx.recyclerview.widget.RecyclerView.Adapter<? extends androidx.recyclerview.widget.RecyclerView.ViewHolder>,androidx.recyclerview.widget.RecyclerView.ViewHolder,int)(
adapter: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter<https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder!>,
viewHolder: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder,
localPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html
)`

Returns the position of the given `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder` in the given `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getItemId(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Return the stable ID for the item at `position`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getItemViewType(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Return the view type of the item at `position` for the purposes of view recycling.
`https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getStateRestorationPolicy()()`

Returns when this Adapter wants to restore the state.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#hasObservers()()`

Returns true if one or more observers are attached to this adapter.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#hasStableIds()()`

Returns true if this adapter publishes a unique `long` value that can act as a key for the item at a given position in the data set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged()()`

Notify any registered observers that the data set has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the item at `position` has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int,java.lang.Object)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

Notify any registered observers that the item at `position` has changed with an optional payload object.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemInserted(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the item reflected at `position` has been newly inserted.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemMoved(int,int)(fromPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, toPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the item reflected at `fromPosition` has been moved to `toPosition`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the `itemCount` items starting at position `positionStart` have changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int,java.lang.Object)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

Notify any registered observers that the `itemCount` items starting at position `positionStart` have changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeInserted(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the currently reflected `itemCount` items starting at `positionStart` have been newly inserted.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeRemoved(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the `itemCount` items previously located at `positionStart` have been removed from the data set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRemoved(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notify any registered observers that the item previously located at `position` has been removed from the data set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onAttachedToRecyclerView(androidx.recyclerview.widget.RecyclerView)(recyclerView: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`

Called by RecyclerView when it starts observing this Adapter.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int)(holder: VH, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Called by RecyclerView to display the data at the specified position.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int,java.util.List<java.lang.Object>)(holder: VH, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payloads: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!>)`

Called by RecyclerView to display the data at the specified position.
`abstract VH` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onCreateViewHolder(android.view.ViewGroup,int)(parent: https://developer.android.com/reference/android/view/ViewGroup.html, viewType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Called when RecyclerView needs a new `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder` of the given type to represent an item.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onDetachedFromRecyclerView(androidx.recyclerview.widget.RecyclerView)(recyclerView: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`

Called by RecyclerView when it stops observing this Adapter.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onFailedToRecycleView(VH)(holder: VH)`

Called by the RecyclerView if a ViewHolder created by this Adapter cannot be recycled due to its transient state.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewAttachedToWindow(VH)(holder: VH)`

Called when a view created by this adapter has been attached to a window.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewDetachedFromWindow(VH)(holder: VH)`

Called when a view created by this adapter has been detached from its window.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewRecycled(VH)(holder: VH)`

Called when a view created by this adapter has been recycled.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver)(observer: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver)`

Register a new observer to listen for data changes.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#setHasStableIds(boolean)(hasStableIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Indicates whether each item in the data set can be represented with a unique identifier of type `https://developer.android.com/reference/java/lang/Long.html`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)(
strategy: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy
)`

Sets the state restoration strategy for the Adapter.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver)(
observer: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver
)`

Unregister an observer currently listening for data changes.

## Protected constructors

### ListAdapter

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

```
protected ListAdapter(config: AsyncDifferConfig<T!>)
```

### ListAdapter

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

```
protected ListAdapter(diffCallback: DiffUtil.ItemCallback<T!>)
```

## Public functions

### getCurrentList

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.1.0)

```
fun getCurrentList(): (Mutable)List<T!>
```

Get the current List - any diffing to present this list has already been computed and dispatched via the ListUpdateCallback.

If a `null` List, or no List has been submitted, an empty list will be returned.

The returned list may not be mutated - mutations to content must be done through `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>)`.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>` | The list currently being displayed. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#onCurrentListChanged(java.util.List<T>,java.util.List<T>)` |   |

### getItemCount

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.4.0)

```
fun getItemCount(): Int
```

Returns the total number of items in the data set held by the adapter.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The total number of items in this adapter. |

### onCurrentListChanged

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.1.0)

```
fun onCurrentListChanged(
    previousList: (Mutable)List<T!>,
    currentList: (Mutable)List<T!>
): Unit
```

Called when the current List is updated.

If a `null` List is passed to `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>)`, or no List has been submitted, the current List is represented as an empty List.

| Parameters |
|---|---|
| `previousList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>` | List that was displayed previously. |
| `currentList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>` | new List being displayed, will be empty if `null` was passed to `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List<T>)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListAdapter#getCurrentList()` |   |

### submitList

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

```
fun submitList(list: (Mutable)List<T!>?): Unit
```

Submits a new list to be diffed, and displayed.

If a list is already being displayed, a diff will be computed on a background thread, which will dispatch Adapter.notifyItem events on the main thread.

| Parameters |
|---|---|
| `list: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>?` | The new list to be displayed. |

### submitList

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.1.0)

```
fun submitList(list: (Mutable)List<T!>?, commitCallback: Runnable?): Unit
```

Set the new list to be displayed.

If a List is already being displayed, a diff will be computed on a background thread, which will dispatch Adapter.notifyItem events on the main thread.

The commit callback can be used to know when the List is committed, but note that it may not be executed. If List B is submitted immediately after List A, and is committed directly, the callback associated with List A will not be run.

| Parameters |
|---|---|
| `list: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T!>?` | The new list to be displayed. |
| `commitCallback: https://developer.android.com/reference/java/lang/Runnable.html?` | Optional runnable that is executed when the List is committed, if it is committed. |

## Protected functions

### getItem

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

```
protected fun getItem(position: Int): T!
```