# DiffUtil.DiffResult

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#)  

# DiffUtil.DiffResult

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static


class
DiffUtil.DiffResult
`  
`

extends Object


``


`

|---|---------------------------------------------|
| java.lang.Object                               ||
| ↳ | android.support.v7.util.DiffUtil.DiffResult |

<br />

*** ** * ** ***

This class holds the information about the result of a[calculateDiff(Callback, boolean)](https://developer.android.com/reference/android/support/v7/util/DiffUtil#calculateDiff(android.support.v7.util.DiffUtil.Callback, boolean))call.

You can consume the updates in a DiffResult via[dispatchUpdatesTo(ListUpdateCallback)](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.util.ListUpdateCallback))or directly stream the results into a[RecyclerView.Adapter](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter)via[dispatchUpdatesTo(RecyclerView.Adapter)](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.widget.RecyclerView.Adapter)).

## Summary

|                                                                                                                                                                          ### Public methods                                                                                                                                                                          ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[dispatchUpdatesTo](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.util.ListUpdateCallback))`(`[ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)` updateCallback) ` Dispatches update operations to the given Callback. |
| ` void` | ` `[dispatchUpdatesTo](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.widget.RecyclerView.Adapter))`(`[Adapter](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter)` adapter) ` Dispatches the update events to the given adapter.            |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### dispatchUpdatesTo

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void dispatchUpdatesTo (ListUpdateCallback updateCallback)
```

Dispatches update operations to the given Callback.

These updates are atomic such that the first update call affects every update call that comes after it (the same as RecyclerView).

<br />

|                                          Parameters                                           ||
|------------------|-----------------------------------------------------------------------------|
| `updateCallback` | `ListUpdateCallback`: The callback to receive the update operations. <br /> |

**See also:**

- [dispatchUpdatesTo(RecyclerView.Adapter)](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.widget.RecyclerView.Adapter))  

### dispatchUpdatesTo

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void dispatchUpdatesTo (Adapter adapter)
```

Dispatches the update events to the given adapter.

For example, if you have an[Adapter](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter)that is backed by a[List](https://developer.android.com/reference/java/util/List), you can swap the list with the new one then call this method to dispatch all updates to the RecyclerView.  

```
     List oldList = mAdapter.getData();
     DiffResult result = DiffUtil.calculateDiff(new MyCallback(oldList, newList));
     mAdapter.setData(newList);
     result.dispatchUpdatesTo(mAdapter);
 
```

Note that the RecyclerView requires you to dispatch adapter updates immediately when you change the data (you cannot defer`notify*`calls). The usage above adheres to this rule because updates are sent to the adapter right after the backing data is changed, before RecyclerView tries to read it.

On the other hand, if you have another[AdapterDataObserver](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.AdapterDataObserver)that tries to process events synchronously, this may confuse that observer because the list is instantly moved to its final state while the adapter updates are dispatched later on, one by one. If you have such an[AdapterDataObserver](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.AdapterDataObserver), you can use[dispatchUpdatesTo(ListUpdateCallback)](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult#dispatchUpdatesTo(android.support.v7.util.ListUpdateCallback))to handle each modification manually.

<br />

|                                                          Parameters                                                           ||
|-----------|--------------------------------------------------------------------------------------------------------------------|
| `adapter` | `Adapter`: A RecyclerView adapter which was displaying the old list and will start displaying the new list. <br /> |

**See also:**

- [AdapterListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/AdapterListUpdateCallback)  
-

  ## Interfaces

  - [ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)
-

  ## Classes

  - [AdapterListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/AdapterListUpdateCallback)
  - [AsyncListUtil](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil)
  - [AsyncListUtil.DataCallback](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil.DataCallback)
  - [AsyncListUtil.ViewCallback](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil.ViewCallback)
  - [BatchingListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback)
  - [DiffUtil](https://developer.android.com/reference/android/support/v7/util/DiffUtil)
  - [DiffUtil.Callback](https://developer.android.com/reference/android/support/v7/util/DiffUtil.Callback)
  - [DiffUtil.DiffResult](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult)
  - [DiffUtil.ItemCallback](https://developer.android.com/reference/android/support/v7/util/DiffUtil.ItemCallback)
  - [SortedList](https://developer.android.com/reference/android/support/v7/util/SortedList)
  - [SortedList.BatchedCallback](https://developer.android.com/reference/android/support/v7/util/SortedList.BatchedCallback)
  - [SortedList.Callback](https://developer.android.com/reference/android/support/v7/util/SortedList.Callback)