use out own method for getting mimetype from extension

This commit is contained in:
tibbi 2017-10-23 11:34:42 +02:00
parent f996cceb7a
commit 357286f1c9
1 changed files with 2 additions and 5 deletions

View File

@ -11,7 +11,6 @@ import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.webkit.MimeTypeMap
import com.simplemobiletools.commons.dialogs.StoragePickerDialog import com.simplemobiletools.commons.dialogs.StoragePickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.models.FileDirItem
@ -232,9 +231,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
private fun fileClicked(path: String) { private fun fileClicked(path: String) {
val file = File(path) val file = File(path)
var mimeType: String? = MimeTypeMap.getSingleton().getMimeTypeFromExtension(path.getFilenameExtension().toLowerCase()) val mimeType = path.getMimeTypeFromPath()
if (mimeType == null)
mimeType = "text/plain"
Intent(Intent.ACTION_VIEW).apply { Intent(Intent.ACTION_VIEW).apply {
setDataAndType(Uri.fromFile(file), mimeType) setDataAndType(Uri.fromFile(file), mimeType)
@ -242,7 +239,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
try { try {
startActivity(this) startActivity(this)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
if (!tryGenericMimeType(this, mimeType!!, file)) { if (!tryGenericMimeType(this, mimeType, file)) {
activity.toast(R.string.no_app_found) activity.toast(R.string.no_app_found)
} }
} }