Skip to content
Snippets Groups Projects
Commit 3ee988cf authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

getAll function for paged viewmodels

parent c271b062
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
abstract fun getTotalCount() : Int
abstract fun getPage(loadSize: Int, startposition: Int) : Array<T>
abstract fun getAll() : Array<T>?
override fun sort(sort: Int) {
if (this.sort != sort) {
......
......@@ -28,6 +28,12 @@ class PagedAlbumsModel(context: Context, val parent: MediaLibraryItem? = null) :
refresh()
}
override fun getAll() = when (parent) {
is Artist -> parent.getAlbums(sort, desc)
is Genre -> parent.getAlbums(sort, desc)
else -> medialibrary.getAlbums(sort, desc)
}
override fun getPage(loadSize: Int, startposition: Int) : Array<Album> = if (filter == null) when(parent) {
is Artist -> parent.getPagedAlbums(sort, desc, loadSize, startposition)
is Genre -> parent.getPagedAlbums(sort, desc, loadSize, startposition)
......
......@@ -24,6 +24,8 @@ class PagedArtistsModel(context: Context, private var showAll: Boolean = false):
showAll = show
}
override fun getAll() = medialibrary.getArtists(showAll, sort, desc)
override fun getPage(loadSize: Int, startposition: Int): Array<Artist> {
return if (filter == null) medialibrary.getPagedArtists(showAll, sort, desc, loadSize, startposition)
else medialibrary.searchArtist(filter, sort, desc, loadSize, startposition)
......
......@@ -25,6 +25,8 @@ class PagedGenresModel(context: Context): MLPagedModel<Genre>(context), Medialib
medialibrary.removeGenreCb(this)
}
override fun getAll() = medialibrary.getGenres(sort, desc)
override fun getPage(loadSize: Int, startposition: Int) = if (filter == null) medialibrary.getPagedGenres(sort, desc, loadSize, startposition)
else medialibrary.searchGenre(filter, sort, desc, loadSize, startposition)
......
......@@ -20,6 +20,8 @@ class PagedPlaylistsModel(context: Context): MLPagedModel<Playlist>(context), Me
override fun canSortByDuration() = true
override fun getAll() = medialibrary.getPlaylists(sort, desc)
override fun getPage(loadSize: Int, startposition: Int) = if (filter == null) medialibrary.getPagedPlaylists(sort, desc, loadSize, startposition)
else medialibrary.searchPlaylist(filter, sort, desc, loadSize, startposition)
......
......@@ -45,6 +45,8 @@ class PagedTracksModel(context: Context, val parent: MediaLibraryItem? = null):
refresh()
}
override fun getAll(): Array<MediaWrapper> = parent?.tracks ?: medialibrary.getAudio(sort, desc)
override fun getPage(loadSize: Int, startposition: Int) : Array<MediaWrapper> = if (filter == null) when(parent) {
is Artist -> parent.getPagedTracks(sort, desc, loadSize, startposition)
is Album -> parent.getPagedTracks(sort, desc, loadSize, startposition)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment