package com.cappielloantonio.play.viewmodel; import android.app.Application; import androidx.annotation.NonNull; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.model.Album; import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.repository.AlbumRepository; import com.cappielloantonio.play.repository.SongRepository; import java.util.ArrayList; import java.util.List; public class HomeViewModel extends AndroidViewModel { private static final String TAG = "HomeViewModel"; private SongRepository songRepository; private AlbumRepository albumRepository; private List dicoverSongSample = new ArrayList<>(); private LiveData> recentlyPlayedSongSample; private LiveData> recentlyAddedSongSample; private LiveData> mostPlayedSongSample; private LiveData> favoritesSongSample; private LiveData> downloadedSongSample; private List years; private LiveData> mostPlayedAlbumSample; private LiveData> recentlyAddedAlbumSample; private LiveData> recentlyPlayedAlbumSample; public HomeViewModel(@NonNull Application application) { super(application); songRepository = new SongRepository(application); albumRepository = new AlbumRepository(application); recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong(20); recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong(20); mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong(20); favoritesSongSample = songRepository.getListLiveFavoritesSampleSong(20); downloadedSongSample = songRepository.getListLiveDownloadedSampleSong(20); years = songRepository.getYearList(); mostPlayedAlbumSample = albumRepository.getListLiveAlbums("frequent", 20); recentlyAddedAlbumSample = albumRepository.getListLiveAlbums("newest", 20); recentlyPlayedAlbumSample = albumRepository.getListLiveAlbums("recent", 20); } public SongRepository getSongRepository() { return songRepository; } public LiveData> getRecentlyAddedSongList() { return recentlyAddedSongSample; } public LiveData> getRecentlyPlayedSongList() { return recentlyPlayedSongSample; } public LiveData> getMostPlayedSongList() { return mostPlayedSongSample; } public List getYearList() { return years; } public LiveData> getFavorites() { return favoritesSongSample; } public LiveData> getDownloaded() { return downloadedSongSample; } public LiveData> getMostPlayedAlbums() { return mostPlayedAlbumSample; } public LiveData> getMostRecentlyAddedAlbums() { return recentlyAddedAlbumSample; } public LiveData> getRecentlyPlayedAlbumList() { return recentlyPlayedAlbumSample; } }