[Android] borwser refresh: directly map channel to list

Geoffrey Métais git at videolan.org
Tue Aug 7 21:24:49 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Aug  7 21:23:59 2018 +0200| [9779ca27a48f30ee0c61c850b80b9166f1143d82] | committer: Geoffrey Métais

borwser refresh: directly map channel to list

> https://code.videolan.org/videolan/vlc-android/commit/9779ca27a48f30ee0c61c850b80b9166f1143d82
---

 vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 84e47c954..62f8dd45b 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -31,6 +31,7 @@ import kotlinx.coroutines.experimental.Job
 import kotlinx.coroutines.experimental.android.HandlerContext
 import kotlinx.coroutines.experimental.android.UI
 import kotlinx.coroutines.experimental.channels.Channel
+import kotlinx.coroutines.experimental.channels.mapTo
 import kotlinx.coroutines.experimental.launch
 import kotlinx.coroutines.experimental.withContext
 import org.videolan.libvlc.Media
@@ -103,7 +104,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
         val refreshList = mutableListOf<MediaLibraryItem>()
         requestBrowsing(url)
         job = launch(UI.immediate) {
-            for (media in browserChannel) refreshList.add(findMedia(media))
+            browserChannel.mapTo(refreshList) { findMedia(it) }
             dataset.value = refreshList
             parseSubDirectories()
         }



More information about the Android mailing list