use the Commons way of determining mimetype of multiple uris

This commit is contained in:
tibbi 2017-10-22 22:56:40 +02:00
parent 2969314cc9
commit e0703acd9d
2 changed files with 2 additions and 15 deletions

View File

@ -37,7 +37,7 @@ android {
}
dependencies {
compile 'com.simplemobiletools:commons:2.30.10'
compile 'com.simplemobiletools:commons:2.30.13'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

View File

@ -179,7 +179,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
action = Intent.ACTION_SEND_MULTIPLE
putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
}
type = getMimeType(uris)
type = uris.getMimeType()
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
try {
@ -200,19 +200,6 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
}
}
private fun getMimeType(uris: List<Uri>): String {
val firstMimeType = uris.first().path.getMimeTypeFromPath()
val firstMimeGroup = firstMimeType.substringBefore("/")
uris.forEach {
val mimeGroup = it.path.getMimeTypeFromPath().substringBefore("/")
if (mimeGroup != firstMimeGroup) {
return "*/*"
}
}
return firstMimeType
}
private fun copyMoveTo(isCopyOperation: Boolean) {
val files = ArrayList<File>()
selectedPositions.forEach { files.add(File(mItems[it].path)) }