Skip to content

Commit

Permalink
Closes #897
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantcheese committed May 22, 2020
1 parent c3b2c45 commit 462af07
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns;
import android.text.TextUtils;
import android.widget.Toast;

import androidx.annotation.Nullable;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class ImagePickDelegate {
private Activity activity;
private ImagePickCallback callback;
private Uri uri;
private String fileName;
private String fileName = "";
private boolean success = false;
private ExecutorService executor = Executors.newSingleThreadExecutor();

Expand Down Expand Up @@ -212,11 +213,11 @@ public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
returnCursor.close();
}

if (fileName == null) {
if (TextUtils.isEmpty(fileName)) {
// As per the comment on OpenableColumns.DISPLAY_NAME:
// If this is not provided then the name should default to the last segment of the file's URI.
fileName = uri.getLastPathSegment();
fileName = fileName == null ? DEFAULT_FILE_NAME : fileName;
fileName = TextUtils.isEmpty(fileName) ? DEFAULT_FILE_NAME : fileName;
}

executor.execute(this::run);
Expand Down Expand Up @@ -291,7 +292,7 @@ private void run() {
private void reset() {
callback = null;
success = false;
fileName = null;
fileName = "";
uri = null;
}

Expand Down

0 comments on commit 462af07

Please sign in to comment.