mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Saving play history. The tracks are saved in the db at the time of playback and every week a list of the most played tracks is generated in the home page in grid format
This commit is contained in:
parent
6a1c5d2ce3
commit
ff8bf4f6bf
14 changed files with 646 additions and 55 deletions
|
|
@ -8,11 +8,13 @@ import androidx.room.Database;
|
|||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.cappielloantonio.play.database.dao.ChronologyDao;
|
||||
import com.cappielloantonio.play.database.dao.DownloadDao;
|
||||
import com.cappielloantonio.play.database.dao.PlaylistDao;
|
||||
import com.cappielloantonio.play.database.dao.QueueDao;
|
||||
import com.cappielloantonio.play.database.dao.RecentSearchDao;
|
||||
import com.cappielloantonio.play.database.dao.ServerDao;
|
||||
import com.cappielloantonio.play.model.Chronology;
|
||||
import com.cappielloantonio.play.model.Download;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
|
|
@ -21,9 +23,9 @@ import com.cappielloantonio.play.model.Server;
|
|||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Database(
|
||||
version = 41,
|
||||
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class}
|
||||
// autoMigrations = {@AutoMigration(from = 39, to = 40)}
|
||||
version = 42,
|
||||
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class, Chronology.class},
|
||||
autoMigrations = {@AutoMigration(from = 41, to = 42)}
|
||||
)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
private static final String TAG = "AppDatabase";
|
||||
|
|
@ -50,4 +52,6 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
public abstract DownloadDao downloadDao();
|
||||
|
||||
public abstract PlaylistDao playlistDao();
|
||||
|
||||
public abstract ChronologyDao chronologyDao();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.cappielloantonio.play.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
|
||||
import com.cappielloantonio.play.model.Chronology;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface ChronologyDao {
|
||||
@Query("SELECT * FROM chronology WHERE timestamp >= :startDate AND timestamp < :endDate GROUP BY id ORDER BY COUNT(id) DESC LIMIT 9")
|
||||
LiveData<List<Chronology>> getAllFrom(long startDate, long endDate);
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(Chronology chronologyObject);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue