mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Removed unused methods from album repository
This commit is contained in:
parent
fc240c273f
commit
0e9ec60195
2 changed files with 34 additions and 139 deletions
|
|
@ -16,7 +16,6 @@ public interface AlbumDao {
|
||||||
@Query("SELECT * FROM album")
|
@Query("SELECT * FROM album")
|
||||||
LiveData<List<Album>> getAll();
|
LiveData<List<Album>> getAll();
|
||||||
|
|
||||||
// @Query("SELECT * FROM album WHERE artistId = :artistId;")
|
|
||||||
@Query("SELECT album.* FROM album INNER JOIN album_artist_cross ON album.id = album_artist_cross.album_id AND album_artist_cross.artist_id = :artistId")
|
@Query("SELECT album.* FROM album INNER JOIN album_artist_cross ON album.id = album_artist_cross.album_id AND album_artist_cross.artist_id = :artistId")
|
||||||
LiveData<List<Album>> getArtistAlbums(String artistId);
|
LiveData<List<Album>> getArtistAlbums(String artistId);
|
||||||
|
|
||||||
|
|
@ -26,18 +25,12 @@ public interface AlbumDao {
|
||||||
@Query("SELECT * FROM album WHERE title LIKE '%' || :name || '%'")
|
@Query("SELECT * FROM album WHERE title LIKE '%' || :name || '%'")
|
||||||
LiveData<List<Album>> searchAlbum(String name);
|
LiveData<List<Album>> searchAlbum(String name);
|
||||||
|
|
||||||
@Query("SELECT EXISTS(SELECT * FROM album WHERE id = :id)")
|
|
||||||
boolean exist(String id);
|
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
void insert(Album album);
|
void insert(Album album);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
void insertAll(List<Album> albums);
|
void insertAll(List<Album> albums);
|
||||||
|
|
||||||
@Delete
|
|
||||||
void delete(Album album);
|
|
||||||
|
|
||||||
@Query("SELECT title FROM album WHERE title LIKE :query || '%' OR title like '% ' || :query || '%' GROUP BY title LIMIT :number")
|
@Query("SELECT title FROM album WHERE title LIKE :query || '%' OR title like '% ' || :query || '%' GROUP BY title LIMIT :number")
|
||||||
List<String> searchSuggestions(String query, int number);
|
List<String> searchSuggestions(String query, int number);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,130 +63,6 @@ public class AlbumRepository {
|
||||||
return suggestions;
|
return suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteAll() {
|
|
||||||
DeleteAllThreadSafe delete = new DeleteAllThreadSafe(albumDao);
|
|
||||||
Thread thread = new Thread(delete);
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Album getAlbumByID(String id) {
|
|
||||||
Album album = null;
|
|
||||||
|
|
||||||
GetAlbumByIDThreadSafe getAlbum = new GetAlbumByIDThreadSafe(albumDao, id);
|
|
||||||
Thread thread = new Thread(getAlbum);
|
|
||||||
thread.start();
|
|
||||||
|
|
||||||
try {
|
|
||||||
thread.join();
|
|
||||||
album = getAlbum.getAlbum();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return album;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.deleteAll();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SearchSuggestionsThreadSafe implements Runnable {
|
private static class SearchSuggestionsThreadSafe implements Runnable {
|
||||||
private AlbumDao albumDao;
|
private AlbumDao albumDao;
|
||||||
private String query;
|
private String query;
|
||||||
|
|
@ -209,17 +85,27 @@ public class AlbumRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DeleteAllThreadSafe implements Runnable {
|
public void insertAll(ArrayList<Album> albums) {
|
||||||
private AlbumDao albumDao;
|
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(albumDao, albums);
|
||||||
|
Thread thread = new Thread(insertAll);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
public DeleteAllThreadSafe(AlbumDao albumDao) {
|
public Album getAlbumByID(String id) {
|
||||||
this.albumDao = albumDao;
|
Album album = null;
|
||||||
|
|
||||||
|
GetAlbumByIDThreadSafe getAlbum = new GetAlbumByIDThreadSafe(albumDao, id);
|
||||||
|
Thread thread = new Thread(getAlbum);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
try {
|
||||||
|
thread.join();
|
||||||
|
album = getAlbum.getAlbum();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
return album;
|
||||||
public void run() {
|
|
||||||
albumDao.deleteAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class GetAlbumByIDThreadSafe implements Runnable {
|
private static class GetAlbumByIDThreadSafe implements Runnable {
|
||||||
|
|
@ -241,4 +127,20 @@ public class AlbumRepository {
|
||||||
return album;
|
return 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.deleteAll();
|
||||||
|
albumDao.insertAll(albums);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue