Skip to content

Commit

Permalink
Fix receiving files
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykcoding committed May 1, 2018
1 parent e5e2626 commit f19cb3a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/src/main/java/ca/pkay/rcloneexplorer/SharingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,21 @@ private class CopyFile extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... voids) {
for (Uri uri : uris) {
Cursor returnCursor = getContentResolver().query(uri, null, null, null, null);
if (returnCursor == null) {
return false;
String fileName;
if (uri.getScheme().equals("content")) {
Cursor returnCursor = getContentResolver().query(uri, null, null, null, null);
if (returnCursor == null) {
return false;
}
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
returnCursor.moveToFirst();
fileName = returnCursor.getString(nameIndex);
returnCursor.close();
} else {
fileName = uri.getPath();
int index = fileName.lastIndexOf("/");
fileName = fileName.substring(index + 1);
}
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
returnCursor.moveToFirst();
String fileName = returnCursor.getString(nameIndex);
returnCursor.close();

File cacheDir = getExternalCacheDir();
InputStream inputStream;
Expand Down

0 comments on commit f19cb3a

Please sign in to comment.