# ObjectAdapter.DataObserver

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

*** ** * ** ***


```
public abstract class ObjectAdapter.DataObserver
```

<br />

*** ** * ** ***

A DataObserver can be notified when an ObjectAdapter's underlying data changes. Separate methods provide notifications about different types of changes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#DataObserver()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onChanged()()` Called whenever the ObjectAdapter's data has changed in some manner outside of the set of changes covered by the other range-based change notification methods. |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemMoved(int,int)(int fromPosition, int toPosition)` Called when an item is moved from one position to another position |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeChanged(int,int)(int positionStart, int itemCount)` Called when a range of items in the ObjectAdapter has changed. |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeChanged(int,int,java.lang.Object)( int positionStart, int itemCount, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html payload )` Called when a range of items in the ObjectAdapter has changed. |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeInserted(int,int)(int positionStart, int itemCount)` Called when a range of items is inserted into the ObjectAdapter. |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeRemoved(int,int)(int positionStart, int itemCount)` Called when a range of items is removed from the ObjectAdapter. |

## Public constructors

### DataObserver

Added in 1.1.0

```
public DataObserver()
```

## Public methods

### onChanged

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

```
public void onChanged()
```

Called whenever the ObjectAdapter's data has changed in some manner outside of the set of changes covered by the other range-based change notification methods.

### onItemMoved

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

```
public void onItemMoved(int fromPosition, int toPosition)
```

Called when an item is moved from one position to another position

| Parameters |
|---|---|
| `int fromPosition` | Previous position of the item. |
| `int toPosition` | New position of the item. |

### onItemRangeChanged

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

```
public void onItemRangeChanged(int positionStart, int itemCount)
```

Called when a range of items in the ObjectAdapter has changed. The basic ordering and structure of the ObjectAdapter has not changed.

| Parameters |
|---|---|
| `int positionStart` | The position of the first item that changed. |
| `int itemCount` | The number of items changed. |

### onItemRangeChanged

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

```
public void onItemRangeChanged(
    int positionStart,
    int itemCount,
    @Nullable Object payload
)
```

Called when a range of items in the ObjectAdapter has changed. The basic ordering and structure of the ObjectAdapter has not changed.

| Parameters |
|---|---|
| `int positionStart` | The position of the first item that changed. |
| `int itemCount` | The number of items changed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html payload` | Optional parameter, use null to identify a "full" update. |

### onItemRangeInserted

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

```
public void onItemRangeInserted(int positionStart, int itemCount)
```

Called when a range of items is inserted into the ObjectAdapter.

| Parameters |
|---|---|
| `int positionStart` | The position of the first inserted item. |
| `int itemCount` | The number of items inserted. |

### onItemRangeRemoved

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

```
public void onItemRangeRemoved(int positionStart, int itemCount)
```

Called when a range of items is removed from the ObjectAdapter.

| Parameters |
|---|---|
| `int positionStart` | The position of the first removed item. |
| `int itemCount` | The number of items removed. |