mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-02 23:43:37 +00:00
Changed the sort order of the songs in the playlist and added a download button
This commit is contained in:
@@ -293,6 +293,23 @@ public class SongRepository {
|
||||
return sample;
|
||||
}
|
||||
|
||||
public List<Song> getPlaylistSong(String playlistID) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
|
||||
GetSongsByPlaylistIDThreadSafe playlistThread = new GetSongsByPlaylistIDThreadSafe(songDao, playlistID);
|
||||
Thread thread = new Thread(playlistThread);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
songs = playlistThread.getSongs();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return songs;
|
||||
}
|
||||
|
||||
private static class GetRandomSongsByArtistIDThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private String artistID;
|
||||
@@ -509,4 +526,24 @@ public class SongRepository {
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetSongsByPlaylistIDThreadSafe implements Runnable {
|
||||
private SongDao songDao;
|
||||
private String playlistID;
|
||||
private List<Song> songs = new ArrayList<>();
|
||||
|
||||
public GetSongsByPlaylistIDThreadSafe(SongDao songDao, String playlistID) {
|
||||
this.songDao = songDao;
|
||||
this.playlistID = playlistID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
songs = songDao.getPlaylistSong(playlistID);
|
||||
}
|
||||
|
||||
public List<Song> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user