Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.net.Uri;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class AssetFileDescriptorLocalUriFetcher extends LocalUriFetcher<AssetFileDescriptor> {
|
||||
public AssetFileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
|
||||
super(contentResolver, uri);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public AssetFileDescriptor a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
|
||||
AssetFileDescriptor openAssetFileDescriptor = contentResolver.openAssetFileDescriptor(uri, "r");
|
||||
if (openAssetFileDescriptor != null) {
|
||||
return openAssetFileDescriptor;
|
||||
}
|
||||
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public void a(AssetFileDescriptor assetFileDescriptor) throws IOException {
|
||||
assetFileDescriptor.close();
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<AssetFileDescriptor> a() {
|
||||
return AssetFileDescriptor.class;
|
||||
}
|
||||
}
|
58
sources/com/bumptech/glide/load/data/AssetPathFetcher.java
Normal file
58
sources/com/bumptech/glide/load/data/AssetPathFetcher.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.data.DataFetcher;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AssetPathFetcher<T> implements DataFetcher<T> {
|
||||
private final String a;
|
||||
private final AssetManager b;
|
||||
private T c;
|
||||
|
||||
public AssetPathFetcher(AssetManager assetManager, String str) {
|
||||
this.b = assetManager;
|
||||
this.a = str;
|
||||
}
|
||||
|
||||
protected abstract T a(AssetManager assetManager, String str) throws IOException;
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void a(Priority priority, DataFetcher.DataCallback<? super T> dataCallback) {
|
||||
try {
|
||||
this.c = a(this.b, this.a);
|
||||
dataCallback.a((DataFetcher.DataCallback<? super T>) this.c);
|
||||
} catch (IOException e) {
|
||||
if (Log.isLoggable("AssetPathFetcher", 3)) {
|
||||
Log.d("AssetPathFetcher", "Failed to load data from asset manager", e);
|
||||
}
|
||||
dataCallback.a((Exception) e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void a(T t) throws IOException;
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void b() {
|
||||
T t = this.c;
|
||||
if (t == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
a(t);
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public DataSource getDataSource() {
|
||||
return DataSource.LOCAL;
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BufferedOutputStream extends OutputStream {
|
||||
private final OutputStream a;
|
||||
private byte[] b;
|
||||
private ArrayPool c;
|
||||
private int d;
|
||||
|
||||
public BufferedOutputStream(OutputStream outputStream, ArrayPool arrayPool) {
|
||||
this(outputStream, arrayPool, 65536);
|
||||
}
|
||||
|
||||
private void a() throws IOException {
|
||||
int i = this.d;
|
||||
if (i > 0) {
|
||||
this.a.write(this.b, 0, i);
|
||||
this.d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void b() throws IOException {
|
||||
if (this.d == this.b.length) {
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
private void c() {
|
||||
byte[] bArr = this.b;
|
||||
if (bArr != null) {
|
||||
this.c.put(bArr);
|
||||
this.b = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
flush();
|
||||
this.a.close();
|
||||
c();
|
||||
} catch (Throwable th) {
|
||||
this.a.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
a();
|
||||
this.a.flush();
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream
|
||||
public void write(int i) throws IOException {
|
||||
byte[] bArr = this.b;
|
||||
int i2 = this.d;
|
||||
this.d = i2 + 1;
|
||||
bArr[i2] = (byte) i;
|
||||
b();
|
||||
}
|
||||
|
||||
BufferedOutputStream(OutputStream outputStream, ArrayPool arrayPool, int i) {
|
||||
this.a = outputStream;
|
||||
this.c = arrayPool;
|
||||
this.b = (byte[]) arrayPool.b(i, byte[].class);
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream
|
||||
public void write(byte[] bArr) throws IOException {
|
||||
write(bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream
|
||||
public void write(byte[] bArr, int i, int i2) throws IOException {
|
||||
int i3 = 0;
|
||||
do {
|
||||
int i4 = i2 - i3;
|
||||
int i5 = i + i3;
|
||||
if (this.d == 0 && i4 >= this.b.length) {
|
||||
this.a.write(bArr, i5, i4);
|
||||
return;
|
||||
}
|
||||
int min = Math.min(i4, this.b.length - this.d);
|
||||
System.arraycopy(bArr, i5, this.b, this.d, min);
|
||||
this.d += min;
|
||||
i3 += min;
|
||||
b();
|
||||
} while (i3 < i2);
|
||||
}
|
||||
}
|
24
sources/com/bumptech/glide/load/data/DataFetcher.java
Normal file
24
sources/com/bumptech/glide/load/data/DataFetcher.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DataFetcher<T> {
|
||||
|
||||
public interface DataCallback<T> {
|
||||
void a(Exception exc);
|
||||
|
||||
void a(T t);
|
||||
}
|
||||
|
||||
Class<T> a();
|
||||
|
||||
void a(Priority priority, DataCallback<? super T> dataCallback);
|
||||
|
||||
void b();
|
||||
|
||||
void cancel();
|
||||
|
||||
DataSource getDataSource();
|
||||
}
|
17
sources/com/bumptech/glide/load/data/DataRewinder.java
Normal file
17
sources/com/bumptech/glide/load/data/DataRewinder.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DataRewinder<T> {
|
||||
|
||||
public interface Factory<T> {
|
||||
DataRewinder<T> a(T t);
|
||||
|
||||
Class<T> a();
|
||||
}
|
||||
|
||||
T a() throws IOException;
|
||||
|
||||
void b();
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import com.bumptech.glide.load.data.DataRewinder;
|
||||
import com.bumptech.glide.util.Preconditions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DataRewinderRegistry {
|
||||
private static final DataRewinder.Factory<?> b = new DataRewinder.Factory<Object>() { // from class: com.bumptech.glide.load.data.DataRewinderRegistry.1
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
||||
public DataRewinder<Object> a(Object obj) {
|
||||
return new DefaultRewinder(obj);
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
||||
public Class<Object> a() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
};
|
||||
private final Map<Class<?>, DataRewinder.Factory<?>> a = new HashMap();
|
||||
|
||||
private static final class DefaultRewinder implements DataRewinder<Object> {
|
||||
private final Object a;
|
||||
|
||||
DefaultRewinder(Object obj) {
|
||||
this.a = obj;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder
|
||||
public Object a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder
|
||||
public void b() {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void a(DataRewinder.Factory<?> factory) {
|
||||
this.a.put(factory.a(), factory);
|
||||
}
|
||||
|
||||
public synchronized <T> DataRewinder<T> a(T t) {
|
||||
DataRewinder.Factory<?> factory;
|
||||
Preconditions.a(t);
|
||||
factory = this.a.get(t.getClass());
|
||||
if (factory == null) {
|
||||
Iterator<DataRewinder.Factory<?>> it = this.a.values().iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
DataRewinder.Factory<?> next = it.next();
|
||||
if (next.a().isAssignableFrom(t.getClass())) {
|
||||
factory = next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (factory == null) {
|
||||
factory = b;
|
||||
}
|
||||
return (DataRewinder<T>) factory.a(t);
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ExifOrientationStream extends FilterInputStream {
|
||||
private static final byte[] c = {-1, -31, 0, 28, 69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 8, 0, 1, 1, 18, 0, 2, 0, 0, 0, 1, 0};
|
||||
private static final int d = c.length;
|
||||
private static final int e = d + 2;
|
||||
private final byte a;
|
||||
private int b;
|
||||
|
||||
public ExifOrientationStream(InputStream inputStream, int i) {
|
||||
super(inputStream);
|
||||
if (i >= -1 && i <= 8) {
|
||||
this.a = (byte) i;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot add invalid orientation: " + i);
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public void mark(int i) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public int read() throws IOException {
|
||||
int i;
|
||||
int i2 = this.b;
|
||||
int read = (i2 < 2 || i2 > (i = e)) ? super.read() : i2 == i ? this.a : c[i2 - 2] & 255;
|
||||
if (read != -1) {
|
||||
this.b++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public void reset() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public long skip(long j) throws IOException {
|
||||
long skip = super.skip(j);
|
||||
if (skip > 0) {
|
||||
this.b = (int) (this.b + skip);
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
||||
@Override // java.io.FilterInputStream, java.io.InputStream
|
||||
public int read(byte[] bArr, int i, int i2) throws IOException {
|
||||
int i3;
|
||||
int i4 = this.b;
|
||||
int i5 = e;
|
||||
if (i4 > i5) {
|
||||
i3 = super.read(bArr, i, i2);
|
||||
} else if (i4 == i5) {
|
||||
bArr[i] = this.a;
|
||||
i3 = 1;
|
||||
} else if (i4 < 2) {
|
||||
i3 = super.read(bArr, i, 2 - i4);
|
||||
} else {
|
||||
int min = Math.min(i5 - i4, i2);
|
||||
System.arraycopy(c, this.b - 2, bArr, i, min);
|
||||
i3 = min;
|
||||
}
|
||||
if (i3 > 0) {
|
||||
this.b += i3;
|
||||
}
|
||||
return i3;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FileDescriptorAssetPathFetcher extends AssetPathFetcher<ParcelFileDescriptor> {
|
||||
public FileDescriptorAssetPathFetcher(AssetManager assetManager, String str) {
|
||||
super(assetManager, str);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.AssetPathFetcher
|
||||
public ParcelFileDescriptor a(AssetManager assetManager, String str) throws IOException {
|
||||
return assetManager.openFd(str).getParcelFileDescriptor();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.bumptech.glide.load.data.AssetPathFetcher
|
||||
public void a(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
|
||||
parcelFileDescriptor.close();
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<ParcelFileDescriptor> a() {
|
||||
return ParcelFileDescriptor.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FileDescriptorLocalUriFetcher extends LocalUriFetcher<ParcelFileDescriptor> {
|
||||
public FileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
|
||||
super(contentResolver, uri);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public ParcelFileDescriptor a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
|
||||
AssetFileDescriptor openAssetFileDescriptor = contentResolver.openAssetFileDescriptor(uri, "r");
|
||||
if (openAssetFileDescriptor != null) {
|
||||
return openAssetFileDescriptor.getParcelFileDescriptor();
|
||||
}
|
||||
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public void a(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
|
||||
parcelFileDescriptor.close();
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<ParcelFileDescriptor> a() {
|
||||
return ParcelFileDescriptor.class;
|
||||
}
|
||||
}
|
180
sources/com/bumptech/glide/load/data/HttpUrlFetcher.java
Normal file
180
sources/com/bumptech/glide/load/data/HttpUrlFetcher.java
Normal file
@@ -0,0 +1,180 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.HttpException;
|
||||
import com.bumptech.glide.load.data.DataFetcher;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.util.ContentLengthInputStream;
|
||||
import com.bumptech.glide.util.LogTime;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HttpUrlFetcher implements DataFetcher<InputStream> {
|
||||
static final HttpUrlConnectionFactory g = new DefaultHttpUrlConnectionFactory();
|
||||
private final GlideUrl a;
|
||||
private final int b;
|
||||
private final HttpUrlConnectionFactory c;
|
||||
private HttpURLConnection d;
|
||||
private InputStream e;
|
||||
private volatile boolean f;
|
||||
|
||||
private static class DefaultHttpUrlConnectionFactory implements HttpUrlConnectionFactory {
|
||||
DefaultHttpUrlConnectionFactory() {
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.HttpUrlFetcher.HttpUrlConnectionFactory
|
||||
public HttpURLConnection a(URL url) throws IOException {
|
||||
return (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
}
|
||||
|
||||
interface HttpUrlConnectionFactory {
|
||||
HttpURLConnection a(URL url) throws IOException;
|
||||
}
|
||||
|
||||
public HttpUrlFetcher(GlideUrl glideUrl, int i) {
|
||||
this(glideUrl, i, g);
|
||||
}
|
||||
|
||||
private static boolean b(int i) {
|
||||
return i / 100 == 3;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void a(Priority priority, DataFetcher.DataCallback<? super InputStream> dataCallback) {
|
||||
StringBuilder sb;
|
||||
long a = LogTime.a();
|
||||
try {
|
||||
try {
|
||||
dataCallback.a((DataFetcher.DataCallback<? super InputStream>) a(this.a.d(), 0, null, this.a.b()));
|
||||
} catch (IOException e) {
|
||||
if (Log.isLoggable("HttpUrlFetcher", 3)) {
|
||||
Log.d("HttpUrlFetcher", "Failed to load data for url", e);
|
||||
}
|
||||
dataCallback.a((Exception) e);
|
||||
if (!Log.isLoggable("HttpUrlFetcher", 2)) {
|
||||
return;
|
||||
} else {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
}
|
||||
if (Log.isLoggable("HttpUrlFetcher", 2)) {
|
||||
sb = new StringBuilder();
|
||||
sb.append("Finished http url fetcher fetch in ");
|
||||
sb.append(LogTime.a(a));
|
||||
Log.v("HttpUrlFetcher", sb.toString());
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
if (Log.isLoggable("HttpUrlFetcher", 2)) {
|
||||
Log.v("HttpUrlFetcher", "Finished http url fetcher fetch in " + LogTime.a(a));
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void cancel() {
|
||||
this.f = true;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public DataSource getDataSource() {
|
||||
return DataSource.REMOTE;
|
||||
}
|
||||
|
||||
HttpUrlFetcher(GlideUrl glideUrl, int i, HttpUrlConnectionFactory httpUrlConnectionFactory) {
|
||||
this.a = glideUrl;
|
||||
this.b = i;
|
||||
this.c = httpUrlConnectionFactory;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void b() {
|
||||
InputStream inputStream = this.e;
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
HttpURLConnection httpURLConnection = this.d;
|
||||
if (httpURLConnection != null) {
|
||||
httpURLConnection.disconnect();
|
||||
}
|
||||
this.d = null;
|
||||
}
|
||||
|
||||
private InputStream a(URL url, int i, URL url2, Map<String, String> map) throws IOException {
|
||||
if (i < 5) {
|
||||
if (url2 != null) {
|
||||
try {
|
||||
if (url.toURI().equals(url2.toURI())) {
|
||||
throw new HttpException("In re-direct loop");
|
||||
}
|
||||
} catch (URISyntaxException unused) {
|
||||
}
|
||||
}
|
||||
this.d = this.c.a(url);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
this.d.addRequestProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.d.setConnectTimeout(this.b);
|
||||
this.d.setReadTimeout(this.b);
|
||||
this.d.setUseCaches(false);
|
||||
this.d.setDoInput(true);
|
||||
this.d.setInstanceFollowRedirects(false);
|
||||
this.d.connect();
|
||||
this.e = this.d.getInputStream();
|
||||
if (this.f) {
|
||||
return null;
|
||||
}
|
||||
int responseCode = this.d.getResponseCode();
|
||||
if (a(responseCode)) {
|
||||
return a(this.d);
|
||||
}
|
||||
if (!b(responseCode)) {
|
||||
if (responseCode == -1) {
|
||||
throw new HttpException(responseCode);
|
||||
}
|
||||
throw new HttpException(this.d.getResponseMessage(), responseCode);
|
||||
}
|
||||
String headerField = this.d.getHeaderField("Location");
|
||||
if (!TextUtils.isEmpty(headerField)) {
|
||||
URL url3 = new URL(url, headerField);
|
||||
b();
|
||||
return a(url3, i + 1, url, map);
|
||||
}
|
||||
throw new HttpException("Received empty or null redirect url");
|
||||
}
|
||||
throw new HttpException("Too many (> 5) redirects!");
|
||||
}
|
||||
|
||||
private static boolean a(int i) {
|
||||
return i / 100 == 2;
|
||||
}
|
||||
|
||||
private InputStream a(HttpURLConnection httpURLConnection) throws IOException {
|
||||
if (TextUtils.isEmpty(httpURLConnection.getContentEncoding())) {
|
||||
this.e = ContentLengthInputStream.a(httpURLConnection.getInputStream(), httpURLConnection.getContentLength());
|
||||
} else {
|
||||
if (Log.isLoggable("HttpUrlFetcher", 3)) {
|
||||
Log.d("HttpUrlFetcher", "Got non empty content encoding: " + httpURLConnection.getContentEncoding());
|
||||
}
|
||||
this.e = httpURLConnection.getInputStream();
|
||||
}
|
||||
return this.e;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<InputStream> a() {
|
||||
return InputStream.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import com.bumptech.glide.load.data.DataRewinder;
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class InputStreamRewinder implements DataRewinder<InputStream> {
|
||||
private final RecyclableBufferedInputStream a;
|
||||
|
||||
public static final class Factory implements DataRewinder.Factory<InputStream> {
|
||||
private final ArrayPool a;
|
||||
|
||||
public Factory(ArrayPool arrayPool) {
|
||||
this.a = arrayPool;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
||||
public DataRewinder<InputStream> a(InputStream inputStream) {
|
||||
return new InputStreamRewinder(inputStream, this.a);
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
||||
public Class<InputStream> a() {
|
||||
return InputStream.class;
|
||||
}
|
||||
}
|
||||
|
||||
InputStreamRewinder(InputStream inputStream, ArrayPool arrayPool) {
|
||||
this.a = new RecyclableBufferedInputStream(inputStream, arrayPool);
|
||||
this.a.mark(5242880);
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder
|
||||
public void b() {
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.DataRewinder
|
||||
public InputStream a() throws IOException {
|
||||
this.a.reset();
|
||||
return this.a;
|
||||
}
|
||||
}
|
59
sources/com/bumptech/glide/load/data/LocalUriFetcher.java
Normal file
59
sources/com/bumptech/glide/load/data/LocalUriFetcher.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.data.DataFetcher;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class LocalUriFetcher<T> implements DataFetcher<T> {
|
||||
private final Uri a;
|
||||
private final ContentResolver b;
|
||||
private T c;
|
||||
|
||||
public LocalUriFetcher(ContentResolver contentResolver, Uri uri) {
|
||||
this.b = contentResolver;
|
||||
this.a = uri;
|
||||
}
|
||||
|
||||
protected abstract T a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException;
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public final void a(Priority priority, DataFetcher.DataCallback<? super T> dataCallback) {
|
||||
try {
|
||||
this.c = a(this.a, this.b);
|
||||
dataCallback.a((DataFetcher.DataCallback<? super T>) this.c);
|
||||
} catch (FileNotFoundException e) {
|
||||
if (Log.isLoggable("LocalUriFetcher", 3)) {
|
||||
Log.d("LocalUriFetcher", "Failed to open Uri", e);
|
||||
}
|
||||
dataCallback.a((Exception) e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void a(T t) throws IOException;
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void b() {
|
||||
T t = this.c;
|
||||
if (t != null) {
|
||||
try {
|
||||
a(t);
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public DataSource getDataSource() {
|
||||
return DataSource.LOCAL;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StreamAssetPathFetcher extends AssetPathFetcher<InputStream> {
|
||||
public StreamAssetPathFetcher(AssetManager assetManager, String str) {
|
||||
super(assetManager, str);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.AssetPathFetcher
|
||||
public InputStream a(AssetManager assetManager, String str) throws IOException {
|
||||
return assetManager.open(str);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.bumptech.glide.load.data.AssetPathFetcher
|
||||
public void a(InputStream inputStream) throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<InputStream> a() {
|
||||
return InputStream.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
package com.bumptech.glide.load.data;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.UriMatcher;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StreamLocalUriFetcher extends LocalUriFetcher<InputStream> {
|
||||
private static final UriMatcher d = new UriMatcher(-1);
|
||||
|
||||
static {
|
||||
d.addURI("com.android.contacts", "contacts/lookup/*/#", 1);
|
||||
d.addURI("com.android.contacts", "contacts/lookup/*", 1);
|
||||
d.addURI("com.android.contacts", "contacts/#/photo", 2);
|
||||
d.addURI("com.android.contacts", "contacts/#", 3);
|
||||
d.addURI("com.android.contacts", "contacts/#/display_photo", 4);
|
||||
d.addURI("com.android.contacts", "phone_lookup/*", 5);
|
||||
}
|
||||
|
||||
public StreamLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
|
||||
super(contentResolver, uri);
|
||||
}
|
||||
|
||||
private InputStream b(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
|
||||
int match = d.match(uri);
|
||||
if (match != 1) {
|
||||
if (match == 3) {
|
||||
return a(contentResolver, uri);
|
||||
}
|
||||
if (match != 5) {
|
||||
return contentResolver.openInputStream(uri);
|
||||
}
|
||||
}
|
||||
Uri lookupContact = ContactsContract.Contacts.lookupContact(contentResolver, uri);
|
||||
if (lookupContact != null) {
|
||||
return a(contentResolver, lookupContact);
|
||||
}
|
||||
throw new FileNotFoundException("Contact cannot be found");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public InputStream a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
|
||||
InputStream b = b(uri, contentResolver);
|
||||
if (b != null) {
|
||||
return b;
|
||||
}
|
||||
throw new FileNotFoundException("InputStream is null for " + uri);
|
||||
}
|
||||
|
||||
private InputStream a(ContentResolver contentResolver, Uri uri) {
|
||||
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.bumptech.glide.load.data.LocalUriFetcher
|
||||
public void a(InputStream inputStream) throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<InputStream> a() {
|
||||
return InputStream.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.bumptech.glide.load.data.mediastore;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FileService {
|
||||
FileService() {
|
||||
}
|
||||
|
||||
public boolean a(File file) {
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
public long b(File file) {
|
||||
return file.length();
|
||||
}
|
||||
|
||||
public File a(String str) {
|
||||
return new File(str);
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.bumptech.glide.load.data.mediastore;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MediaStoreUtil {
|
||||
public static boolean a(int i, int i2) {
|
||||
return i != Integer.MIN_VALUE && i2 != Integer.MIN_VALUE && i <= 512 && i2 <= 384;
|
||||
}
|
||||
|
||||
public static boolean a(Uri uri) {
|
||||
return b(uri) && !d(uri);
|
||||
}
|
||||
|
||||
public static boolean b(Uri uri) {
|
||||
return uri != null && "content".equals(uri.getScheme()) && "media".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean c(Uri uri) {
|
||||
return b(uri) && d(uri);
|
||||
}
|
||||
|
||||
private static boolean d(Uri uri) {
|
||||
return uri.getPathSegments().contains("video");
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package com.bumptech.glide.load.data.mediastore;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.data.DataFetcher;
|
||||
import com.bumptech.glide.load.data.ExifOrientationStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ThumbFetcher implements DataFetcher<InputStream> {
|
||||
private final Uri a;
|
||||
private final ThumbnailStreamOpener b;
|
||||
private InputStream c;
|
||||
|
||||
static class ImageThumbnailQuery implements ThumbnailQuery {
|
||||
private static final String[] b = {"_data"};
|
||||
private final ContentResolver a;
|
||||
|
||||
ImageThumbnailQuery(ContentResolver contentResolver) {
|
||||
this.a = contentResolver;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.mediastore.ThumbnailQuery
|
||||
public Cursor a(Uri uri) {
|
||||
return this.a.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, b, "kind = 1 AND image_id = ?", new String[]{uri.getLastPathSegment()}, null);
|
||||
}
|
||||
}
|
||||
|
||||
static class VideoThumbnailQuery implements ThumbnailQuery {
|
||||
private static final String[] b = {"_data"};
|
||||
private final ContentResolver a;
|
||||
|
||||
VideoThumbnailQuery(ContentResolver contentResolver) {
|
||||
this.a = contentResolver;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.mediastore.ThumbnailQuery
|
||||
public Cursor a(Uri uri) {
|
||||
return this.a.query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, b, "kind = 1 AND video_id = ?", new String[]{uri.getLastPathSegment()}, null);
|
||||
}
|
||||
}
|
||||
|
||||
ThumbFetcher(Uri uri, ThumbnailStreamOpener thumbnailStreamOpener) {
|
||||
this.a = uri;
|
||||
this.b = thumbnailStreamOpener;
|
||||
}
|
||||
|
||||
public static ThumbFetcher a(Context context, Uri uri) {
|
||||
return a(context, uri, new ImageThumbnailQuery(context.getContentResolver()));
|
||||
}
|
||||
|
||||
public static ThumbFetcher b(Context context, Uri uri) {
|
||||
return a(context, uri, new VideoThumbnailQuery(context.getContentResolver()));
|
||||
}
|
||||
|
||||
private InputStream c() throws FileNotFoundException {
|
||||
InputStream b = this.b.b(this.a);
|
||||
int a = b != null ? this.b.a(this.a) : -1;
|
||||
return a != -1 ? new ExifOrientationStream(b, a) : b;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public DataSource getDataSource() {
|
||||
return DataSource.LOCAL;
|
||||
}
|
||||
|
||||
private static ThumbFetcher a(Context context, Uri uri, ThumbnailQuery thumbnailQuery) {
|
||||
return new ThumbFetcher(uri, new ThumbnailStreamOpener(Glide.b(context).h().a(), thumbnailQuery, Glide.b(context).c(), context.getContentResolver()));
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void b() {
|
||||
InputStream inputStream = this.c;
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public void a(Priority priority, DataFetcher.DataCallback<? super InputStream> dataCallback) {
|
||||
try {
|
||||
this.c = c();
|
||||
dataCallback.a((DataFetcher.DataCallback<? super InputStream>) this.c);
|
||||
} catch (FileNotFoundException e) {
|
||||
if (Log.isLoggable("MediaStoreThumbFetcher", 3)) {
|
||||
Log.d("MediaStoreThumbFetcher", "Failed to find thumbnail file", e);
|
||||
}
|
||||
dataCallback.a((Exception) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.data.DataFetcher
|
||||
public Class<InputStream> a() {
|
||||
return InputStream.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.bumptech.glide.load.data.mediastore;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface ThumbnailQuery {
|
||||
Cursor a(Uri uri);
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
package com.bumptech.glide.load.data.mediastore;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.load.ImageHeaderParser;
|
||||
import com.bumptech.glide.load.ImageHeaderParserUtils;
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ThumbnailStreamOpener {
|
||||
private static final FileService f = new FileService();
|
||||
private final FileService a;
|
||||
private final ThumbnailQuery b;
|
||||
private final ArrayPool c;
|
||||
private final ContentResolver d;
|
||||
private final List<ImageHeaderParser> e;
|
||||
|
||||
ThumbnailStreamOpener(List<ImageHeaderParser> list, ThumbnailQuery thumbnailQuery, ArrayPool arrayPool, ContentResolver contentResolver) {
|
||||
this(list, f, thumbnailQuery, arrayPool, contentResolver);
|
||||
}
|
||||
|
||||
private String c(Uri uri) {
|
||||
Cursor a = this.b.a(uri);
|
||||
if (a != null) {
|
||||
try {
|
||||
if (a.moveToFirst()) {
|
||||
return a.getString(0);
|
||||
}
|
||||
} finally {
|
||||
if (a != null) {
|
||||
a.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
a.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int a(Uri uri) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
try {
|
||||
inputStream = this.d.openInputStream(uri);
|
||||
int a = ImageHeaderParserUtils.a(this.e, inputStream, this.c);
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
return a;
|
||||
} catch (IOException | NullPointerException e) {
|
||||
if (Log.isLoggable("ThumbStreamOpener", 3)) {
|
||||
Log.d("ThumbStreamOpener", "Failed to open uri: " + uri, e);
|
||||
}
|
||||
if (inputStream == null) {
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
inputStream.close();
|
||||
return -1;
|
||||
} catch (IOException unused2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
if (0 != 0) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused3) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public InputStream b(Uri uri) throws FileNotFoundException {
|
||||
String c = c(uri);
|
||||
if (TextUtils.isEmpty(c)) {
|
||||
return null;
|
||||
}
|
||||
File a = this.a.a(c);
|
||||
if (!a(a)) {
|
||||
return null;
|
||||
}
|
||||
Uri fromFile = Uri.fromFile(a);
|
||||
try {
|
||||
return this.d.openInputStream(fromFile);
|
||||
} catch (NullPointerException e) {
|
||||
throw ((FileNotFoundException) new FileNotFoundException("NPE opening uri: " + uri + " -> " + fromFile).initCause(e));
|
||||
}
|
||||
}
|
||||
|
||||
ThumbnailStreamOpener(List<ImageHeaderParser> list, FileService fileService, ThumbnailQuery thumbnailQuery, ArrayPool arrayPool, ContentResolver contentResolver) {
|
||||
this.a = fileService;
|
||||
this.b = thumbnailQuery;
|
||||
this.c = arrayPool;
|
||||
this.d = contentResolver;
|
||||
this.e = list;
|
||||
}
|
||||
|
||||
private boolean a(File file) {
|
||||
return this.a.a(file) && 0 < this.a.b(file);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user