[Android] Refresh once ML actions are done

Geoffrey Métais git at videolan.org
Tue Mar 24 09:41:07 CET 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 19 16:26:09 2020 +0100| [443d6dae862960988f3fb25dfbd286e50f6bfd2b] | committer: Nicolas Pomepuy

Refresh once ML actions are done

> https://code.videolan.org/videolan/vlc-android/commit/443d6dae862960988f3fb25dfbd286e50f6bfd2b
---

 .../src/org/videolan/vlc/viewmodels/StreamsModel.kt          | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/StreamsModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/StreamsModel.kt
index debcc78e5..1b70532ff 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/StreamsModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/StreamsModel.kt
@@ -48,14 +48,18 @@ class StreamsModel(context: Context, coroutineContextProvider: CoroutineContextP
 
     fun rename(position: Int, name: String) {
         val media = dataset.get(position)
-        viewModelScope.launch(Dispatchers.IO) { media.rename(name) }
-        refresh()
+        viewModelScope.launch {
+            withContext(Dispatchers.IO) { media.rename(name) }
+            refresh()
+        }
     }
 
     fun delete() {
         deletingMedia?.let { media ->
-            viewModelScope.launch(Dispatchers.IO) { context.getFromMl { removeExternalMedia(media.id) } }
-            refresh()
+            viewModelScope.launch {
+                context.getFromMl { removeExternalMedia(media.id) }
+                refresh()
+            }
         }
     }
     class Factory(private val context: Context) : ViewModelProvider.Factory {



More information about the Android mailing list