public class OkHttpDataSource extends Object
HttpDataSource that delegates to Square's Call.Factory.| 构造器和说明 |
|---|
OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate) |
OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate,
<any> listener) |
OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate,
<any> listener,
CacheControl cacheControl) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected long |
bytesRead()
Returns the number of bytes that have been read since the most recent call to
open(DataSpec). |
protected long |
bytesRemaining()
Returns the number of bytes that are still to be read for the current
DataSpec. |
protected long |
bytesSkipped()
Returns the number of bytes that have been skipped since the most recent call to
open(DataSpec). |
void |
clearAllRequestProperties() |
void |
clearRequestProperty(String name) |
void |
close() |
Map<String,List<String>> |
getResponseHeaders() |
android.net.Uri |
getUri() |
long |
open(DataSpec dataSpec) |
int |
read(byte[] buffer,
int offset,
int readLength) |
void |
setRequestProperty(String name,
String value) |
public OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate)
callFactory - A Call.Factory (typically an okhttp3.OkHttpClient) for use
by the source.userAgent - The User-Agent string that should be used.contentTypePredicate - An optional Predicate. If a content type is rejected by the
predicate then a InvalidContentTypeException} is thrown from open(DataSpec).public OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate,
<any> listener)
callFactory - A Call.Factory (typically an okhttp3.OkHttpClient) for use
by the source.userAgent - The User-Agent string that should be used.contentTypePredicate - An optional Predicate. If a content type is rejected by the
predicate then a InvalidContentTypeException is thrown from
open(DataSpec).listener - An optional listener.public OkHttpDataSource(Call.Factory callFactory,
String userAgent,
<any> contentTypePredicate,
<any> listener,
CacheControl cacheControl)
callFactory - A Call.Factory (typically an okhttp3.OkHttpClient) for use
by the source.userAgent - The User-Agent string that should be used.contentTypePredicate - An optional Predicate. If a content type is rejected by the
predicate then a InvalidContentTypeException is thrown from
open(DataSpec).listener - An optional listener.cacheControl - An optional CacheControl for setting the Cache-Control header.public android.net.Uri getUri()
public void clearRequestProperty(String name)
public void clearAllRequestProperties()
public long open(DataSpec dataSpec)
throws HttpDataSourceException
HttpDataSourceExceptionpublic int read(byte[] buffer,
int offset,
int readLength)
throws HttpDataSourceException
HttpDataSourceExceptionpublic void close()
throws HttpDataSourceException
HttpDataSourceExceptionprotected final long bytesSkipped()
open(DataSpec).protected final long bytesRead()
open(DataSpec).protected final long bytesRemaining()
DataSpec.
If the total length of the data being read is known, then this length minus bytesRead()
is returned. If the total length is unknown, C#LENGTH_UNSET is returned.
C#LENGTH_UNSET.