Changed the sort order of the songs in the playlist and added a download button

This commit is contained in:
CappielloAntonio 2021-06-26 15:10:49 +02:00
parent a466574e08
commit 91fd7a5b29
10 changed files with 106 additions and 12 deletions

View file

@ -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;
}
}
}