Skip to content

Commit ba751a2

Browse files
committed
Catching unknown URL exceptions.
1 parent f1d2319 commit ba751a2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.os.AsyncTask;
1919
import android.provider.MediaStore;
2020
import android.text.TextUtils;
21+
import android.util.Log;
2122
import android.widget.ImageView;
2223

2324
import org.apache.http.HttpEntity;
@@ -405,13 +406,17 @@ public static byte[] createThumbnailFromUri(Context context,
405406
String filePath = null;
406407
if (imageUri.toString().contains("content:")) {
407408
String[] projection = new String[] { MediaStore.Images.Media.DATA };
408-
Cursor cur = context.getContentResolver().query(imageUri, projection, null, null, null);
409-
if (cur != null) {
410-
if (cur.moveToFirst()) {
411-
int dataColumn = cur.getColumnIndex(MediaStore.Images.Media.DATA);
412-
filePath = cur.getString(dataColumn);
409+
try {
410+
Cursor cur = context.getContentResolver().query(imageUri, projection, null, null, null);
411+
if (cur != null) {
412+
if (cur.moveToFirst()) {
413+
int dataColumn = cur.getColumnIndex(MediaStore.Images.Media.DATA);
414+
filePath = cur.getString(dataColumn);
415+
}
416+
cur.close();
413417
}
414-
cur.close();
418+
} catch (IllegalStateException stateException) {
419+
Log.d(ImageUtils.class.getName(), "IllegalStateException querying content:" + imageUri);
415420
}
416421
}
417422

0 commit comments

Comments
 (0)