package o; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.provider.MediaStore; import com.squareup.picasso.Picasso; import java.io.IOException; import o.AbstractC12987fNZ; /* loaded from: classes.dex */ public final class fNT extends fND { private static final String[] b = {"orientation"}; public fNT(Context context) { super(context); } @Override // o.fND, o.AbstractC12987fNZ public final boolean d(fNW fnw) { Uri uri = fnw.r; return "content".equals(uri.getScheme()) && "media".equals(uri.getAuthority()); } @Override // o.fND, o.AbstractC12987fNZ public final AbstractC12987fNZ.Sts c(fNW fnw, int i) throws IOException { LWm lWm; Bitmap thumbnail; ContentResolver contentResolver = this.e.getContentResolver(); int aBl_ = aBl_(contentResolver, fnw.r); String type = contentResolver.getType(fnw.r); boolean z = type != null && type.startsWith("video/"); if (fnw.p != 0 || fnw.s != 0) { int i2 = fnw.p; int i3 = fnw.s; if (i2 <= LWm.MICRO.width && i3 <= LWm.MICRO.height) { lWm = LWm.MICRO; } else if (i2 <= LWm.MINI.width && i3 <= LWm.MINI.height) { lWm = LWm.MINI; } else { lWm = LWm.FULL; } LWm lWm2 = lWm; if (!z && lWm2 == LWm.FULL) { return new AbstractC12987fNZ.Sts(null, C15160gio.e(this.e.getContentResolver().openInputStream(fnw.r)), Picasso.HBt.DISK, aBl_); } long parseId = ContentUris.parseId(fnw.r); BitmapFactory.Options aBx_ = aBx_(fnw); aBx_.inJustDecodeBounds = true; aBw_(fnw.p, fnw.s, lWm2.width, lWm2.height, aBx_, fnw); if (z) { thumbnail = MediaStore.Video.Thumbnails.getThumbnail(contentResolver, parseId, lWm2 == LWm.FULL ? 1 : lWm2.androidKind, aBx_); } else { thumbnail = MediaStore.Images.Thumbnails.getThumbnail(contentResolver, parseId, lWm2.androidKind, aBx_); } if (thumbnail != null) { return new AbstractC12987fNZ.Sts(thumbnail, null, Picasso.HBt.DISK, aBl_); } } return new AbstractC12987fNZ.Sts(null, C15160gio.e(this.e.getContentResolver().openInputStream(fnw.r)), Picasso.HBt.DISK, aBl_); } /* JADX WARN: Code restructure failed: missing block: B:15:0x0022, code lost: r1.close(); */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static int aBl_(android.content.ContentResolver r8, android.net.Uri r9) { /* r0 = 0 r1 = 0 java.lang.String[] r4 = o.fNT.b // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d r5 = 0 r6 = 0 r7 = 0 r2 = r8 r3 = r9 android.database.Cursor r1 = r2.query(r3, r4, r5, r6, r7) // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d if (r1 == 0) goto L20 boolean r8 = r1.moveToFirst() // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d if (r8 != 0) goto L16 goto L20 L16: int r8 = r1.getInt(r0) // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d if (r1 == 0) goto L1f r1.close() L1f: return r8 L20: if (r1 == 0) goto L25 r1.close() L25: return r0 L26: r8 = move-exception if (r1 == 0) goto L2c r1.close() L2c: throw r8 L2d: if (r1 == 0) goto L32 r1.close() L32: return r0 */ throw new UnsupportedOperationException("Method not decompiled: o.fNT.aBl_(android.content.ContentResolver, android.net.Uri):int"); } /* loaded from: classes.dex */ enum LWm { MICRO(3, 96, 96), MINI(1, 512, 384), FULL(2, -1, -1); final int androidKind; final int height; final int width; LWm(int i, int i2, int i3) { this.androidKind = i; this.width = i2; this.height = i3; } } }