mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 10:23:33 +00:00
Removed unused methods from queue repository
This commit is contained in:
parent
ed5661c667
commit
c1496d01a2
2 changed files with 4 additions and 93 deletions
|
|
@ -16,18 +16,9 @@ public interface PlaylistDao {
|
||||||
@Query("SELECT * FROM playlist")
|
@Query("SELECT * FROM playlist")
|
||||||
LiveData<List<Playlist>> getAll();
|
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)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
void insertAll(List<Playlist> playlists);
|
void insertAll(List<Playlist> playlists);
|
||||||
|
|
||||||
@Delete
|
|
||||||
void delete(Playlist playlist);
|
|
||||||
|
|
||||||
@Query("DELETE FROM playlist")
|
@Query("DELETE FROM playlist")
|
||||||
void deleteAll();
|
void deleteAll();
|
||||||
}
|
}
|
||||||
|
|
@ -25,83 +25,12 @@ public class PlaylistRepository {
|
||||||
return listLivePlaylists;
|
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) {
|
public void insertAll(ArrayList<Playlist> playlists) {
|
||||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(playlistDao, playlists);
|
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(playlistDao, playlists);
|
||||||
Thread thread = new Thread(insertAll);
|
Thread thread = new Thread(insertAll);
|
||||||
thread.start();
|
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 static class InsertAllThreadSafe implements Runnable {
|
||||||
private PlaylistDao playlistDao;
|
private PlaylistDao playlistDao;
|
||||||
private ArrayList<Playlist> playlists;
|
private ArrayList<Playlist> playlists;
|
||||||
|
|
@ -118,19 +47,10 @@ public class PlaylistRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DeleteThreadSafe implements Runnable {
|
public void deleteAll() {
|
||||||
private PlaylistDao playlistDao;
|
DeleteAllThreadSafe delete = new DeleteAllThreadSafe(playlistDao);
|
||||||
private Playlist playlist;
|
Thread thread = new Thread(delete);
|
||||||
|
thread.start();
|
||||||
public DeleteThreadSafe(PlaylistDao playlistDao, Playlist playlist) {
|
|
||||||
this.playlistDao = playlistDao;
|
|
||||||
this.playlist = playlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
playlistDao.delete(playlist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DeleteAllThreadSafe implements Runnable {
|
private static class DeleteAllThreadSafe implements Runnable {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue