Removed unused methods from queue repository

This commit is contained in:
CappielloAntonio 2021-04-19 14:57:39 +02:00
parent ed5661c667
commit c1496d01a2
2 changed files with 4 additions and 93 deletions

View file

@ -16,18 +16,9 @@ public interface PlaylistDao {
@Query("SELECT * FROM playlist")
LiveData<List<Playlist>> getAll();
@Query("SELECT EXISTS(SELECT * FROM playlist WHERE id = :id)")
boolean exist(String id);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(Playlist playlist);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<Playlist> playlists);
@Delete
void delete(Playlist playlist);
@Query("DELETE FROM playlist")
void deleteAll();
}

View file

@ -25,83 +25,12 @@ public class PlaylistRepository {
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();
}
public void deleteAll() {
DeleteAllThreadSafe delete = new DeleteAllThreadSafe(playlistDao);
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;
@ -118,19 +47,10 @@ public class PlaylistRepository {
}
}
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);
}
public void deleteAll() {
DeleteAllThreadSafe delete = new DeleteAllThreadSafe(playlistDao);
Thread thread = new Thread(delete);
thread.start();
}
private static class DeleteAllThreadSafe implements Runnable {