Order pinned playlists in playlist catalogue

This commit is contained in:
CappielloAntonio 2021-11-26 11:22:25 +01:00
parent e29b96d905
commit e2f1212e58
4 changed files with 59 additions and 6 deletions

View file

@ -23,6 +23,7 @@ public class PlaylistCatalogueViewModel extends AndroidViewModel {
private String type;
private MutableLiveData<List<Playlist>> playlistList;
private MutableLiveData<List<Playlist>> pinnedPlaylistList;
public PlaylistCatalogueViewModel(@NonNull Application application) {
super(application);
@ -48,6 +49,20 @@ public class PlaylistCatalogueViewModel extends AndroidViewModel {
return playlistList;
}
public LiveData<List<Playlist>> getPinnedPlaylistList(FragmentActivity activity) {
pinnedPlaylistList = new MutableLiveData<>(new ArrayList<>());
playlistRepository.getPinnedPlaylists().observe(activity, playlists -> pinnedPlaylistList.postValue(playlists));
return pinnedPlaylistList;
}
public void unpinPlaylist(List<Playlist> playlists) {
if(type.equals(Playlist.ALL)) {
for(Playlist playlist: playlists) {
playlistRepository.delete(playlist);
}
}
}
public void setType(String type) {
this.type = type;
}