mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Add Made for you section in home
This commit is contained in:
parent
ec7f9d3002
commit
c2782d7e49
7 changed files with 218 additions and 17 deletions
|
|
@ -28,6 +28,8 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
private final DownloadRepository downloadRepository;
|
||||
|
||||
private final MutableLiveData<List<Song>> dicoverSongSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Song>> starredTracksSample = new MutableLiveData<>(null);
|
||||
|
||||
private final MutableLiveData<List<Album>> mostPlayedAlbumSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Album>> recentlyPlayedAlbumSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Integer>> years = new MutableLiveData<>(null);
|
||||
|
|
@ -46,19 +48,24 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
downloadRepository = new DownloadRepository(application);
|
||||
|
||||
songRepository.getRandomSample(10, null, null).observeForever(dicoverSongSample::postValue);
|
||||
songRepository.getStarredSongs(true, 10).observeForever(starredTracksSample::postValue);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getDiscoverSongSample() {
|
||||
return dicoverSongSample;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getStarredTracksSample() {
|
||||
return starredTracksSample;
|
||||
}
|
||||
|
||||
public LiveData<List<Integer>> getYearList(LifecycleOwner owner) {
|
||||
albumRepository.getDecades().observe(owner, years::postValue);
|
||||
return years;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getStarredTracks(LifecycleOwner owner) {
|
||||
songRepository.getStarredSongs().observe(owner, starredTracks::postValue);
|
||||
songRepository.getStarredSongs(false, -1).observe(owner, starredTracks::postValue);
|
||||
return starredTracks;
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +103,12 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
songRepository.getRandomSample(10, null, null).observe(owner, dicoverSongSample::postValue);
|
||||
}
|
||||
|
||||
public void refreshSimilarSongSample(LifecycleOwner owner) {
|
||||
songRepository.getStarredSongs(true, 10).observe(owner, starredTracksSample::postValue);
|
||||
}
|
||||
|
||||
public void refreshStarredTracks(LifecycleOwner owner) {
|
||||
songRepository.getStarredSongs().observe(owner, starredTracks::postValue);
|
||||
songRepository.getStarredSongs(false, -1).observe(owner, starredTracks::postValue);
|
||||
}
|
||||
|
||||
public void refreshStarredAlbums(LifecycleOwner owner) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
songList = songRepository.getRandomSample(500, year, year + 10);
|
||||
break;
|
||||
case Song.STARRED:
|
||||
songList = songRepository.getStarredSongs();
|
||||
songList = songRepository.getStarredSongs(false, -1);
|
||||
break;
|
||||
case Song.DOWNLOADED:
|
||||
songList.setValue(MappingUtil.mapDownload(downloadRepository.getLiveDownload()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue