Skip to content

Commit 16e01b6

Browse files
committed
Catching other unknown URL exception.
1 parent d70578c commit 16e01b6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ public static int[] getImageSize(Uri uri, Context context){
4242

4343
if (uri.toString().contains("content:")) {
4444
String[] projection = new String[] { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA };
45-
Cursor cur = context.getContentResolver().query(uri, projection, null, null, null);
46-
if (cur != null) {
47-
if (cur.moveToFirst()) {
45+
Cursor cur = null;
46+
try {
47+
cur = context.getContentResolver().query(uri, projection, null, null, null);
48+
if (cur != null && cur.moveToFirst()) {
4849
int dataColumn = cur.getColumnIndex(MediaStore.Images.Media.DATA);
4950
path = cur.getString(dataColumn);
5051
}
51-
cur.close();
52+
} catch (IllegalStateException stateException) {
53+
Log.d(ImageUtils.class.getName(), "IllegalStateException querying content:" + uri);
54+
} finally {
55+
SqlUtils.closeCursor(cur);
5256
}
5357
}
5458

0 commit comments

Comments
 (0)