OkHttpDataSource.Factory
public final class OkHttpDataSource.Factory implements HttpDataSource.Factory
DataSource.Factory for OkHttpDataSource instances.
Summary
Public constructors |
|---|
Factory(Factory callFactory)Creates an instance. |
Public methods |
|
|---|---|
OkHttpDataSource |
Creates a |
OkHttpDataSource.Factory |
@CanIgnoreReturnValueSets the CacheControl that will be used. |
OkHttpDataSource.Factory |
@CanIgnoreReturnValueSets a content type |
final OkHttpDataSource.Factory |
@CanIgnoreReturnValueSets the default request headers for |
OkHttpDataSource.Factory |
@CanIgnoreReturnValueSets the |
OkHttpDataSource.Factory |
@CanIgnoreReturnValueSets the user agent that will be used. |
Inherited methods |
||
|---|---|---|
|
Public constructors
Factory
public Factory(Factory callFactory)
Creates an instance.
| Parameters | |
|---|---|
Factory callFactory |
A Call.Factory (typically an OkHttpClient) for use by the sources created by the factory. |
Public methods
createDataSource
@UnstableApi
public OkHttpDataSource createDataSource()
Creates a DataSource instance.
setCacheControl
@CanIgnoreReturnValue
@UnstableApi
public OkHttpDataSource.Factory setCacheControl(@Nullable CacheControl cacheControl)
Sets the CacheControl that will be used.
The default is null.
| Parameters | |
|---|---|
@Nullable CacheControl cacheControl |
The cache control that will be used. |
| Returns | |
|---|---|
OkHttpDataSource.Factory |
This factory. |
setContentTypePredicate
@CanIgnoreReturnValue
@UnstableApi
public OkHttpDataSource.Factory setContentTypePredicate(
@Nullable Predicate<String> contentTypePredicate
)
Sets a content type Predicate. If a content type is rejected by the predicate then a HttpDataSource.InvalidContentTypeException is thrown from open.
The default is null.
| Parameters | |
|---|---|
@Nullable Predicate<String> contentTypePredicate |
The content type |
| Returns | |
|---|---|
OkHttpDataSource.Factory |
This factory. |
setDefaultRequestProperties
@CanIgnoreReturnValue
@UnstableApi
public final OkHttpDataSource.Factory setDefaultRequestProperties(
Map<String, String> defaultRequestProperties
)
Sets the default request headers for HttpDataSource instances created by the factory.
The new request properties will be used for future requests made by HttpDataSources created by the factory, including instances that have already been created. Modifying the defaultRequestProperties map after a call to this method will have no effect, and so it's necessary to call this method again each time the request properties need to be updated.
| Returns | |
|---|---|
OkHttpDataSource.Factory |
This factory. |
setTransferListener
@CanIgnoreReturnValue
@UnstableApi
public OkHttpDataSource.Factory setTransferListener(@Nullable TransferListener transferListener)
Sets the TransferListener that will be used.
The default is null.
See addTransferListener.
| Parameters | |
|---|---|
@Nullable TransferListener transferListener |
The listener that will be used. |
| Returns | |
|---|---|
OkHttpDataSource.Factory |
This factory. |
setUserAgent
@CanIgnoreReturnValue
public OkHttpDataSource.Factory setUserAgent(@Nullable String userAgent)
Sets the user agent that will be used.
The default is null, which causes the default user agent of the underlying OkHttpClient to be used.
| Parameters | |
|---|---|
@Nullable String userAgent |
The user agent that will be used, or |
| Returns | |
|---|---|
OkHttpDataSource.Factory |
This factory. |