Check the number of songs present before performing the action

This commit is contained in:
CappielloAntonio 2021-08-31 13:12:48 +02:00
parent 8cef75c763
commit b6082cdb16
2 changed files with 8 additions and 1 deletions

View file

@ -144,7 +144,7 @@ public class AlbumPageFragment extends Fragment {
private void initMusicButton() {
albumPageViewModel.getAlbumSongLiveList().observe(requireActivity(), songs -> {
if (bind != null) {
if (bind != null && !songs.isEmpty()) {
bind.albumPagePlayButton.setOnClickListener(v -> {
QueueRepository queueRepository = new QueueRepository(App.getInstance());
queueRepository.insertAllAndStartNew(songs);
@ -167,6 +167,11 @@ public class AlbumPageFragment extends Fragment {
MusicPlayerRemote.openQueue(songs, 0, true);
});
}
if(bind != null && songs.isEmpty()) {
bind.albumPagePlayButton.setEnabled(false);
bind.albumPageShuffleButton.setEnabled(false);
}
});
}

View file

@ -145,6 +145,8 @@ public class ArtistPageFragment extends Fragment {
MusicPlayerRemote.openQueue(songs, 0, true);
activity.isBottomSheetInPeek(true);
} else {
Toast.makeText(requireContext(), "Error retrieving artist's songs", Toast.LENGTH_SHORT).show();
}
});
});