allow null mime types
This commit is contained in:
parent
746ccc2d96
commit
1b587b3d10
2 changed files with 2 additions and 2 deletions
|
@ -62,7 +62,7 @@ class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMimeType(url: String): String {
|
fun getMimeType(url: String): String? {
|
||||||
val extension = MimeTypeMap.getFileExtensionFromUrl(url)
|
val extension = MimeTypeMap.getFileExtensionFromUrl(url)
|
||||||
return if (extension != null) {
|
return if (extension != null) {
|
||||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
|
MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
|
||||||
|
|
|
@ -250,7 +250,7 @@ class MainActivity : SimpleActivity(), GetDirectoriesAsynctask.GetDirectoriesLis
|
||||||
val path = resultData.data.path
|
val path = resultData.data.path
|
||||||
val uri = Uri.fromFile(File(path))
|
val uri = Uri.fromFile(File(path))
|
||||||
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
|
if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) {
|
||||||
val type = Utils.getMimeType(path)
|
val type = Utils.getMimeType(path) ?: ""
|
||||||
setDataAndTypeAndNormalize(uri, type)
|
setDataAndTypeAndNormalize(uri, type)
|
||||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||||
} else if (mIsPickImageIntent || mIsPickVideoIntent) {
|
} else if (mIsPickImageIntent || mIsPickVideoIntent) {
|
||||||
|
|
Loading…
Reference in a new issue