package r1; 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.load.data.d; import com.bumptech.glide.load.data.g; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; /* loaded from: classes.dex */ public class c implements com.bumptech.glide.load.data.d { /* renamed from: a, reason: collision with root package name */ private final Uri f13606a; /* renamed from: b, reason: collision with root package name */ private final e f13607b; /* renamed from: c, reason: collision with root package name */ private InputStream f13608c; static class a implements d { /* renamed from: b, reason: collision with root package name */ private static final String[] f13609b = {"_data"}; /* renamed from: a, reason: collision with root package name */ private final ContentResolver f13610a; a(ContentResolver contentResolver) { this.f13610a = contentResolver; } @Override // r1.d public Cursor a(Uri uri) { return this.f13610a.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, f13609b, "kind = 1 AND image_id = ?", new String[]{uri.getLastPathSegment()}, null); } } static class b implements d { /* renamed from: b, reason: collision with root package name */ private static final String[] f13611b = {"_data"}; /* renamed from: a, reason: collision with root package name */ private final ContentResolver f13612a; b(ContentResolver contentResolver) { this.f13612a = contentResolver; } @Override // r1.d public Cursor a(Uri uri) { return this.f13612a.query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, f13611b, "kind = 1 AND video_id = ?", new String[]{uri.getLastPathSegment()}, null); } } c(Uri uri, e eVar) { this.f13606a = uri; this.f13607b = eVar; } private static c c(Context context, Uri uri, d dVar) { return new c(uri, new e(com.bumptech.glide.b.c(context).j().g(), dVar, com.bumptech.glide.b.c(context).e(), context.getContentResolver())); } public static c e(Context context, Uri uri) { return c(context, uri, new a(context.getContentResolver())); } public static c g(Context context, Uri uri) { return c(context, uri, new b(context.getContentResolver())); } private InputStream h() { InputStream d10 = this.f13607b.d(this.f13606a); int a10 = d10 != null ? this.f13607b.a(this.f13606a) : -1; return a10 != -1 ? new g(d10, a10) : d10; } @Override // com.bumptech.glide.load.data.d public Class a() { return InputStream.class; } @Override // com.bumptech.glide.load.data.d public void b() { InputStream inputStream = this.f13608c; if (inputStream != null) { try { inputStream.close(); } catch (IOException unused) { } } } @Override // com.bumptech.glide.load.data.d public void cancel() { } @Override // com.bumptech.glide.load.data.d public q1.a d() { return q1.a.LOCAL; } @Override // com.bumptech.glide.load.data.d public void f(com.bumptech.glide.g gVar, d.a aVar) { try { InputStream h10 = h(); this.f13608c = h10; aVar.e(h10); } catch (FileNotFoundException e10) { if (Log.isLoggable("MediaStoreThumbFetcher", 3)) { Log.d("MediaStoreThumbFetcher", "Failed to find thumbnail file", e10); } aVar.c(e10); } } }