Initial commit
This commit is contained in:
@@ -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