allow null mime types

This commit is contained in:
tibbi 2016-11-21 18:23:09 +01:00
parent 746ccc2d96
commit 1b587b3d10
2 changed files with 2 additions and 2 deletions

View file

@ -62,7 +62,7 @@ class Utils {
}
}
fun getMimeType(url: String): String {
fun getMimeType(url: String): String? {
val extension = MimeTypeMap.getFileExtensionFromUrl(url)
return if (extension != null) {
MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)

View file

@ -250,7 +250,7 @@ class MainActivity : SimpleActivity(), GetDirectoriesAsynctask.GetDirectoriesLis
val path = resultData.data.path
val uri = Uri.fromFile(File(path))
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
val type = Utils.getMimeType(path)
val type = Utils.getMimeType(path) ?: ""
setDataAndTypeAndNormalize(uri, type)
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
} else if (mIsPickImageIntent || mIsPickVideoIntent) {