60 lines
1.7 KiB
Java
60 lines
1.7 KiB
Java
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;
|
|
}
|
|
}
|