feat: added podcast description to the right page of the player

This commit is contained in:
antonio 2023-10-12 22:57:38 +02:00
parent c20cadff94
commit 67905affd3
4 changed files with 30 additions and 11 deletions

View file

@ -157,6 +157,7 @@ public class PlayerBottomSheetFragment extends Fragment {
if (mediaMetadata.extras != null) {
playerBottomSheetViewModel.setLiveMedia(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("id"));
playerBottomSheetViewModel.setLiveArtist(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("artistId"));
playerBottomSheetViewModel.setLiveDescription(mediaMetadata.extras.getString("description", null));
bind.playerHeaderLayout.playerHeaderMediaTitleLabel.setText(MusicUtil.getReadableString(mediaMetadata.extras.getString("title")));
bind.playerHeaderLayout.playerHeaderMediaArtistLabel.setText(MusicUtil.getReadableString(mediaMetadata.extras.getString("artist")));

View file

@ -44,18 +44,25 @@ public class PlayerLyricsFragment extends Fragment {
private void initLyrics() {
playerBottomSheetViewModel.getLiveLyrics().observe(getViewLifecycleOwner(), lyrics -> {
playerBottomSheetViewModel.getLiveDescription().observe(getViewLifecycleOwner(), description -> {
if (bind != null) {
if (lyrics == null || lyrics.trim().equals("")) {
bind.nowPlayingSongLyricsTextView.setVisibility(View.GONE);
bind.emptyDescriptionImageView.setVisibility(View.VISIBLE);
bind.titleEmptyDescriptionLabel.setVisibility(View.VISIBLE);
} else {
if (lyrics != null && !lyrics.trim().equals("")) {
bind.nowPlayingSongLyricsTextView.setText(MusicUtil.getReadableLyrics(lyrics));
bind.nowPlayingSongLyricsTextView.setVisibility(View.VISIBLE);
bind.emptyDescriptionImageView.setVisibility(View.GONE);
bind.titleEmptyDescriptionLabel.setVisibility(View.GONE);
} else if (description != null && !description.trim().equals("")) {
bind.nowPlayingSongLyricsTextView.setText(MusicUtil.getReadableLyrics(description));
bind.nowPlayingSongLyricsTextView.setVisibility(View.VISIBLE);
bind.emptyDescriptionImageView.setVisibility(View.GONE);
bind.titleEmptyDescriptionLabel.setVisibility(View.GONE);
} else {
bind.nowPlayingSongLyricsTextView.setVisibility(View.GONE);
bind.emptyDescriptionImageView.setVisibility(View.VISIBLE);
bind.titleEmptyDescriptionLabel.setVisibility(View.VISIBLE);
}
}
});
});
}
}

View file

@ -179,6 +179,7 @@ public class MappingUtil {
bundle.putBoolean("isVideo", podcastEpisode.isVideo());
bundle.putLong("created", podcastEpisode.getCreated() != null ? podcastEpisode.getCreated().getTime() : 0);
bundle.putString("artistId", podcastEpisode.getArtistId());
bundle.putString("description", podcastEpisode.getDescription());
bundle.putString("type", Constants.MEDIA_TYPE_PODCAST);
bundle.putString("uri", uri.toString());

View file

@ -42,6 +42,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
private final FavoriteRepository favoriteRepository;
private final MutableLiveData<String> lyricsLiveData = new MutableLiveData<>(null);
private final MutableLiveData<String> descriptionLiveData = new MutableLiveData<>(null);
private final MutableLiveData<Child> liveMedia = new MutableLiveData<>(null);
private final MutableLiveData<ArtistID3> liveArtist = new MutableLiveData<>(null);
@ -137,6 +138,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
switch (mediaType) {
case Constants.MEDIA_TYPE_MUSIC:
songRepository.getSong(mediaId).observe(owner, liveMedia::postValue);
descriptionLiveData.postValue(null);
break;
case Constants.MEDIA_TYPE_PODCAST:
liveMedia.postValue(null);
@ -162,6 +164,14 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
}
}
public void setLiveDescription(String description) {
descriptionLiveData.postValue(description);
}
public LiveData<String> getLiveDescription() {
return descriptionLiveData;
}
public LiveData<List<Child>> getMediaInstantMix(LifecycleOwner owner, Child media) {
instantMix.setValue(Collections.emptyList());