mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-02 07:23:36 +00:00
Added lastPlay info in queue model
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user