Commit 5f6f6de6 authored by Geoffrey Métais's avatar Geoffrey Métais

Browsers: code cleaning

parent 14862ae4
......@@ -54,7 +54,7 @@ internal class StorageBrowserAdapter(fragment: BaseBrowserFragment) : BaseBrowse
}
override fun onBindViewHolder(holder: BaseBrowserAdapter.ViewHolder<*>, position: Int) {
launch(UI.immediate) {
launch {
val vh = holder as BaseBrowserAdapter.MediaViewHolder
var storage = getItem(position)
......@@ -81,14 +81,14 @@ internal class StorageBrowserAdapter(fragment: BaseBrowserFragment) : BaseBrowse
}
fun updateMediaDirs(context: Context) {
if (mediaDirsLocation != null) mediaDirsLocation.clear()
mediaDirsLocation.clear()
val folders = VLCApplication.getMLInstance().foldersList
folders.forEach {
mediaDirsLocation.add(Uri.decode(if (it.startsWith("file://")) it.substring(7) else it))
}
job = launch(UI.immediate) {
job = launch {
customDirsLocation = DirectoryRepository.getInstance(context).getCustomDirectories().map { it.path }
}
}
......
......@@ -26,7 +26,6 @@ import android.hardware.usb.UsbDevice
import android.net.Uri
import android.text.TextUtils
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.android.UI
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.media.DummyItem
import org.videolan.medialibrary.media.MediaLibraryItem
......@@ -67,7 +66,7 @@ open class FileBrowserProvider(
}
}
}
launch(UI.immediate) {
launch {
if (favs.isNotEmpty()) {
job?.cancelAndJoin()
val position = data.size
......@@ -127,8 +126,8 @@ open class FileBrowserProvider(
override fun browse(url: String?) {
when {
url == "otg://" || url?.startsWith("content:") == true -> launch(UI.immediate) {
dataset.value = withContext(IO) { getDocumentFiles(context, Uri.parse(url).path.substringAfterLast(':')) as? MutableList<MediaLibraryItem> ?: mutableListOf() }
url == "otg://" || url?.startsWith("content:") == true -> launch {
dataset.value = withContext(Dispatchers.IO) { getDocumentFiles(context, Uri.parse(url).path?.substringAfterLast(':') ?: "") as? MutableList<MediaLibraryItem> ?: mutableListOf() }
}
else -> super.browse(url)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment