mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-01-30 06:12:07 +00:00
Merge pull request #251 from albertcanales/main
feat: open album when clicking the song's title on player
This commit is contained in:
@@ -156,6 +156,7 @@ public class PlayerBottomSheetFragment extends Fragment {
|
|||||||
private void setMetadata(MediaMetadata mediaMetadata) {
|
private void setMetadata(MediaMetadata mediaMetadata) {
|
||||||
if (mediaMetadata.extras != null) {
|
if (mediaMetadata.extras != null) {
|
||||||
playerBottomSheetViewModel.setLiveMedia(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("id"));
|
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.setLiveArtist(getViewLifecycleOwner(), mediaMetadata.extras.getString("type"), mediaMetadata.extras.getString("artistId"));
|
||||||
playerBottomSheetViewModel.setLiveDescription(mediaMetadata.extras.getString("description", null));
|
playerBottomSheetViewModel.setLiveDescription(mediaMetadata.extras.getString("description", null));
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class PlayerControllerFragment extends Fragment {
|
|||||||
initQuickActionView();
|
initQuickActionView();
|
||||||
initCoverLyricsSlideView();
|
initCoverLyricsSlideView();
|
||||||
initMediaListenable();
|
initMediaListenable();
|
||||||
|
initMediaLabelButton();
|
||||||
initArtistLabelButton();
|
initArtistLabelButton();
|
||||||
|
|
||||||
return view;
|
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() {
|
private void initArtistLabelButton() {
|
||||||
playerBottomSheetViewModel.getLiveArtist().observe(getViewLifecycleOwner(), artist -> {
|
playerBottomSheetViewModel.getLiveArtist().observe(getViewLifecycleOwner(), artist -> {
|
||||||
if (artist != null) {
|
if (artist != null) {
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import androidx.media3.common.util.UnstableApi;
|
|||||||
import com.cappielloantonio.tempo.interfaces.StarCallback;
|
import com.cappielloantonio.tempo.interfaces.StarCallback;
|
||||||
import com.cappielloantonio.tempo.model.Download;
|
import com.cappielloantonio.tempo.model.Download;
|
||||||
import com.cappielloantonio.tempo.model.Queue;
|
import com.cappielloantonio.tempo.model.Queue;
|
||||||
|
import com.cappielloantonio.tempo.repository.AlbumRepository;
|
||||||
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
||||||
import com.cappielloantonio.tempo.repository.FavoriteRepository;
|
import com.cappielloantonio.tempo.repository.FavoriteRepository;
|
||||||
import com.cappielloantonio.tempo.repository.OpenRepository;
|
import com.cappielloantonio.tempo.repository.OpenRepository;
|
||||||
import com.cappielloantonio.tempo.repository.QueueRepository;
|
import com.cappielloantonio.tempo.repository.QueueRepository;
|
||||||
import com.cappielloantonio.tempo.repository.SongRepository;
|
import com.cappielloantonio.tempo.repository.SongRepository;
|
||||||
|
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.LyricsList;
|
import com.cappielloantonio.tempo.subsonic.models.LyricsList;
|
||||||
@@ -40,6 +42,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||||||
private static final String TAG = "PlayerBottomSheetViewModel";
|
private static final String TAG = "PlayerBottomSheetViewModel";
|
||||||
|
|
||||||
private final SongRepository songRepository;
|
private final SongRepository songRepository;
|
||||||
|
private final AlbumRepository albumRepository;
|
||||||
private final ArtistRepository artistRepository;
|
private final ArtistRepository artistRepository;
|
||||||
private final QueueRepository queueRepository;
|
private final QueueRepository queueRepository;
|
||||||
private final FavoriteRepository favoriteRepository;
|
private final FavoriteRepository favoriteRepository;
|
||||||
@@ -48,6 +51,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||||||
private final MutableLiveData<LyricsList> lyricsListLiveData = new MutableLiveData<>(null);
|
private final MutableLiveData<LyricsList> lyricsListLiveData = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<String> descriptionLiveData = new MutableLiveData<>(null);
|
private final MutableLiveData<String> descriptionLiveData = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<Child> liveMedia = new MutableLiveData<>(null);
|
private final MutableLiveData<Child> liveMedia = new MutableLiveData<>(null);
|
||||||
|
private final MutableLiveData<AlbumID3> liveAlbum = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<ArtistID3> liveArtist = new MutableLiveData<>(null);
|
private final MutableLiveData<ArtistID3> liveArtist = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<List<Child>> instantMix = new MutableLiveData<>(null);
|
private final MutableLiveData<List<Child>> instantMix = new MutableLiveData<>(null);
|
||||||
private boolean lyricsSyncState = true;
|
private boolean lyricsSyncState = true;
|
||||||
@@ -57,6 +61,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||||||
super(application);
|
super(application);
|
||||||
|
|
||||||
songRepository = new SongRepository();
|
songRepository = new SongRepository();
|
||||||
|
albumRepository = new AlbumRepository();
|
||||||
artistRepository = new ArtistRepository();
|
artistRepository = new ArtistRepository();
|
||||||
queueRepository = new QueueRepository();
|
queueRepository = new QueueRepository();
|
||||||
favoriteRepository = new FavoriteRepository();
|
favoriteRepository = new FavoriteRepository();
|
||||||
@@ -162,6 +167,23 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<AlbumID3> getLiveAlbum() {
|
||||||
|
return liveAlbum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLiveAlbum(LifecycleOwner owner, String mediaType, String AlbumId) {
|
||||||
|
if (mediaType != null) {
|
||||||
|
switch (mediaType) {
|
||||||
|
case Constants.MEDIA_TYPE_MUSIC:
|
||||||
|
albumRepository.getAlbum(AlbumId).observe(owner, liveAlbum::postValue);
|
||||||
|
break;
|
||||||
|
case Constants.MEDIA_TYPE_PODCAST:
|
||||||
|
liveAlbum.postValue(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public LiveData<ArtistID3> getLiveArtist() {
|
public LiveData<ArtistID3> getLiveArtist() {
|
||||||
return liveArtist;
|
return liveArtist;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user