[Android] Sort browsers content in background
Geoffrey Métais
git at videolan.org
Fri Apr 6 16:50:29 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr 6 16:50:00 2018 +0200| [fbe9d4ae584815a1238d1075fa7bc00058f2d10f] | committer: Geoffrey Métais
Sort browsers content in background
> https://code.videolan.org/videolan/vlc-android/commit/fbe9d4ae584815a1238d1075fa7bc00058f2d10f
---
.../org/videolan/vlc/viewmodels/browser/BrowserProvider.kt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserProvider.kt
index 2064fe879..d08c8df51 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserProvider.kt
@@ -8,9 +8,12 @@ import android.os.Process
import android.support.annotation.MainThread
import android.support.v4.util.SimpleArrayMap
import android.text.TextUtils
+import kotlinx.coroutines.experimental.CommonPool
+import kotlinx.coroutines.experimental.CoroutineStart
import kotlinx.coroutines.experimental.android.HandlerContext
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.launch
+import kotlinx.coroutines.experimental.withContext
import org.videolan.libvlc.Media
import org.videolan.libvlc.util.MediaBrowser
import org.videolan.libvlc.util.MediaBrowser.EventListener
@@ -73,9 +76,11 @@ abstract class BrowserProvider(val url: String?, private val showHiddenFiles: Bo
@MainThread
override fun sort(sort: Int) {
- this.sort = sort
- desc = !desc
- dataset.value = dataset.value.apply { sortWith(if (desc) descComp else ascComp) }
+ launch(UI, CoroutineStart.UNDISPATCHED) {
+ this at BrowserProvider.sort = sort
+ desc = !desc
+ dataset.value = withContext(CommonPool) { dataset.value.apply { sortWith(if (desc) descComp else ascComp) } }
+ }
}
fun releaseBrowser() {
More information about the Android
mailing list