2023-06-17 15:30:23 +02:00
|
|
|
package com.cappielloantonio.tempo.viewmodel;
|
2020-11-23 09:28:20 +01:00
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.lifecycle.AndroidViewModel;
|
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
|
|
|
2023-06-17 15:30:23 +02:00
|
|
|
import com.cappielloantonio.tempo.repository.AlbumRepository;
|
|
|
|
|
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
|
|
|
|
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
2024-03-16 15:50:06 +01:00
|
|
|
import com.cappielloantonio.tempo.subsonic.models.AlbumInfo;
|
2023-06-17 15:30:23 +02:00
|
|
|
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
|
|
|
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
2020-11-23 09:28:20 +01:00
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class AlbumPageViewModel extends AndroidViewModel {
|
2021-09-02 14:12:13 +02:00
|
|
|
private final AlbumRepository albumRepository;
|
|
|
|
|
private final ArtistRepository artistRepository;
|
2020-11-23 09:28:20 +01:00
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
private AlbumID3 album;
|
2020-11-23 09:28:20 +01:00
|
|
|
|
|
|
|
|
public AlbumPageViewModel(@NonNull Application application) {
|
|
|
|
|
super(application);
|
|
|
|
|
|
2023-03-10 15:21:02 +01:00
|
|
|
albumRepository = new AlbumRepository();
|
|
|
|
|
artistRepository = new ArtistRepository();
|
2020-11-23 09:28:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-10 16:20:33 +01:00
|
|
|
public LiveData<List<Child>> getAlbumSongLiveList() {
|
|
|
|
|
return albumRepository.getAlbumTracks(album.getId());
|
2021-04-26 19:50:23 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
public AlbumID3 getAlbum() {
|
2020-11-23 09:28:20 +01:00
|
|
|
return album;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
public void setAlbum(AlbumID3 album) {
|
2020-11-23 09:28:20 +01:00
|
|
|
this.album = album;
|
|
|
|
|
}
|
2021-05-01 17:11:09 +02:00
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
public LiveData<ArtistID3> getArtist() {
|
2021-07-30 14:09:50 +02:00
|
|
|
return artistRepository.getArtistInfo(album.getArtistId());
|
2021-05-01 17:11:09 +02:00
|
|
|
}
|
2024-03-16 15:50:06 +01:00
|
|
|
|
|
|
|
|
public LiveData<AlbumInfo> getAlbumInfo() {
|
|
|
|
|
return albumRepository.getAlbumInfo(album.getId());
|
|
|
|
|
}
|
2020-11-23 09:28:20 +01:00
|
|
|
}
|