Package com.google.android.exoplayer2.upstream

## Interface TransferListener

- All Known Implementing Classes:
    `DataSourceContractTest.FakeTransferListener`, `DefaultBandwidthMeter`

      public interface TransferListener

  A listener of data transfer events.

  A transfer usually progresses through multiple steps:

  1. Initializing the underlying resource (e.g. opening a HTTP connection). `onTransferInitializing(DataSource, DataSpec, boolean)` is called before the initialization starts.
  2. Starting the transfer after successfully initializing the resource. `onTransferStart(DataSource, DataSpec, boolean)` is called. Note that this only happens if the initialization was successful.
  3. Transferring data. `onBytesTransferred(DataSource, DataSpec, boolean, int)` is called frequently during the transfer to indicate progress.
  4. Closing the transfer and the underlying resource. `onTransferEnd(DataSource, DataSpec, boolean)` is called. Note that each `onTransferStart(DataSource, DataSpec, boolean)` will have exactly one corresponding call to `onTransferEnd(DataSource, DataSpec, boolean)`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onBytesTransferred​(DataSource source, DataSpec dataSpec, boolean isNetwork, int bytesTransferred)` | Called incrementally during a transfer.
    `void` | `onTransferEnd​(DataSource source, DataSpec dataSpec, boolean isNetwork)` | Called when a transfer ends.
    `void` | `onTransferInitializing​(DataSource source, DataSpec dataSpec, boolean isNetwork)` | Called when a transfer is being initialized.
    `void` | `onTransferStart​(DataSource source, DataSpec dataSpec, boolean isNetwork)` | Called when a transfer starts.

- - ### Method Detail

    - #### onTransferInitializing

          void onTransferInitializing​(DataSource source,
                                      DataSpec dataSpec,
                                      boolean isNetwork)

      Called when a transfer is being initialized.
      Parameters:
        `source` - The source performing the transfer.
        `dataSpec` - Describes the data for which the transfer is initialized.
        `isNetwork` - Whether the data is transferred through a network.

    - #### onTransferStart

          void onTransferStart​(DataSource source,
                               DataSpec dataSpec,
                               boolean isNetwork)

      Called when a transfer starts.
      Parameters:
        `source` - The source performing the transfer.
        `dataSpec` - Describes the data being transferred.
        `isNetwork` - Whether the data is transferred through a network.

    - #### onBytesTransferred

          void onBytesTransferred​(DataSource source,
                                  DataSpec dataSpec,
                                  boolean isNetwork,
                                  int bytesTransferred)

      Called incrementally during a transfer.
      Parameters:
        `source` - The source performing the transfer.
        `dataSpec` - Describes the data being transferred.
        `isNetwork` - Whether the data is transferred through a network.
        `bytesTransferred` - The number of bytes transferred since the previous call to this method

    - #### onTransferEnd

          void onTransferEnd​(DataSource source,
                             DataSpec dataSpec,
                             boolean isNetwork)

      Called when a transfer ends.
      Parameters:
        `source` - The source performing the transfer.
        `dataSpec` - Describes the data being transferred.
        `isNetwork` - Whether the data is transferred through a network.