mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
lint: minor de-lint of ContentResolverUtil
just null checking / annotation
(cherry picked from commit f9153d7e85
)
This commit is contained in:
parent
754cdd3fe4
commit
17eadee486
@ -26,6 +26,7 @@ import java.io.File;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import androidx.annotation.CheckResult;
|
import androidx.annotation.CheckResult;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
@ -53,9 +54,9 @@ public class ContentResolverUtil {
|
|||||||
|
|
||||||
@CheckResult
|
@CheckResult
|
||||||
@Nullable
|
@Nullable
|
||||||
private static String getFilenameViaMimeType(ContentResolver contentResolver, Uri uri) {
|
private static String getFilenameViaMimeType(ContentResolver contentResolver, @NonNull Uri uri) {
|
||||||
// value: "png" when testing
|
// value: "png" when testing
|
||||||
String extension;
|
String extension = null;
|
||||||
|
|
||||||
//Check uri format to avoid null
|
//Check uri format to avoid null
|
||||||
if (uri.getScheme() != null && uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
|
if (uri.getScheme() != null && uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
|
||||||
@ -65,7 +66,9 @@ public class ContentResolverUtil {
|
|||||||
} else {
|
} else {
|
||||||
// If scheme is a File
|
// If scheme is a File
|
||||||
// This will replace white spaces with %20 and also other special characters. This will avoid returning null values on file name with spaces and special characters.
|
// This will replace white spaces with %20 and also other special characters. This will avoid returning null values on file name with spaces and special characters.
|
||||||
extension = MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(new File(uri.getPath())).toString().toLowerCase(Locale.ROOT));
|
if (uri.getPath() != null) {
|
||||||
|
extension = MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(new File(uri.getPath())).toString().toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (extension == null) {
|
if (extension == null) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user