mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
project upload
This commit is contained in:
parent
e1749a3123
commit
6eff64e7e1
105 changed files with 5907 additions and 0 deletions
|
|
@ -0,0 +1,127 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.AlbumDao;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AlbumRepository {
|
||||
private AlbumDao albumDao;
|
||||
private LiveData<List<Album>> listLiveAlbums;
|
||||
|
||||
public AlbumRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
albumDao = database.albumDao();
|
||||
listLiveAlbums = albumDao.getAll();
|
||||
}
|
||||
|
||||
public LiveData<List<Album>> getListLiveAlbums() {
|
||||
return listLiveAlbums;
|
||||
}
|
||||
|
||||
public boolean exist(Album album) {
|
||||
boolean exist = false;
|
||||
|
||||
ExistThreadSafe existThread = new ExistThreadSafe(albumDao, album);
|
||||
Thread thread = new Thread(existThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
exist = existThread.exist();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
public void insert(Album album) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(albumDao, album);
|
||||
Thread thread = new Thread(insert);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void insertAll(ArrayList<Album> albums) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(albumDao, albums);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void delete(Album album) {
|
||||
DeleteThreadSafe delete = new DeleteThreadSafe(albumDao, album);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class ExistThreadSafe implements Runnable {
|
||||
private AlbumDao albumDao;
|
||||
private Album album;
|
||||
private boolean exist = false;
|
||||
|
||||
public ExistThreadSafe(AlbumDao albumDao, Album album) {
|
||||
this.albumDao = albumDao;
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
exist = albumDao.exist(album.getId());
|
||||
}
|
||||
|
||||
public boolean exist() {
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertThreadSafe implements Runnable {
|
||||
private AlbumDao albumDao;
|
||||
private Album album;
|
||||
|
||||
public InsertThreadSafe(AlbumDao albumDao, Album album) {
|
||||
this.albumDao = albumDao;
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
albumDao.insert(album);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private AlbumDao albumDao;
|
||||
private ArrayList<Album> albums;
|
||||
|
||||
public InsertAllThreadSafe(AlbumDao albumDao, ArrayList<Album> albums) {
|
||||
this.albumDao = albumDao;
|
||||
this.albums = albums;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
albumDao.insertAll(albums);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteThreadSafe implements Runnable {
|
||||
private AlbumDao albumDao;
|
||||
private Album album;
|
||||
|
||||
public DeleteThreadSafe(AlbumDao albumDao, Album album) {
|
||||
this.albumDao = albumDao;
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
albumDao.delete(album);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.ArtistDao;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ArtistRepository {
|
||||
private ArtistDao artistDao;
|
||||
private LiveData<List<Artist>> listLiveArtists;
|
||||
|
||||
public ArtistRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
artistDao = database.artistDao();
|
||||
listLiveArtists = artistDao.getAll();
|
||||
}
|
||||
|
||||
public LiveData<List<Artist>> getListLiveArtists() {
|
||||
return listLiveArtists;
|
||||
}
|
||||
|
||||
public boolean exist(Artist artist) {
|
||||
boolean exist = false;
|
||||
|
||||
ExistThreadSafe existThread = new ExistThreadSafe(artistDao, artist);
|
||||
Thread thread = new Thread(existThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
exist = existThread.exist();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
public void insert(Artist artist) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(artistDao, artist);
|
||||
Thread thread = new Thread(insert);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void insertAll(ArrayList<Artist> artists) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(artistDao, artists);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void delete(Artist artist) {
|
||||
DeleteThreadSafe delete = new DeleteThreadSafe(artistDao, artist);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class ExistThreadSafe implements Runnable {
|
||||
private ArtistDao artistDao;
|
||||
private Artist artist;
|
||||
private boolean exist = false;
|
||||
|
||||
public ExistThreadSafe(ArtistDao artistDao, Artist artist) {
|
||||
this.artistDao = artistDao;
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
exist = artistDao.exist(artist.getId());
|
||||
}
|
||||
|
||||
public boolean exist() {
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertThreadSafe implements Runnable {
|
||||
private ArtistDao artistDao;
|
||||
private Artist artist;
|
||||
|
||||
public InsertThreadSafe(ArtistDao artistDao, Artist artist) {
|
||||
this.artistDao = artistDao;
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
artistDao.insert(artist);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private ArtistDao artistDao;
|
||||
private ArrayList<Artist> artists;
|
||||
|
||||
public InsertAllThreadSafe(ArtistDao artistDao, ArrayList<Artist> artists) {
|
||||
this.artistDao = artistDao;
|
||||
this.artists = artists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
artistDao.insertAll(artists);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteThreadSafe implements Runnable {
|
||||
private ArtistDao artistDao;
|
||||
private Artist artist;
|
||||
|
||||
public DeleteThreadSafe(ArtistDao artistDao, Artist artist) {
|
||||
this.artistDao = artistDao;
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
artistDao.delete(artist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.GenreDao;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenreRepository {
|
||||
private GenreDao genreDao;
|
||||
private LiveData<List<Genre>> listLiveGenres;
|
||||
|
||||
public GenreRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
genreDao = database.genreDao();
|
||||
listLiveGenres = genreDao.getAll();
|
||||
}
|
||||
|
||||
public LiveData<List<Genre>> getListLiveGenres() {
|
||||
return listLiveGenres;
|
||||
}
|
||||
|
||||
public boolean exist(Genre genre) {
|
||||
boolean exist = false;
|
||||
|
||||
ExistThreadSafe existThread = new ExistThreadSafe(genreDao, genre);
|
||||
Thread thread = new Thread(existThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
exist = existThread.exist();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
public void insert(Genre genre) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(genreDao, genre);
|
||||
Thread thread = new Thread(insert);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void insertAll(ArrayList<Genre> genres) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(genreDao, genres);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void delete(Genre genre) {
|
||||
DeleteThreadSafe delete = new DeleteThreadSafe(genreDao, genre);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class ExistThreadSafe implements Runnable {
|
||||
private GenreDao genreDao;
|
||||
private Genre genre;
|
||||
private boolean exist = false;
|
||||
|
||||
public ExistThreadSafe(GenreDao genreDao, Genre genre) {
|
||||
this.genreDao = genreDao;
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
exist = genreDao.exist(genre.getId());
|
||||
}
|
||||
|
||||
public boolean exist() {
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertThreadSafe implements Runnable {
|
||||
private GenreDao genreDao;
|
||||
private Genre genre;
|
||||
|
||||
public InsertThreadSafe(GenreDao genreDao, Genre genre) {
|
||||
this.genreDao = genreDao;
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
genreDao.insert(genre);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private GenreDao genreDao;
|
||||
private ArrayList<Genre> genres;
|
||||
|
||||
public InsertAllThreadSafe(GenreDao genreDao, ArrayList<Genre> genres) {
|
||||
this.genreDao = genreDao;
|
||||
this.genres = genres;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
genreDao.insertAll(genres);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteThreadSafe implements Runnable {
|
||||
private GenreDao genreDao;
|
||||
private Genre genre;
|
||||
|
||||
public DeleteThreadSafe(GenreDao genreDao, Genre genre) {
|
||||
this.genreDao = genreDao;
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
genreDao.delete(genre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.PlaylistDao;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistRepository {
|
||||
private PlaylistDao playlistDao;
|
||||
private LiveData<List<Playlist>> listLivePlaylists;
|
||||
|
||||
public PlaylistRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
playlistDao = database.playlistDao();
|
||||
listLivePlaylists = playlistDao.getAll();
|
||||
}
|
||||
|
||||
public LiveData<List<Playlist>> getListLivePlaylists() {
|
||||
return listLivePlaylists;
|
||||
}
|
||||
|
||||
public boolean exist(Playlist playlist) {
|
||||
boolean exist = false;
|
||||
|
||||
ExistThreadSafe existThread = new ExistThreadSafe(playlistDao, playlist);
|
||||
Thread thread = new Thread(existThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
exist = existThread.exist();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
public void insert(Playlist playlist) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(playlistDao, playlist);
|
||||
Thread thread = new Thread(insert);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void insertAll(ArrayList<Playlist> playlists) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(playlistDao, playlists);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void delete(Playlist playlist) {
|
||||
DeleteThreadSafe delete = new DeleteThreadSafe(playlistDao, playlist);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class ExistThreadSafe implements Runnable {
|
||||
private PlaylistDao playlistDao;
|
||||
private Playlist playlist;
|
||||
private boolean exist = false;
|
||||
|
||||
public ExistThreadSafe(PlaylistDao playlistDao, Playlist playlist) {
|
||||
this.playlistDao = playlistDao;
|
||||
this.playlist = playlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
exist = playlistDao.exist(playlist.getId());
|
||||
}
|
||||
|
||||
public boolean exist() {
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertThreadSafe implements Runnable {
|
||||
private PlaylistDao playlistDao;
|
||||
private Playlist playlist;
|
||||
|
||||
public InsertThreadSafe(PlaylistDao playlistDao, Playlist playlist) {
|
||||
this.playlistDao = playlistDao;
|
||||
this.playlist = playlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playlistDao.insert(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private PlaylistDao playlistDao;
|
||||
private ArrayList<Playlist> playlists;
|
||||
|
||||
public InsertAllThreadSafe(PlaylistDao playlistDao, ArrayList<Playlist> playlists) {
|
||||
this.playlistDao = playlistDao;
|
||||
this.playlists = playlists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playlistDao.insertAll(playlists);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteThreadSafe implements Runnable {
|
||||
private PlaylistDao playlistDao;
|
||||
private Playlist playlist;
|
||||
|
||||
public DeleteThreadSafe(PlaylistDao playlistDao, Playlist playlist) {
|
||||
this.playlistDao = playlistDao;
|
||||
this.playlist = playlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playlistDao.delete(playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.SongDao;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SongRepository {
|
||||
private SongDao songDao;
|
||||
private LiveData<List<Song>> listLiveSongs;
|
||||
|
||||
public SongRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
songDao = database.songDao();
|
||||
listLiveSongs = songDao.getAll();
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getListLiveSongs() {
|
||||
return listLiveSongs;
|
||||
}
|
||||
|
||||
public boolean exist(Song song) {
|
||||
boolean exist = false;
|
||||
|
||||
ExistThreadSafe existThread = new ExistThreadSafe(songDao, song);
|
||||
Thread thread = new Thread(existThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
exist = existThread.exist();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
public void insert(Song song) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(songDao, song);
|
||||
Thread thread = new Thread(insert);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void insertAll(ArrayList<Song> songs) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(songDao, songs);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void delete(Song song) {
|
||||
DeleteThreadSafe delete = new DeleteThreadSafe(songDao, song);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class ExistThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private Song song;
|
||||
private boolean exist = false;
|
||||
|
||||
public ExistThreadSafe(SongDao songDao, Song song) {
|
||||
this.songDao = songDao;
|
||||
this.song = song;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
exist = songDao.exist(song.getId());
|
||||
}
|
||||
|
||||
public boolean exist() {
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private Song song;
|
||||
|
||||
public InsertThreadSafe(SongDao songDao, Song song) {
|
||||
this.songDao = songDao;
|
||||
this.song = song;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
songDao.insert(song);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private ArrayList<Song> songs;
|
||||
|
||||
public InsertAllThreadSafe(SongDao songDao, ArrayList<Song> songs) {
|
||||
this.songDao = songDao;
|
||||
this.songs = songs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
songDao.insertAll(songs);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private Song song;
|
||||
|
||||
public DeleteThreadSafe(SongDao songDao, Song song) {
|
||||
this.songDao = songDao;
|
||||
this.song = song;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
songDao.delete(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue