mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 10:23:33 +00:00
Added lastPlay info in queue model
This commit is contained in:
parent
4adde9e951
commit
76f4f1d021
6 changed files with 44 additions and 3 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue