Skip to content

Commit

Permalink
Merge pull request #19947 from wordpress-mobile/fix/sharing-media-crash
Browse files Browse the repository at this point in the history
Prevent processing media if the Uri is null or if mLocalMediaUris is …
  • Loading branch information
Gerardo Pacheco authored Jan 15, 2024
2 parents 6f3e0f4 + e837837 commit 9812efc
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ private void downloadExternalMedia() {
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) {
ArrayList<Uri> externalUris = getIntent().getParcelableArrayListExtra((Intent.EXTRA_STREAM));
for (Uri uri : externalUris) {
if (isAllowedMediaType(uri)) {
if (uri != null && isAllowedMediaType(uri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, uri));
}
}
} else if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
Uri externalUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
if (isAllowedMediaType(externalUri)) {
if (externalUri != null && isAllowedMediaType(externalUri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, externalUri));
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ private void startActivityAndFinish(@NonNull Intent intent, int mSelectedSiteLoc

if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
intent.putExtra(Intent.EXTRA_STREAM, mLocalMediaUris);
} else if (Intent.ACTION_SEND.equals(action)) {
} else if (Intent.ACTION_SEND.equals(action) && !mLocalMediaUris.isEmpty()) {
intent.putExtra(Intent.EXTRA_STREAM, mLocalMediaUris.get(0));
}

Expand Down

0 comments on commit 9812efc

Please sign in to comment.