Package com.castlabs.android.network
Class DefaultDataSourceFactory
java.lang.Object
com.castlabs.android.network.DefaultDataSourceFactory
- All Implemented Interfaces:
DataSourceFactory
,com.google.android.exoplayer2.upstream.DataSource.Factory
The default implementation of the
DataSourceFactory
.- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultDataSourceFactory
(Context context) Creates a new instance ofDefaultDataSourceFactory
.DefaultDataSourceFactory
(Context context, com.google.android.exoplayer2.upstream.TransferListener transferListener) Creates a new instance ofDefaultDataSourceFactory
.DefaultDataSourceFactory
(Context context, com.google.android.exoplayer2.upstream.TransferListener transferListener, HttpListener httpListener, PlayerController playerController) Creates a new instance ofDefaultDataSourceFactory
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHeaderParameter
(String key, String value) Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSource
created by this factory.void
addQueryParameter
(String key, String value) Adds a query parameter that will be appended to each HTTP URL.void
Removes all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String)
.void
Removes all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)
com.google.android.exoplayer2.upstream.DataSource
com.google.android.exoplayer2.upstream.DataSource
createDataSource
(int requestType) Creates a data source for the given request typeReturns a non-null map of all registered header parameters.Returns a non-null map of all registered query parameters.
-
Constructor Details
-
DefaultDataSourceFactory
Creates a new instance ofDefaultDataSourceFactory
.- Parameters:
context
- The context.
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(@NonNull Context context, @Nullable com.google.android.exoplayer2.upstream.TransferListener transferListener) Creates a new instance ofDefaultDataSourceFactory
.- Parameters:
context
- The context.transferListener
- The transfer listener.
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(@NonNull Context context, @Nullable com.google.android.exoplayer2.upstream.TransferListener transferListener, @Nullable HttpListener httpListener, @Nullable PlayerController playerController) Creates a new instance ofDefaultDataSourceFactory
.- Parameters:
context
- The context.transferListener
- The transfer listener.httpListener
- The HTTP listener.playerController
- The player controller.
-
-
Method Details
-
createDataSource
@NonNull public com.google.android.exoplayer2.upstream.DataSource createDataSource()- Specified by:
createDataSource
in interfacecom.google.android.exoplayer2.upstream.DataSource.Factory
-
createDataSource
public com.google.android.exoplayer2.upstream.DataSource createDataSource(int requestType) Description copied from interface:DataSourceFactory
Creates a data source for the given request type- Specified by:
createDataSource
in interfaceDataSourceFactory
- Parameters:
requestType
- The request type- Returns:
- dataSource the data source
-
addHeaderParameter
Description copied from interface:DataSourceFactory
Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSource
created by this factory. Note that you will need to call this before a call toDataSource.Factory.createDataSource()
in order to successfully add the parameter.- Specified by:
addHeaderParameter
in interfaceDataSourceFactory
- Parameters:
key
- the keyvalue
- the value or null to remove any previously added endtry with the given key
-
clearHeaderParameters
public void clearHeaderParameters()Description copied from interface:DataSourceFactory
Removes all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String)
.- Specified by:
clearHeaderParameters
in interfaceDataSourceFactory
-
addQueryParameter
Description copied from interface:DataSourceFactory
Adds a query parameter that will be appended to each HTTP URL. Note that you will need to call this before a call toDataSource.Factory.createDataSource()
in order to successfully add the parameter.- Specified by:
addQueryParameter
in interfaceDataSourceFactory
- Parameters:
key
- the keyvalue
- the value or null to remove any previously added entry with the given key
-
clearQueryParameters
public void clearQueryParameters()Description copied from interface:DataSourceFactory
Removes all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)
- Specified by:
clearQueryParameters
in interfaceDataSourceFactory
-
getHeaderParameter
Description copied from interface:DataSourceFactory
Returns a non-null map of all registered header parameters.- Specified by:
getHeaderParameter
in interfaceDataSourceFactory
- Returns:
- A non-null map of all registered header parameter
-
getQueryParameter
Description copied from interface:DataSourceFactory
Returns a non-null map of all registered query parameters.- Specified by:
getQueryParameter
in interfaceDataSourceFactory
- Returns:
- A non-null map of all registered query parameter
-