Skip to content

Commit

Permalink
Add uri as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Feb 7, 2024
1 parent daccf7e commit 0c98841
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -116,7 +117,11 @@ private void downloadExternalMedia() {
}

private boolean isAllowedMediaType(@NonNull Uri uri) {
String filePath = uri.getPath();
String filePath = MediaUtils.getRealPathFromURI(this, uri);
// For cases when getRealPathFromURI returns an empty string
if (TextUtils.isEmpty(filePath)) {
filePath = String.valueOf(uri);
}
return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath);
}

Expand Down

0 comments on commit 0c98841

Please sign in to comment.