DataLoaderpublic class DataLoader extends StreamLoader This class is a concrete implementation of StreamLoader that uses the
content supplied as a URL as the source for the stream. The mimetype
optionally provided in the URL is extracted and inserted into the HTTP
response headers. |
Fields Summary |
---|
private String | mContentType |
Constructors Summary |
---|
DataLoader(String dataUrl, LoadListener loadListener)Constructor uses the dataURL as the source for an InputStream
super(loadListener);
String url = dataUrl.substring("data:".length());
String content;
int commaIndex = url.indexOf(',");
if (commaIndex != -1) {
mContentType = url.substring(0, commaIndex);
content = url.substring(commaIndex + 1);
} else {
content = url;
}
mDataStream = new ByteArrayInputStream(content.getBytes());
mContentLength = content.length();
|
Methods Summary |
---|
protected void | buildHeaders(android.net.http.Headers headers)
if (mContentType != null) {
headers.setContentType(mContentType);
}
| public static void | requestUrl(java.lang.String url, LoadListener loadListener)Construct a DataLoader and instruct it to start loading.
DataLoader loader = new DataLoader(url, loadListener);
loader.load();
| protected boolean | setupStreamAndSendStatus()
mHandler.status(1, 1, 0, "OK");
return true;
|
|