Skip to content

Commit 124c70c

Browse files
committed
Use default title/size upon any exception when querying Cursor.
1 parent 6ad8f4f commit 124c70c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/src/main/java/com/artifex/mupdf/viewer/DocumentActivity.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ public void onCreate(final Bundle savedInstanceState)
215215

216216
mDocTitle = null;
217217
long size = -1;
218-
Cursor cursor;
218+
Cursor cursor = null;
219219

220-
cursor = getContentResolver().query(uri, null, null, null, null);
221-
if (cursor != null && cursor.moveToFirst()) {
222-
try {
220+
try {
221+
cursor = getContentResolver().query(uri, null, null, null, null);
222+
if (cursor != null && cursor.moveToFirst()) {
223223
int idx;
224224

225225
idx = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
@@ -232,9 +232,13 @@ public void onCreate(final Bundle savedInstanceState)
232232

233233
if (size == 0)
234234
size = -1;
235-
} finally {
236-
cursor.close();
237235
}
236+
} catch (Exception x) {
237+
// Ignore any exception and depend on default values for title
238+
// and size (unless one was decoded
239+
} finally {
240+
if (cursor != null)
241+
cursor.close();
238242
}
239243

240244
Log.i(APP, " NAME " + mDocTitle);

0 commit comments

Comments
 (0)