TransferListener
@UnstableApi
public interface TransferListener
DataSourceContractTest.FakeTransferListener |
A |
DefaultBandwidthMeter |
Estimates bandwidth by listening to data transfers. |
ExperimentalBandwidthMeter |
An experimental |
A listener of data transfer events.
A transfer usually progresses through multiple steps:
- Initializing the underlying resource (e.g. opening a HTTP connection).
onTransferInitializingis called before the initialization starts. - Starting the transfer after successfully initializing the resource.
onTransferStartis called. Note that this only happens if the initialization was successful. - Transferring data.
onBytesTransferredis called frequently during the transfer to indicate progress. - Closing the transfer and the underlying resource.
onTransferEndis called. Note that eachonTransferStartwill have exactly one corresponding call toonTransferEnd.
Summary
Public methods |
|
|---|---|
abstract void |
onBytesTransferred(Called incrementally during a transfer. |
abstract void |
onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork)Called when a transfer ends. |
abstract void |
onTransferInitializing(Called when a transfer is being initialized. |
abstract void |
onTransferStart(DataSource source, DataSpec dataSpec, boolean isNetwork)Called when a transfer starts. |
Public methods
onBytesTransferred
abstract void onBytesTransferred(
DataSource source,
DataSpec dataSpec,
boolean isNetwork,
int bytesTransferred
)
Called incrementally during a transfer.
| Parameters | |
|---|---|
DataSource source |
The source performing the transfer. |
DataSpec dataSpec |
Describes the data being transferred. |
boolean isNetwork |
Whether the data is transferred through a network. |
int bytesTransferred |
The number of bytes transferred since the previous call to this method. |
onTransferEnd
abstract void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork)
Called when a transfer ends.
| Parameters | |
|---|---|
DataSource source |
The source performing the transfer. |
DataSpec dataSpec |
Describes the data being transferred. |
boolean isNetwork |
Whether the data is transferred through a network. |
onTransferInitializing
abstract void onTransferInitializing(
DataSource source,
DataSpec dataSpec,
boolean isNetwork
)
Called when a transfer is being initialized.
| Parameters | |
|---|---|
DataSource source |
The source performing the transfer. |
DataSpec dataSpec |
Describes the data for which the transfer is initialized. |
boolean isNetwork |
Whether the data is transferred through a network. |
onTransferStart
abstract void onTransferStart(DataSource source, DataSpec dataSpec, boolean isNetwork)
Called when a transfer starts.
| Parameters | |
|---|---|
DataSource source |
The source performing the transfer. |
DataSpec dataSpec |
Describes the data being transferred. |
boolean isNetwork |
Whether the data is transferred through a network. |