# AsyncListUtil.ViewCallback

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

*** ** * ** ***

<br />

```
abstract class AsyncListUtil.ViewCallback
```

<br />

*** ** * ** ***

The callback that links `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil` with the list view.

All methods are called on the main thread.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#HINT_SCROLL_ASC() = 2` Scrolling in ascending order (from lower to higher positions in the order of the backing storage). |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#HINT_SCROLL_DESC() = 1` Scrolling in descending order (from higher to lower positions in the order of the backing storage). |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#HINT_SCROLL_NONE() = 0` No scroll direction hint available. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#ViewCallback()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#extendRangeInto(int[],int[],int)( range: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, outRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, scrollHint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Compute a wider range of items that will be loaded for smoother scrolling. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#getItemRangeInto(int[])(outRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>)` Compute the range of visible item positions. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#onDataRefresh()()` Called when the entire data set has changed. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#onItemLoaded(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called when an item at the given position is loaded. |

## Constants

### HINT_SCROLL_ASC

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

```
const val HINT_SCROLL_ASC = 2: Int
```

Scrolling in ascending order (from lower to higher positions in the order of the backing storage).

### HINT_SCROLL_DESC

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

```
const val HINT_SCROLL_DESC = 1: Int
```

Scrolling in descending order (from higher to lower positions in the order of the backing storage).

### HINT_SCROLL_NONE

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

```
const val HINT_SCROLL_NONE = 0: Int
```

No scroll direction hint available.

## Public constructors

### ViewCallback

Added in 1.0.0

```
ViewCallback()
```

## Public functions

### extendRangeInto

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

```
@UiThread
fun extendRangeInto(
    range: IntArray<Int>,
    outRange: IntArray<Int>,
    scrollHint: Int
): Unit
```

Compute a wider range of items that will be loaded for smoother scrolling.

If there is no scroll hint, the default implementation extends the visible range by half its length in both directions. If there is a scroll hint, the range is extended by its full length in the scroll direction, and by half in the other direction.

For example, if `range` is `{100, 200}` and `scrollHint` is `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#HINT_SCROLL_ASC()`, then `outRange` will be `{50, 300}`.

However, if `scrollHint` is `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#HINT_SCROLL_NONE()`, then `outRange` will be `{50, 250}`

| Parameters |
|---|---|
| `range: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | Visible item range. |
| `outRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | Extended range. |
| `scrollHint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The scroll direction hint. |

### getItemRangeInto

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

```
@UiThread
abstract fun getItemRangeInto(outRange: IntArray<Int>): Unit
```

Compute the range of visible item positions.

outRange\[0\] is the position of the first visible item (in the order of the backing storage).

outRange\[1\] is the position of the last visible item (in the order of the backing storage).

Negative positions and positions greater or equal to `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/AsyncListUtil#getItemCount()` are invalid. If the returned range contains invalid positions it is ignored (no item will be loaded).

| Parameters |
|---|---|
| `outRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | The visible item range. |

### onDataRefresh

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

```
@UiThread
abstract fun onDataRefresh(): Unit
```

Called when the entire data set has changed.

### onItemLoaded

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

```
@UiThread
abstract fun onItemLoaded(position: Int): Unit
```

Called when an item at the given position is loaded.

| Parameters |
|---|---|
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Item position. |