# AsyncListUtil.DataCallback

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.DataCallback) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***


```
public abstract class AsyncListUtil.DataCallback<T>
```

<br />

*** ** * ** ***

The callback that provides data access for `https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil`.

All methods are called on the background thread.

## Summary

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

| ### Public methods |
|---|---|
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#fillData(T[],int,int)(@https://developer.android.com/reference/androidx/annotation/NonNull T[] data, int startPosition, int itemCount)` Fill the given tile. |
| `int` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#getMaxCachedTiles()()` Returns tile cache size limit (in tiles). |
| `void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#recycleData(T[],int)(@https://developer.android.com/reference/androidx/annotation/NonNull T[] data, int itemCount)` Recycle the objects created in `https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#fillData(T[],int,int)` if necessary. |
| `abstract int` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#refreshData()()` Refresh the data set and return the new data item count. |

## Public constructors

### DataCallback

Added in 1.0.0

```
public DataCallback()
```

## Public methods

### fillData

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

```
@WorkerThread
public abstract void fillData(@NonNull T[] data, int startPosition, int itemCount)
```

Fill the given tile.

The provided tile might be a recycled tile, in which case it will already have objects. It is suggested to re-use these objects if possible in your use case.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T[] data` | The data item array to fill into. Should not be accessed beyond `itemCount`. |
| `int startPosition` | The start position in the list. |
| `int itemCount` | The data item count. |

### getMaxCachedTiles

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

```
@WorkerThread
public int getMaxCachedTiles()
```

Returns tile cache size limit (in tiles).

The actual number of cached tiles will be the maximum of this value and the number of tiles that is required to cover the range returned by `https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#extendRangeInto(int[],int[],int)`.

For example, if this method returns 10, and the most recent call to `https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.ViewCallback#extendRangeInto(int[],int[],int)` returned {100, 179}, and the tile size is 5, then the maximum number of cached tiles will be 16.

However, if the tile size is 20, then the maximum number of cached tiles will be 10.

The default implementation returns 10.

| Returns |
|---|---|
| `int` | Maximum cache size. |

### recycleData

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

```
@WorkerThread
public void recycleData(@NonNull T[] data, int itemCount)
```

Recycle the objects created in `https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListUtil.DataCallback#fillData(T[],int,int)` if necessary.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T[] data` | Array of data items. Should not be accessed beyond `itemCount`. |
| `int itemCount` | The data item count. |

### refreshData

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

```
@WorkerThread
public abstract int refreshData()
```

Refresh the data set and return the new data item count.

If the data is being accessed through `https://developer.android.com/reference/android/database/Cursor.html` this is where the new cursor should be created.

| Returns |
|---|---|
| `int` | Data item count. |