Skip to content

Commit

Permalink
fix: crash when opening file from Dropbox while it is downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
axxie committed Apr 4, 2021
1 parent c297ea5 commit af84a82
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/src/main/java/com/axxie/tiddlywikiandroid/ViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af84a82

Please sign in to comment.