mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Add catalogues
This commit is contained in:
parent
8c889f7a38
commit
8b7e383dc2
45 changed files with 1084 additions and 136 deletions
|
|
@ -0,0 +1,32 @@
|
|||
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.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlbumCatalogueViewModel extends AndroidViewModel {
|
||||
private AlbumRepository albumRepository;
|
||||
|
||||
private LiveData<List<Album>> albumList;
|
||||
|
||||
public AlbumCatalogueViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
albumRepository = new AlbumRepository(application);
|
||||
|
||||
albumList = albumRepository.getListLiveAlbums();
|
||||
}
|
||||
|
||||
public LiveData<List<Album>> getAlbumList() {
|
||||
return albumList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
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.model.Artist;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArtistCatalogueViewModel extends AndroidViewModel {
|
||||
private ArtistRepository artistRepository;
|
||||
|
||||
private LiveData<List<Artist>> artistList;
|
||||
|
||||
public ArtistCatalogueViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
artistRepository = new ArtistRepository(application);
|
||||
|
||||
artistList = artistRepository.getListLiveArtists();
|
||||
}
|
||||
|
||||
public LiveData<List<Artist>> getArtistList() {
|
||||
return artistList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
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.model.Genre;
|
||||
import com.cappielloantonio.play.model.RecentSearch;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
import com.cappielloantonio.play.repository.RecentSearchRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FilterViewModel extends AndroidViewModel {
|
||||
private GenreRepository genreRepository;
|
||||
|
||||
private LiveData<List<Genre>> allGenres;
|
||||
|
||||
public FilterViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
genreRepository = new GenreRepository(application);
|
||||
}
|
||||
|
||||
public LiveData<List<Genre>> getGenreList() {
|
||||
allGenres = genreRepository.getListLiveGenres();
|
||||
return allGenres;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
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.model.Artist;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GenreCatalogueViewModel extends AndroidViewModel {
|
||||
private GenreRepository genreRepository;
|
||||
|
||||
private LiveData<List<Genre>> genreList;
|
||||
|
||||
public GenreCatalogueViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
genreRepository = new GenreRepository(application);
|
||||
|
||||
genreList = genreRepository.getListLiveGenres();
|
||||
}
|
||||
|
||||
public LiveData<List<Genre>> getGenreList() {
|
||||
return genreList;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,51 @@
|
|||
package com.cappielloantonio.play.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeViewModel extends ViewModel {
|
||||
public class HomeViewModel extends AndroidViewModel {
|
||||
private SongRepository songRepository;
|
||||
|
||||
public List<Song> getDiscoverSongList() {
|
||||
List<Song> discover_songs = new ArrayList<>();
|
||||
discover_songs.add(new Song("Holiday", "American Idiot"));
|
||||
discover_songs.add(new Song("Brioschi", "Stanza Singola"));
|
||||
discover_songs.add(new Song("HappySad", "Ceri Singles"));
|
||||
discover_songs.add(new Song("Falling back to Earth", "Haken"));
|
||||
private LiveData<List<Song>> dicoverSongSample;
|
||||
private LiveData<List<Song>> recentlyPlayedSongSample;
|
||||
private LiveData<List<Song>> recentlyAddedSongSample;
|
||||
private LiveData<List<Song>> mostPlayedSongSample;
|
||||
|
||||
return discover_songs;
|
||||
public HomeViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
songRepository = new SongRepository(application);
|
||||
|
||||
dicoverSongSample = songRepository.getListLiveDiscoverSampleSong();
|
||||
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong();
|
||||
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong();
|
||||
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong();
|
||||
}
|
||||
|
||||
public List<Song> getRecentSongList() {
|
||||
List<Song> recent_songs = new ArrayList<>();
|
||||
recent_songs.add(new Song("Holiday", "American Idiot"));
|
||||
recent_songs.add(new Song("Brioschi", "Stanza Singola"));
|
||||
recent_songs.add(new Song("HappySad", "Ceri Singles"));
|
||||
recent_songs.add(new Song("Falling back to Earth", "Haken"));
|
||||
|
||||
return recent_songs;
|
||||
public LiveData<List<Song>> getDiscoverSongList() {
|
||||
return dicoverSongSample;
|
||||
}
|
||||
|
||||
public List<Song> getMostPlayedSongList() {
|
||||
List<Song> most_played_songs = new ArrayList<>();
|
||||
most_played_songs.add(new Song("Holiday", "American Idiot"));
|
||||
most_played_songs.add(new Song("Brioschi", "Stanza Singola"));
|
||||
most_played_songs.add(new Song("HappySad", "Ceri Singles"));
|
||||
most_played_songs.add(new Song("Falling back to Earth", "Haken"));
|
||||
public LiveData<List<Song>> getRecentlyAddedSongList() {
|
||||
return recentlyAddedSongSample;
|
||||
}
|
||||
|
||||
return most_played_songs;
|
||||
public LiveData<List<Song>> getRecentlyPlayedSongList() {
|
||||
return recentlyPlayedSongSample;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getMostPlayedSongList() {
|
||||
return mostPlayedSongSample;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,54 +10,53 @@ import com.cappielloantonio.play.model.Album;
|
|||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryViewModel extends AndroidViewModel {
|
||||
private AlbumRepository albumRepository;
|
||||
private ArtistRepository artistRepository;
|
||||
private GenreRepository genreRepository;
|
||||
|
||||
private LiveData<List<Album>> sampleAlbum;
|
||||
private LiveData<List<Artist>> sampleArtist;
|
||||
private LiveData<List<Genre>> sampleGenres;
|
||||
|
||||
private LiveData<List<Genre>> allGenres;
|
||||
|
||||
public LibraryViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
albumRepository = new AlbumRepository(application);
|
||||
artistRepository = new ArtistRepository(application);
|
||||
genreRepository = new GenreRepository(application);
|
||||
allGenres = genreRepository.getListLiveGenres();
|
||||
|
||||
// Inizializzate all'interno del costruttore, in modo da rimanere immutabili per tutto il
|
||||
// ciclo di vita dell'applicazione
|
||||
sampleAlbum = albumRepository.getListLiveSampleAlbum();
|
||||
sampleArtist = artistRepository.getListLiveSampleArtist();
|
||||
sampleGenres = genreRepository.getListLiveSampleGenre();
|
||||
}
|
||||
|
||||
public LiveData<List<Genre>> getGenreList() {
|
||||
allGenres = genreRepository.getListLiveGenres();
|
||||
return allGenres;
|
||||
}
|
||||
|
||||
public ArrayList<Album> getAlbumSample() {
|
||||
ArrayList<Album> albums = new ArrayList<>();
|
||||
albums.add(new Album("1", "aaaa", 1, "1", "qqqq", "", ""));
|
||||
albums.add(new Album("2", "ssss", 1, "2", "wwww", "", ""));
|
||||
albums.add(new Album("3", "dddd", 1, "3", "eeee", "", ""));
|
||||
albums.add(new Album("4", "ffff", 1, "4", "rrrr", "", ""));
|
||||
albums.add(new Album("5", "gggg", 1, "5", "tttt", "", ""));
|
||||
albums.add(new Album("6", "hhhh", 1, "6", "yyyy", "", ""));
|
||||
albums.add(new Album("7", "jjjj", 1, "7", "uuuu", "", ""));
|
||||
albums.add(new Album("8", "kkkk", 1, "8", "iiii", "", ""));
|
||||
albums.add(new Album("9", "llll", 1, "9", "oooo", "", ""));
|
||||
|
||||
return albums;
|
||||
public LiveData<List<Album>> getAlbumSample() {
|
||||
return sampleAlbum;
|
||||
}
|
||||
|
||||
public ArrayList<Artist> getArtistSample() {
|
||||
ArrayList<Artist> artists = new ArrayList<>();
|
||||
artists.add(new Artist("1", "dhgr", "", ""));
|
||||
artists.add(new Artist("2", "kdnu", "", ""));
|
||||
artists.add(new Artist("3", "wfty", "", ""));
|
||||
artists.add(new Artist("4", "hfds", "", ""));
|
||||
artists.add(new Artist("5", "jgab", "", ""));
|
||||
artists.add(new Artist("6", "iudg", "", ""));
|
||||
artists.add(new Artist("7", "istr", "", ""));
|
||||
artists.add(new Artist("8", "dger", "", ""));
|
||||
artists.add(new Artist("9", "jhjk", "", ""));
|
||||
public LiveData<List<Artist>> getArtistSample() {
|
||||
return sampleArtist;
|
||||
}
|
||||
|
||||
return artists;
|
||||
public LiveData<List<Genre>> getGenreSample() {
|
||||
return sampleGenres;
|
||||
}
|
||||
|
||||
public ArrayList<Playlist> getPlaylist() {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
}
|
||||
|
||||
public LiveData<List<Song>> searchSong(String title) {
|
||||
searchSong = songRepository.searchListLiveSongs(title);
|
||||
searchSong = songRepository.searchListLiveSong(title);
|
||||
return searchSong;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
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.model.Song;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SongViewModel extends AndroidViewModel {
|
||||
private SongRepository repository;
|
||||
private LiveData<List<Song>> allSongs;
|
||||
|
||||
public SongViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
repository = new SongRepository(application);
|
||||
allSongs = repository.getListLiveSongs();
|
||||
}
|
||||
|
||||
public boolean exist(Song song) {
|
||||
return repository.exist(song);
|
||||
}
|
||||
|
||||
public void insert(Song song) {
|
||||
repository.insert(song);
|
||||
}
|
||||
|
||||
public void delete(Song song) {
|
||||
repository.delete(song);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getAllSongs() {
|
||||
return allSongs;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue