[Android] Fix tracks viewmodel callbacks subscription

Geoffrey Métais git at videolan.org
Wed Feb 13 12:04:11 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 13 12:03:09 2019 +0100| [ce106c1f94e6c86b500287e547c432cd1499d946] | committer: Geoffrey Métais

Fix tracks viewmodel callbacks subscription

Fix #752

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

 .../vlc/viewmodels/paged/PagedTracksModel.kt         | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedTracksModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedTracksModel.kt
index 963236f10..d06aaab04 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedTracksModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedTracksModel.kt
@@ -3,8 +3,6 @@ package org.videolan.vlc.viewmodels.paged
 import android.content.Context
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.ViewModelProvider
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
 import org.videolan.medialibrary.Medialibrary
 import org.videolan.medialibrary.media.*
 import org.videolan.vlc.util.EmptyMLCallbacks
@@ -31,18 +29,12 @@ class PagedTracksModel(context: Context, val parent: MediaLibraryItem? = null):
             else -> Medialibrary.SORT_ALPHA
         }
         if (medialibrary.isStarted) refresh()
-    }
-
-    override fun onMedialibraryReady() {
-        super.onMedialibraryReady()
-        launch(Dispatchers.Main) {
-            when (parent) {
-                is Artist -> medialibrary.addArtistsCb(this at PagedTracksModel)
-                is Album -> medialibrary.addAlbumsCb(this at PagedTracksModel)
-                is Genre -> medialibrary.addGenreCb(this at PagedTracksModel)
-                is Playlist -> medialibrary.addPlaylistCb(this at PagedTracksModel)
-                else -> medialibrary.addMediaCb(this at PagedTracksModel)
-            }
+        when (parent) {
+            is Artist -> medialibrary.addArtistsCb(this at PagedTracksModel)
+            is Album -> medialibrary.addAlbumsCb(this at PagedTracksModel)
+            is Genre -> medialibrary.addGenreCb(this at PagedTracksModel)
+            is Playlist -> medialibrary.addPlaylistCb(this at PagedTracksModel)
+            else -> medialibrary.addMediaCb(this at PagedTracksModel)
         }
     }
 



More information about the Android mailing list