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.model.Song;
|
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.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;
|
|
|
|
|
|
2020-11-22 19:11:38 +01:00
|
|
|
private List<Song> dicoverSongSample;
|
2020-11-21 18:41:35 +01:00
|
|
|
private LiveData<List<Song>> recentlyPlayedSongSample;
|
|
|
|
|
private LiveData<List<Song>> recentlyAddedSongSample;
|
|
|
|
|
private LiveData<List<Song>> mostPlayedSongSample;
|
|
|
|
|
|
|
|
|
|
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);
|
2020-11-20 15:38:08 +01:00
|
|
|
|
2020-11-22 19:11:38 +01:00
|
|
|
dicoverSongSample = songRepository.getRandomSample(5);
|
2020-11-21 18:41:35 +01:00
|
|
|
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong();
|
|
|
|
|
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong();
|
|
|
|
|
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong();
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-22 19:11:38 +01:00
|
|
|
public List<Song> getDiscoverSongList() {
|
2020-11-21 18:41:35 +01:00
|
|
|
return dicoverSongSample;
|
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
|
|
|
}
|
|
|
|
|
}
|