# ObjectAdapter.DataObserver

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/leanback/widget/ObjectAdapter.DataObserver "View this page in Java")

<br />

```
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                                                        |
|---------------------------------------------------------------------------------------------------------------------------------------|
| [DataObserver](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#DataObserver())`()` |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onChanged](https://developer.android.com/reference/kotlin/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.                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onItemMoved](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemMoved(int,int))`(fromPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, toPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when an item is moved from one position to another position                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeChanged(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when a range of items in the ObjectAdapter has changed.                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeChanged(int,int,java.lang.Object))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, payload: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)` Called when a range of items in the ObjectAdapter has changed. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onItemRangeInserted](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeInserted(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when a range of items is inserted into the ObjectAdapter.                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onItemRangeRemoved](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver#onItemRangeRemoved(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when a range of items is removed from the ObjectAdapter.                                                                                                          |

## Public constructors

### DataObserver

Added in 1.1.0  

```
DataObserver()
```  

## Public functions

### onChanged

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

```
fun onChanged(): Unit
```

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)  

```
fun onItemMoved(fromPosition: Int, toPosition: Int): Unit
```

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

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|--------------------------------|
| `fromPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Previous position of the item. |
| `toPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | New position of the item.      |

### onItemRangeChanged

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

```
fun onItemRangeChanged(positionStart: Int, itemCount: Int): Unit
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|----------------------------------------------|
| `positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the first item that changed. |
| `itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The number of items changed.                 |

### onItemRangeChanged

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

```
fun onItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?): Unit
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the first item that changed.              |
| `itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The number of items changed.                              |
| `payload: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?`    | 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)  

```
fun onItemRangeInserted(positionStart: Int, itemCount: Int): Unit
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|------------------------------------------|
| `positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the first inserted item. |
| `itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The number of items inserted.            |

### onItemRangeRemoved

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

```
fun onItemRangeRemoved(positionStart: Int, itemCount: Int): Unit
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-----------------------------------------|
| `positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the first removed item. |
| `itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The number of items removed.            |