From 357286f1c96338ea01d4065167528e7ef28d284b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Oct 2017 11:34:42 +0200 Subject: [PATCH] use out own method for getting mimetype from extension --- .../filemanager/fragments/ItemsFragment.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index b89d9ce0..e473b4a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -11,7 +11,6 @@ import android.support.v7.widget.LinearLayoutManager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.webkit.MimeTypeMap import com.simplemobiletools.commons.dialogs.StoragePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.FileDirItem @@ -232,9 +231,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum private fun fileClicked(path: String) { val file = File(path) - var mimeType: String? = MimeTypeMap.getSingleton().getMimeTypeFromExtension(path.getFilenameExtension().toLowerCase()) - if (mimeType == null) - mimeType = "text/plain" + val mimeType = path.getMimeTypeFromPath() Intent(Intent.ACTION_VIEW).apply { setDataAndType(Uri.fromFile(file), mimeType) @@ -242,7 +239,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum try { startActivity(this) } catch (e: ActivityNotFoundException) { - if (!tryGenericMimeType(this, mimeType!!, file)) { + if (!tryGenericMimeType(this, mimeType, file)) { activity.toast(R.string.no_app_found) } }