# PagedList.BoundaryCallback

Summary:[Ctors](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#pubctors)\|[Methods](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#inhmethods)  

# PagedList.BoundaryCallback

| The`android.arch`Architecture Components packages are no longer maintained. They have been superseded by the corresponding[androidx.\*](https://developer.android.com/jetpack/androidx/migrate)packages. See[androidx.paging.PagedList.BoundaryCallback](https://developer.android.com/reference/androidx/paging/PagedList.BoundaryCallback)instead.

`
public
static

abstract
class
PagedList.BoundaryCallback
`  
`

extends Object


``


`

|---|-----------------------------------------------------|
| java.lang.Object                                       ||
| ↳ | android.arch.paging.PagedList.BoundaryCallback\<T\> |

<br />

*** ** * ** ***

Signals when a PagedList has reached the end of available data.

When local storage is a cache of network data, it's common to set up a streaming pipeline: Network data is paged into the database, database is paged into UI. Paging from the database to UI can be done with a`LiveData<PagedList>`, but it's still necessary to know when to trigger network loads.

BoundaryCallback does this signaling - when a DataSource runs out of data at the end of the list,[onItemAtEndLoaded(Object)](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#onItemAtEndLoaded(T))is called, and you can start an async network load that will write the result directly to the database. Because the database is being observed, the UI bound to the`LiveData<PagedList>`will update automatically to account for the new items.

Note that a BoundaryCallback instance shared across multiple PagedLists (e.g. when passed to[setBoundaryCallback(PagedList.BoundaryCallback)](https://developer.android.com/reference/android/arch/paging/LivePagedListBuilder#setBoundaryCallback(android.arch.paging.PagedList.BoundaryCallback<Value>))), the callbacks may be issued multiple times. If for example[onItemAtEndLoaded(Object)](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#onItemAtEndLoaded(T))triggers a network load, it should avoid triggering it again while the load is ongoing.

BoundaryCallback only passes the item at front or end of the list. Number of items is not passed, since it may not be fully computed by the DataSource if placeholders are not supplied. Keys are not known because the BoundaryCallback is independent of the DataSource-specific keys, which may be different for local vs remote storage.

The database + network Repository in the[PagingWithNetworkSample](https://github.com/googlesamples/android-architecture-components/blob/master/PagingWithNetworkSample/README.md)shows how to implement a network BoundaryCallback using[Retrofit](https://square.github.io/retrofit/), while handling swipe-to-refresh, network errors, and retry.

## Summary

|                                                                   ### Public constructors                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[PagedList.BoundaryCallback](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#PagedList.BoundaryCallback())`() ` |

|                                                                                                                                                                                      ### Public methods                                                                                                                                                                                      ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onItemAtEndLoaded](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#onItemAtEndLoaded(T))`(T itemAtEnd) ` Called when the item at the end of the PagedList has been loaded, and access has occurred within[prefetchDistance](https://developer.android.com/reference/android/arch/paging/PagedList.Config#prefetchDistance)of it.         |
| ` void` | ` `[onItemAtFrontLoaded](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#onItemAtFrontLoaded(T))`(T itemAtFront) ` Called when the item at the front of the PagedList has been loaded, and access has occurred within[prefetchDistance](https://developer.android.com/reference/android/arch/paging/PagedList.Config#prefetchDistance)of it. |
| ` void` | ` `[onZeroItemsLoaded](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback#onZeroItemsLoaded())`() ` Called when zero items are returned from an initial load of the PagedList's data source.                                                                                                                                                    |

| ### Inherited methods |
|-----------------------|---|
| 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 constructors

### PagedList.BoundaryCallback

```
PagedList.BoundaryCallback ()
```

<br />

<br />

## Public methods

### onItemAtEndLoaded

```
void onItemAtEndLoaded (T itemAtEnd)
```

Called when the item at the end of the PagedList has been loaded, and access has occurred within[prefetchDistance](https://developer.android.com/reference/android/arch/paging/PagedList.Config#prefetchDistance)of it.

No more data will be appended to the PagedList after this item.

<br />

|                      Parameters                      ||
|-------------|-----------------------------------------|
| `itemAtEnd` | `T`: The first item of PagedList <br /> |

### onItemAtFrontLoaded

```
void onItemAtFrontLoaded (T itemAtFront)
```

Called when the item at the front of the PagedList has been loaded, and access has occurred within[prefetchDistance](https://developer.android.com/reference/android/arch/paging/PagedList.Config#prefetchDistance)of it.

No more data will be prepended to the PagedList before this item.

<br />

|                       Parameters                       ||
|---------------|-----------------------------------------|
| `itemAtFront` | `T`: The first item of PagedList <br /> |

### onZeroItemsLoaded

```
void onZeroItemsLoaded ()
```

Called when zero items are returned from an initial load of the PagedList's data source.

<br />

-

  ## Interfaces

  - [DataSource.InvalidatedCallback](https://developer.android.com/reference/android/arch/paging/DataSource.InvalidatedCallback)
-

  ## Classes

  - [AsyncPagedListDiffer](https://developer.android.com/reference/android/arch/paging/AsyncPagedListDiffer)
  - [DataSource](https://developer.android.com/reference/android/arch/paging/DataSource)
  - [DataSource.Factory](https://developer.android.com/reference/android/arch/paging/DataSource.Factory)
  - [ItemKeyedDataSource](https://developer.android.com/reference/android/arch/paging/ItemKeyedDataSource)
  - [ItemKeyedDataSource.LoadCallback](https://developer.android.com/reference/android/arch/paging/ItemKeyedDataSource.LoadCallback)
  - [ItemKeyedDataSource.LoadInitialCallback](https://developer.android.com/reference/android/arch/paging/ItemKeyedDataSource.LoadInitialCallback)
  - [ItemKeyedDataSource.LoadInitialParams](https://developer.android.com/reference/android/arch/paging/ItemKeyedDataSource.LoadInitialParams)
  - [ItemKeyedDataSource.LoadParams](https://developer.android.com/reference/android/arch/paging/ItemKeyedDataSource.LoadParams)
  - [LivePagedListBuilder](https://developer.android.com/reference/android/arch/paging/LivePagedListBuilder)
  - [PagedList](https://developer.android.com/reference/android/arch/paging/PagedList)
  - [PagedList.BoundaryCallback](https://developer.android.com/reference/android/arch/paging/PagedList.BoundaryCallback)
  - [PagedList.Builder](https://developer.android.com/reference/android/arch/paging/PagedList.Builder)
  - [PagedList.Callback](https://developer.android.com/reference/android/arch/paging/PagedList.Callback)
  - [PagedList.Config](https://developer.android.com/reference/android/arch/paging/PagedList.Config)
  - [PagedList.Config.Builder](https://developer.android.com/reference/android/arch/paging/PagedList.Config.Builder)
  - [PagedListAdapter](https://developer.android.com/reference/android/arch/paging/PagedListAdapter)
  - [PageKeyedDataSource](https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource)
  - [PageKeyedDataSource.LoadCallback](https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource.LoadCallback)
  - [PageKeyedDataSource.LoadInitialCallback](https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource.LoadInitialCallback)
  - [PageKeyedDataSource.LoadInitialParams](https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource.LoadInitialParams)
  - [PageKeyedDataSource.LoadParams](https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource.LoadParams)
  - [PositionalDataSource](https://developer.android.com/reference/android/arch/paging/PositionalDataSource)
  - [PositionalDataSource.LoadInitialCallback](https://developer.android.com/reference/android/arch/paging/PositionalDataSource.LoadInitialCallback)
  - [PositionalDataSource.LoadInitialParams](https://developer.android.com/reference/android/arch/paging/PositionalDataSource.LoadInitialParams)
  - [PositionalDataSource.LoadRangeCallback](https://developer.android.com/reference/android/arch/paging/PositionalDataSource.LoadRangeCallback)
  - [PositionalDataSource.LoadRangeParams](https://developer.android.com/reference/android/arch/paging/PositionalDataSource.LoadRangeParams)
  - [RxPagedListBuilder](https://developer.android.com/reference/android/arch/paging/RxPagedListBuilder)