Added lastPlay info in queue model

This commit is contained in:
CappielloAntonio 2021-08-12 17:56:03 +02:00
parent 4adde9e951
commit 76f4f1d021
6 changed files with 44 additions and 3 deletions

View file

@ -14,6 +14,7 @@ import com.cappielloantonio.play.util.MappingUtil;
import com.cappielloantonio.play.util.PreferenceUtil;
import com.cappielloantonio.play.util.QueueUtil;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@ -93,6 +94,12 @@ public class QueueRepository {
return count;
}
public void setTimestamp(Song song) {
SetTimestampThreadSafe delete = new SetTimestampThreadSafe(queueDao, song.getId());
Thread thread = new Thread(delete);
thread.start();
}
private static class GetSongsThreadSafe implements Runnable {
private QueueDao queueDao;
private List<Song> songs;
@ -171,4 +178,19 @@ public class QueueRepository {
return count;
}
}
private static class SetTimestampThreadSafe implements Runnable {
private QueueDao queueDao;
private String songId;
public SetTimestampThreadSafe(QueueDao queueDao, String songId) {
this.queueDao = queueDao;
this.songId = songId;
}
@Override
public void run() {
queueDao.setLastPlay(songId, Instant.now().toEpochMilli());
}
}
}