Check if children exist before adding

This commit is contained in:
Reinhard Prechtl 2023-08-22 13:09:30 +02:00
parent 9784a2b6c5
commit 41b5c57240
No known key found for this signature in database
GPG key ID: C8C9457DF795C096

View file

@ -73,9 +73,11 @@ public class SongListPageViewModel extends AndroidViewModel {
case Constants.MEDIA_BY_GENRE:
int page = (songList.getValue() != null ? songList.getValue().size() : 0) / 100;
songRepository.getSongsByGenre(genre.getGenre(), page).observe(owner, children -> {
List<Child> currentMedia = songList.getValue();
currentMedia.addAll(children);
songList.setValue(currentMedia);
if(children != null && !children.isEmpty()) {
List<Child> currentMedia = songList.getValue();
currentMedia.addAll(children);
songList.setValue(currentMedia);
}
});
break;
case Constants.MEDIA_BY_ARTIST: