tempus/app/src/main/java/com/cappielloantonio/play/viewmodel/HomeViewModel.java

93 lines
3.1 KiB
Java
Raw Normal View History

2020-11-20 15:38:08 +01:00
package com.cappielloantonio.play.viewmodel;
2020-11-21 18:41:35 +01:00
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
2020-11-20 15:38:08 +01:00
import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Album;
2020-11-20 15:38:08 +01:00
import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.AlbumRepository;
2020-11-21 18:41:35 +01:00
import com.cappielloantonio.play.repository.SongRepository;
2020-11-20 15:38:08 +01:00
import java.util.ArrayList;
2020-11-20 15:38:08 +01:00
import java.util.List;
2020-11-21 18:41:35 +01:00
public class HomeViewModel extends AndroidViewModel {
2020-11-22 19:11:38 +01:00
private static final String TAG = "HomeViewModel";
2020-11-21 18:41:35 +01:00
private SongRepository songRepository;
private AlbumRepository albumRepository;
2020-11-21 18:41:35 +01:00
private List<Song> dicoverSongSample = new ArrayList<>();
2020-11-21 18:41:35 +01:00
private LiveData<List<Song>> recentlyPlayedSongSample;
private LiveData<List<Song>> recentlyAddedSongSample;
private LiveData<List<Song>> mostPlayedSongSample;
2020-11-30 20:54:05 +01:00
private LiveData<List<Song>> favoritesSongSample;
2021-04-26 19:37:05 +02:00
private LiveData<List<Song>> downloadedSongSample;
2020-11-28 14:50:15 +01:00
private List<Integer> years;
2020-11-21 18:41:35 +01:00
private LiveData<List<Album>> mostPlayedAlbumSample;
private LiveData<List<Album>> recentlyAddedAlbumSample;
private LiveData<List<Album>> recentlyPlayedAlbumSample;
2020-11-21 18:41:35 +01:00
public HomeViewModel(@NonNull Application application) {
super(application);
2020-11-20 15:38:08 +01:00
2020-11-21 18:41:35 +01:00
songRepository = new SongRepository(application);
albumRepository = new AlbumRepository(application);
2020-11-20 15:38:08 +01:00
2020-11-24 10:52:00 +01:00
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong(20);
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong(20);
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong(20);
2020-11-30 20:54:05 +01:00
favoritesSongSample = songRepository.getListLiveFavoritesSampleSong(20);
2021-04-26 19:37:05 +02:00
downloadedSongSample = songRepository.getListLiveDownloadedSampleSong(20);
2020-11-28 14:50:15 +01:00
years = songRepository.getYearList();
2020-11-20 15:38:08 +01:00
mostPlayedAlbumSample = albumRepository.getListLiveAlbums("frequent", 20);
recentlyAddedAlbumSample = albumRepository.getListLiveAlbums("newest", 20);
recentlyPlayedAlbumSample = albumRepository.getListLiveAlbums("recent", 20);
}
2020-11-24 10:52:00 +01:00
public SongRepository getSongRepository() {
return songRepository;
2020-11-20 15:38:08 +01:00
}
2020-11-21 18:41:35 +01:00
public LiveData<List<Song>> getRecentlyAddedSongList() {
return recentlyAddedSongSample;
}
public LiveData<List<Song>> getRecentlyPlayedSongList() {
return recentlyPlayedSongSample;
}
2020-11-20 15:38:08 +01:00
2020-11-21 18:41:35 +01:00
public LiveData<List<Song>> getMostPlayedSongList() {
return mostPlayedSongSample;
2020-11-20 15:38:08 +01:00
}
2020-11-28 14:50:15 +01:00
public List<Integer> getYearList() {
return years;
}
2020-11-30 20:54:05 +01:00
public LiveData<List<Song>> getFavorites() {
return favoritesSongSample;
}
2021-04-26 19:37:05 +02:00
public LiveData<List<Song>> getDownloaded() {
return downloadedSongSample;
}
public LiveData<List<Album>> getMostPlayedAlbums() {
return mostPlayedAlbumSample;
}
public LiveData<List<Album>> getMostRecentlyAddedAlbums() {
return recentlyAddedAlbumSample;
}
public LiveData<List<Album>> getRecentlyPlayedAlbumList() {
return recentlyPlayedAlbumSample;
}
2020-11-20 15:38:08 +01:00
}