Implemented offline mode functionality

This commit is contained in:
CappielloAntonio 2021-04-26 19:17:42 +02:00
parent 658e69dcb9
commit e0569c3901
21 changed files with 635 additions and 23 deletions

View file

@ -353,6 +353,12 @@ public class SongRepository {
thread.start();
}
public void setOfflineStatus(Song song) {
UpdateThreadSafe update = new UpdateThreadSafe(songDao, song);
Thread thread = new Thread(update);
thread.start();
}
private static class UpdateThreadSafe implements Runnable {
private SongDao songDao;
private Song song;
@ -368,6 +374,25 @@ public class SongRepository {
}
}
public void setAllOffline() {
SetAllOfflineThreadSafe update = new SetAllOfflineThreadSafe(songDao);
Thread thread = new Thread(update);
thread.start();
}
private static class SetAllOfflineThreadSafe implements Runnable {
private SongDao songDao;
public SetAllOfflineThreadSafe(SongDao songDao) {
this.songDao = songDao;
}
@Override
public void run() {
songDao.updateAllOffline();
}
}
public void insertSongPerGenre(ArrayList<SongGenreCross> songGenreCrosses) {
InsertPerGenreThreadSafe insertPerGenre = new InsertPerGenreThreadSafe(songGenreCrossDao, songGenreCrosses);
Thread thread = new Thread(insertPerGenre);