Remove unused class
This commit is contained in:
parent
4165d848d8
commit
6c82db1675
@ -1,80 +0,0 @@
|
|||||||
package de.danoeh.antennapod.core.glide;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Priority;
|
|
||||||
import com.bumptech.glide.load.data.DataFetcher;
|
|
||||||
import com.bumptech.glide.load.model.GlideUrl;
|
|
||||||
import com.bumptech.glide.util.ContentLengthInputStream;
|
|
||||||
import com.squareup.okhttp.OkHttpClient;
|
|
||||||
import com.squareup.okhttp.Request;
|
|
||||||
import com.squareup.okhttp.Response;
|
|
||||||
import com.squareup.okhttp.ResponseBody;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher
|
|
||||||
*/
|
|
||||||
public class ApOkHttpStreamFetcher implements DataFetcher<InputStream> {
|
|
||||||
private final OkHttpClient client;
|
|
||||||
private final GlideUrl url;
|
|
||||||
private InputStream stream;
|
|
||||||
private ResponseBody responseBody;
|
|
||||||
|
|
||||||
public ApOkHttpStreamFetcher(OkHttpClient client, GlideUrl url) {
|
|
||||||
this.client = client;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream loadData(Priority priority) throws Exception {
|
|
||||||
Request.Builder requestBuilder = new Request.Builder()
|
|
||||||
.url(url.toStringUrl());
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
|
|
||||||
String key = headerEntry.getKey();
|
|
||||||
requestBuilder.addHeader(key, headerEntry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
Request request = requestBuilder.build();
|
|
||||||
|
|
||||||
Response response = client.newCall(request).execute();
|
|
||||||
responseBody = response.body();
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
throw new IOException("Request failed with code: " + response.code());
|
|
||||||
}
|
|
||||||
|
|
||||||
long contentLength = responseBody.contentLength();
|
|
||||||
stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanup() {
|
|
||||||
if (stream != null) {
|
|
||||||
try {
|
|
||||||
stream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (responseBody != null) {
|
|
||||||
try {
|
|
||||||
responseBody.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignored.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return url.getCacheKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancel() {
|
|
||||||
// TODO: call cancel on the client when this method is called on a background thread. See #257
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user