Skip to content

Commit

Permalink
Move null check outside of isAllowedMediaType and put them where it's…
Browse files Browse the repository at this point in the history
… called
  • Loading branch information
geriux committed Jan 15, 2024
1 parent a630efc commit e837837
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,21 @@ 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));
}
}
}

private boolean isAllowedMediaType(@NonNull Uri uri) {
if (uri != null) {
String filePath = MediaUtils.getRealPathFromURI(this, uri);
return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath);
}
return false;
String filePath = MediaUtils.getRealPathFromURI(this, uri);
return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath);
}

private void initShareFragment() {
Expand Down

0 comments on commit e837837

Please sign in to comment.