mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Implemented playlist
This commit is contained in:
parent
d72b37725c
commit
3addc3b561
14 changed files with 255 additions and 5 deletions
|
|
@ -0,0 +1,62 @@
|
|||
package com.cappielloantonio.play.repository;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.PlaylistSongCrossDao;
|
||||
import com.cappielloantonio.play.database.dao.SongArtistCrossDao;
|
||||
import com.cappielloantonio.play.model.PlaylistSongCross;
|
||||
import com.cappielloantonio.play.model.SongArtistCross;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistSongRepository {
|
||||
private static final String TAG = "AlbumArtistRepository";
|
||||
|
||||
private PlaylistSongCrossDao playlistSongCrossDao;
|
||||
|
||||
public PlaylistSongRepository(Application application) {
|
||||
AppDatabase database = AppDatabase.getInstance(application);
|
||||
playlistSongCrossDao = database.playlistSongCrossDao();
|
||||
}
|
||||
|
||||
public void insertAll(List<PlaylistSongCross> crosses) {
|
||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(playlistSongCrossDao, crosses);
|
||||
Thread thread = new Thread(insertAll);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private PlaylistSongCrossDao playlistSongCrossDao;
|
||||
private List<PlaylistSongCross> crosses;
|
||||
|
||||
public InsertAllThreadSafe(PlaylistSongCrossDao playlistSongCrossDao, List<PlaylistSongCross> crosses) {
|
||||
this.playlistSongCrossDao = playlistSongCrossDao;
|
||||
this.crosses = crosses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playlistSongCrossDao.insertAll(crosses);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
DeleteAllPlaylistSongCrossThreadSafe delete = new DeleteAllPlaylistSongCrossThreadSafe(playlistSongCrossDao);
|
||||
Thread thread = new Thread(delete);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static class DeleteAllPlaylistSongCrossThreadSafe implements Runnable {
|
||||
private PlaylistSongCrossDao playlistSongCrossDao;
|
||||
|
||||
public DeleteAllPlaylistSongCrossThreadSafe(PlaylistSongCrossDao playlistSongCrossDao) {
|
||||
this.playlistSongCrossDao = playlistSongCrossDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playlistSongCrossDao.deleteAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ public class SongRepository {
|
|||
private LiveData<List<Song>> listLiveSampleMostPlayedSongs;
|
||||
private LiveData<List<Song>> listLiveSampleArtistTopSongs;
|
||||
private LiveData<List<Song>> listLiveAlbumSongs;
|
||||
private LiveData<List<Song>> listLivePlaylistSongs;
|
||||
private LiveData<List<Song>> listLiveSongByGenre;
|
||||
private LiveData<List<Song>> listLiveFilteredSongs;
|
||||
private LiveData<List<Song>> listLiveSongByYear;
|
||||
|
|
@ -102,6 +103,11 @@ public class SongRepository {
|
|||
return listLiveAlbumSongs;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getPlaylistLiveSong(String playlistID) {
|
||||
listLivePlaylistSongs = songDao.getLivePlaylistSong(playlistID);
|
||||
return listLivePlaylistSongs;
|
||||
}
|
||||
|
||||
public List<Song> getAlbumListSong(String albumID, boolean randomOrder) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue