feat: clicking the song's title opens the album on player

This commit is contained in:
Albert Canales Ros 2024-06-08 23:02:59 +02:00
parent fb7296b467
commit 7c87ec2cbe
3 changed files with 37 additions and 0 deletions

View file

@ -156,6 +156,7 @@ public class PlayerBottomSheetFragment extends Fragment {
private void setMetadata(MediaMetadata mediaMetadata) {
if (mediaMetadata.extras != null) {
playerBottomSheetViewModel.setLiveMedia(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("id"));
playerBottomSheetViewModel.setLiveAlbum(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("albumId"));
playerBottomSheetViewModel.setLiveArtist(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("artistId"));
playerBottomSheetViewModel.setLiveDescription(mediaMetadata.extras.getString("description", null));

View file

@ -76,6 +76,7 @@ public class PlayerControllerFragment extends Fragment {
initQuickActionView();
initCoverLyricsSlideView();
initMediaListenable();
initMediaLabelButton();
initArtistLabelButton();
return view;
@ -299,6 +300,19 @@ public class PlayerControllerFragment extends Fragment {
});
}
private void initMediaLabelButton() {
playerBottomSheetViewModel.getLiveAlbum().observe(getViewLifecycleOwner(), album -> {
if (album != null) {
playerMediaTitleLabel.setOnClickListener(view -> {
Bundle bundle = new Bundle();
bundle.putParcelable(Constants.ALBUM_OBJECT, album);
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
activity.collapseBottomSheetDelayed();
});
}
});
}
private void initArtistLabelButton() {
playerBottomSheetViewModel.getLiveArtist().observe(getViewLifecycleOwner(), artist -> {
if (artist != null) {