diff --git a/app/src/main/java/com/axxie/tiddlywikiandroid/ViewActivity.java b/app/src/main/java/com/axxie/tiddlywikiandroid/ViewActivity.java index b231d46..9836944 100644 --- a/app/src/main/java/com/axxie/tiddlywikiandroid/ViewActivity.java +++ b/app/src/main/java/com/axxie/tiddlywikiandroid/ViewActivity.java @@ -53,13 +53,20 @@ public boolean saveFile(String filename, String data) { public String getFileNameFromUri(Uri uri) { String result = null; if (uri.getScheme().equals("content")) { - Cursor cursor = getContentResolver().query(uri, null, null, null, null); + Cursor cursor = null; + try { + cursor = getContentResolver().query(uri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); } + } catch (IllegalArgumentException e) { + // TODO: handle error + return null; } finally { - cursor.close(); + if (cursor != null) { + cursor.close(); + } } } if (result == null) { @@ -109,9 +116,13 @@ public void onProgressChanged(WebView view, int progress) { if (progress == 100) { activity.progress.setVisibility(View.GONE); - setTitle(title); } } + + @Override + public void onReceivedTitle(WebView view, String title) { + setTitle(title); + } }); view.setWebViewClient(new WebViewClient() { @Override