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
public class DefaultDataSourceFactory extends Object implements DataSourceFactory
The default implementation of theDataSourceFactory.- Since:
- 3.0.0
-
-
Constructor Summary
Constructors Constructor Description DefaultDataSourceFactory(Context context)DefaultDataSourceFactory(Context context, com.google.android.exoplayer2.upstream.TransferListener transferListener)DefaultDataSourceFactory(Context context, com.google.android.exoplayer2.upstream.TransferListener transferListener, HttpListener httpListener, PlayerController playerController)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeaderParameter(String key, String value)Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSourcecreated by this factory.voidaddQueryParameter(String key, String value)Adds a query parameter that will be appended to each HTTP URL.voidclearHeaderParameters()Removes all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String).voidclearQueryParameters()Removes all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)com.google.android.exoplayer2.upstream.DataSourcecreateDataSource()com.google.android.exoplayer2.upstream.DataSourcecreateDataSource(int requestType)Creates a data source for the given request typeMap<String,String>getHeaderParameter()Map<String,String>getQueryParameter()
-
-
-
Constructor Detail
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(@NonNull Context context)
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(@NonNull Context context, @Nullable com.google.android.exoplayer2.upstream.TransferListener transferListener)
-
DefaultDataSourceFactory
public DefaultDataSourceFactory(@NonNull Context context, @Nullable com.google.android.exoplayer2.upstream.TransferListener transferListener, @Nullable HttpListener httpListener, @Nullable PlayerController playerController)
-
-
Method Detail
-
createDataSource
@NonNull public com.google.android.exoplayer2.upstream.DataSource createDataSource()
- Specified by:
createDataSourcein interfacecom.google.android.exoplayer2.upstream.DataSource.Factory
-
createDataSource
public com.google.android.exoplayer2.upstream.DataSource createDataSource(int requestType)
Description copied from interface:DataSourceFactoryCreates a data source for the given request type- Specified by:
createDataSourcein interfaceDataSourceFactory- Parameters:
requestType- The request type- Returns:
- dataSource the data source
-
addHeaderParameter
public void addHeaderParameter(@NonNull String key, @Nullable String value)Description copied from interface:DataSourceFactoryAdds a header parameter that will be added to each HTTP connection header that is generated with aDataSourcecreated 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:
addHeaderParameterin 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:DataSourceFactoryRemoves all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String).- Specified by:
clearHeaderParametersin interfaceDataSourceFactory
-
addQueryParameter
public void addQueryParameter(@NonNull String key, @Nullable String value)Description copied from interface:DataSourceFactoryAdds 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:
addQueryParameterin 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:DataSourceFactoryRemoves all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)- Specified by:
clearQueryParametersin interfaceDataSourceFactory
-
getHeaderParameter
@NonNull public Map<String,String> getHeaderParameter()
- Specified by:
getHeaderParameterin interfaceDataSourceFactory- Returns:
- A non-null map of all registered header parameter
-
getQueryParameter
@NonNull public Map<String,String> getQueryParameter()
- Specified by:
getQueryParameterin interfaceDataSourceFactory- Returns:
- A non-null map of all registered query parameter
-
-