mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Multi server/user implementation
This commit is contained in:
parent
4e269a7446
commit
78a4006ed6
30 changed files with 959 additions and 192 deletions
|
|
@ -9,11 +9,13 @@ import androidx.room.RoomDatabase;
|
|||
import com.cappielloantonio.play.database.dao.DownloadDao;
|
||||
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.Download;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.RecentSearch;
|
||||
import com.cappielloantonio.play.model.Server;
|
||||
|
||||
@Database(entities = {Queue.class, RecentSearch.class, Download.class}, version = 5, exportSchema = false)
|
||||
@Database(entities = {Queue.class, Server.class, RecentSearch.class, Download.class}, version = 9, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
private static final String TAG = "AppDatabase";
|
||||
|
||||
|
|
@ -31,6 +33,8 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
|
||||
public abstract QueueDao queueDao();
|
||||
|
||||
public abstract ServerDao serverDao();
|
||||
|
||||
public abstract RecentSearchDao recentSearchDao();
|
||||
|
||||
public abstract DownloadDao downloadDao();
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ public interface DownloadDao {
|
|||
@Query("SELECT * FROM download")
|
||||
List<Download> getAll();
|
||||
|
||||
@Query("SELECT * FROM download LIMIT :size")
|
||||
LiveData<List<Download>> getSample(int size);
|
||||
@Query("SELECT * FROM download WHERE server=:server LIMIT :size")
|
||||
LiveData<List<Download>> getSample(int size, String server);
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(Download download);
|
||||
|
|
@ -27,6 +27,6 @@ public interface DownloadDao {
|
|||
@Query("DELETE FROM download WHERE id = :id")
|
||||
void delete(String id);
|
||||
|
||||
@Query("DELETE FROM download")
|
||||
void deleteAll();
|
||||
@Query("DELETE FROM download WHERE server=:server")
|
||||
void deleteAll(String server);
|
||||
}
|
||||
|
|
@ -12,20 +12,20 @@ import java.util.List;
|
|||
|
||||
@Dao
|
||||
public interface QueueDao {
|
||||
@Query("SELECT * FROM queue")
|
||||
LiveData<List<Queue>> getAll();
|
||||
@Query("SELECT * FROM queue WHERE server = :server")
|
||||
LiveData<List<Queue>> getAll(String server);
|
||||
|
||||
@Query("SELECT * FROM queue")
|
||||
List<Queue> getAllSimple();
|
||||
@Query("SELECT * FROM queue WHERE server = :server")
|
||||
List<Queue> getAllSimple(String server);
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insertAll(List<Queue> songQueueObject);
|
||||
|
||||
@Query("DELETE FROM queue WHERE queue.track_order = :position")
|
||||
void deleteByPosition(int position);
|
||||
@Query("DELETE FROM queue WHERE queue.track_order = :position AND server = :server")
|
||||
void deleteByPosition(int position, String server);
|
||||
|
||||
@Query("DELETE FROM queue")
|
||||
void deleteAll();
|
||||
@Query("DELETE FROM queue WHERE server = :server")
|
||||
void deleteAll(String server);
|
||||
|
||||
@Query("SELECT COUNT(*) FROM queue;")
|
||||
int count();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,4 @@ public interface RecentSearchDao {
|
|||
|
||||
@Delete
|
||||
void delete(RecentSearch search);
|
||||
|
||||
@Query("DELETE FROM recent_search")
|
||||
void deleteAll();
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.cappielloantonio.play.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface ServerDao {
|
||||
@Query("SELECT * FROM server")
|
||||
LiveData<List<Server>> getAll();
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(Server server);
|
||||
|
||||
@Delete
|
||||
void delete(Server server);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue