First reimplementation of download functionality

This commit is contained in:
antonio 2023-03-10 09:31:15 +01:00
parent 77a3b90b4e
commit 3e7d260d6a
16 changed files with 143 additions and 92 deletions

View file

@ -22,7 +22,7 @@ import com.cappielloantonio.play.model.Server;
import com.cappielloantonio.play.subsonic.models.Playlist;
@Database(
version = 52,
version = 53,
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class, Chronology.class}
// autoMigrations = {@AutoMigration(from = 43, to = 44)}
)

View file

@ -12,32 +12,32 @@ import java.util.List;
@Dao
public interface DownloadDao {
@Query("SELECT * FROM download WHERE server=:server")
LiveData<List<Download>> getAll(String server);
@Query("SELECT * FROM download")
LiveData<List<Download>> getAll();
@Query("SELECT * FROM download WHERE server=:server AND playlist_id IS NULL GROUP BY artist LIMIT :size")
LiveData<List<Download>> getSampleArtist(int size, String server);
@Query("SELECT * FROM download WHERE playlist_id IS NULL GROUP BY artist LIMIT :size")
LiveData<List<Download>> getSampleArtist(int size);
@Query("SELECT * FROM download WHERE server=:server AND playlist_id IS NULL GROUP BY album LIMIT :size")
LiveData<List<Download>> getSampleAlbum(int size, String server);
@Query("SELECT * FROM download WHERE playlist_id IS NULL GROUP BY album LIMIT :size")
LiveData<List<Download>> getSampleAlbum(int size);
@Query("SELECT * FROM download WHERE server=:server AND playlist_id IS NOT NULL GROUP BY playlist_id LIMIT :size")
LiveData<List<Download>> getSamplePlaylist(int size, String server);
@Query("SELECT * FROM download WHERE playlist_id IS NOT NULL GROUP BY playlist_id LIMIT :size")
LiveData<List<Download>> getSamplePlaylist(int size);
@Query("SELECT * FROM download WHERE server=:server LIMIT :size")
LiveData<List<Download>> getSample(int size, String server);
@Query("SELECT * FROM download LIMIT :size")
LiveData<List<Download>> getSample(int size);
@Query("SELECT * FROM download WHERE server=:server AND artist=:artistId")
LiveData<List<Download>> getAllFromArtist(String server, String artistId);
@Query("SELECT * FROM download WHERE artist=:artistId")
LiveData<List<Download>> getAllFromArtist(String artistId);
@Query("SELECT * FROM download WHERE server=:server AND album=:albumId ORDER BY track ASC")
LiveData<List<Download>> getAllFromAlbum(String server, String albumId);
@Query("SELECT * FROM download WHERE album=:albumId ORDER BY track ASC")
LiveData<List<Download>> getAllFromAlbum(String albumId);
@Query("SELECT * FROM download WHERE server=:server AND playlist_id=:playlistId")
LiveData<List<Download>> getAllFromPlaylist(String server, String playlistId);
@Query("SELECT * FROM download WHERE playlist_id=:playlistId")
LiveData<List<Download>> getAllFromPlaylist(String playlistId);
@Query("SELECT * FROM download WHERE server=:server AND playlist_id IS NOT NULL GROUP BY playlist_id")
LiveData<List<Download>> getAllPlaylists(String server);
@Query("SELECT * FROM download WHERE playlist_id IS NOT NULL GROUP BY playlist_id")
LiveData<List<Download>> getAllPlaylists();
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(Download download);
@ -45,9 +45,9 @@ public interface DownloadDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<Download> downloads);
@Query("DELETE FROM download WHERE media_id = :mediaId")
void delete(String mediaId);
@Query("DELETE FROM download WHERE id = :id")
void delete(String id);
@Query("DELETE FROM download WHERE server=:server")
void deleteAll(String server);
@Query("DELETE FROM download")
void deleteAll();
}