mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Implementation of download navigation for artists and albums
This commit is contained in:
parent
c5f39cf9ee
commit
86d46f7537
16 changed files with 98 additions and 53 deletions
|
|
@ -23,45 +23,22 @@ public class DownloadRepository {
|
|||
downloadDao = database.downloadDao();
|
||||
}
|
||||
|
||||
public List<Download> getLiveDownload() {
|
||||
List<Download> downloads = new ArrayList<>();
|
||||
|
||||
GetDownloadThreadSafe getDownloads = new GetDownloadThreadSafe(downloadDao);
|
||||
Thread thread = new Thread(getDownloads);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
downloads = getDownloads.getDownloads();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return downloads;
|
||||
}
|
||||
|
||||
private static class GetDownloadThreadSafe implements Runnable {
|
||||
private final DownloadDao downloadDao;
|
||||
private List<Download> downloads;
|
||||
|
||||
public GetDownloadThreadSafe(DownloadDao downloadDao) {
|
||||
this.downloadDao = downloadDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
downloads = downloadDao.getAll();
|
||||
}
|
||||
|
||||
public List<Download> getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
public LiveData<List<Download>> getLiveDownload() {
|
||||
return downloadDao.getAll(PreferenceUtil.getInstance(App.getInstance()).getServerId());
|
||||
}
|
||||
|
||||
public LiveData<List<Download>> getLiveDownloadSample(int size) {
|
||||
return downloadDao.getSample(size, PreferenceUtil.getInstance(App.getInstance()).getServerId());
|
||||
}
|
||||
|
||||
public LiveData<List<Download>> getLiveDownloadFromArtist(String artistId) {
|
||||
return downloadDao.getAllFromArtist(PreferenceUtil.getInstance(App.getInstance()).getServerId(), artistId);
|
||||
}
|
||||
|
||||
public LiveData<List<Download>> getLiveDownloadFromAlbum(String albumId) {
|
||||
return downloadDao.getAllFromAlbum(PreferenceUtil.getInstance(App.getInstance()).getServerId(), albumId);
|
||||
}
|
||||
|
||||
public void insert(Download download) {
|
||||
InsertThreadSafe insert = new InsertThreadSafe(downloadDao, download);
|
||||
Thread thread = new Thread(insert);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue