Search in sources :

Example 21 with PlaylistInfo

use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.

the class PlaylistService method addTmpPlaylist.

public void addTmpPlaylist(List<PlaylistEntry> entries) {
    PlaylistInfo tmpEntry = new PlaylistInfo();
    tmpEntry.setName(TMP_PLAYLIST_ID);
    tmpEntry.setId(TMP_PLAYLIST_ID);
    playlistSongs.put(tmpEntry.getId(), entries);
    playlists.removeIf(item -> item.getId().equals(TMP_PLAYLIST_ID));
    playlists.add(tmpEntry);
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 22 with PlaylistInfo

use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.

the class PlaylistService method addSongs.

public void addSongs(PlaylistInfo playlist, List<PlaylistEntry> entry, List<List<ContentEntry>> songs) {
    if (entry.size() != songs.size()) {
        throw new IllegalStateException("Bah!!!");
    }
    List<PlaylistEntry> entries = new ArrayList<>();
    Iterator<PlaylistEntry> entryLists = entry.iterator();
    Iterator<List<ContentEntry>> entryListsSongs = songs.iterator();
    while (entryLists.hasNext()) {
        PlaylistEntry pEntry = entryLists.next();
        List<ContentEntry> pSongs = entryListsSongs.next();
        for (ContentEntry song : pSongs) {
            if (song.getName().toLowerCase().endsWith(".sid")) {
                PlaylistEntry tmp = new PlaylistEntry(pEntry.getId(), pEntry.getCategory(), song.getId());
                tmp.setName(song.getName());
                if (song.getFullPlaylistInfo() != null) {
                    tmp.setGroup(song.getFullPlaylistInfo().getGroup());
                    tmp.setYear(song.getFullPlaylistInfo().getYear());
                }
                entries.add(tmp);
            }
        }
    }
    Executors.newSingleThreadExecutor().execute(() -> {
        List<PlaylistEntry> addedSongs = getClient().target(server).path("/leet/playlistsnew/addsongs/" + playlist.getId()).request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).post(Entity.json(entries), new GenericType<List<PlaylistEntry>>() {
        });
        List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
        for (PlaylistEntry tmp1 : addedSongs) {
            for (PlaylistEntry tmp2 : songsForPlaylist) {
                if (tmp2.getSongId().equals(tmp1.getSongId())) {
                    tmp2.setGroup(tmp1.getGroup());
                    tmp2.setYear(tmp1.getYear());
                    tmp2.setName(tmp1.getName());
                    break;
                }
            }
        }
        flush(songsForPlaylist, resolvePlaylistFilename(playlist));
        playlist.setChecksum(getChksum(songsForPlaylist));
        Analytics.sendEvent("sidify", "addsongs");
    });
    List<PlaylistEntry> songsForPlaylist = getSongsForPlaylist(playlist);
    songsForPlaylist.addAll(entries);
    flush(songsForPlaylist, resolvePlaylistFilename(playlist));
    playlist.setChecksum(getChksum(songsForPlaylist));
    flushPlaylistInfo();
}
Also used : ContentEntry(se.light.assembly64.model.ContentEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 23 with PlaylistInfo

use of se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.

the class PlaylistService method moveSongInList.

public void moveSongInList(PlaylistInfo playlist, int from, int to) {
    getClient().target(server).path("/leet/playlistsnew/move/" + playlist.getId() + "/" + from + "/" + to).request().header("email", email).header("token", token).get().close();
    List<PlaylistEntry> list = playlistSongs.get(playlist.getId());
    PlaylistEntry entry = list.remove(from);
    list.add(to, entry);
    flushLocalList(playlist, list);
    playlist.setChecksum(getChksum(list));
    flushPlaylistInfo();
    Analytics.sendEvent("sidify", "movesong");
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Aggregations

PlaylistInfo (se.light.assembly64.model.PlaylistInfo)17 PlaylistEntry (se.light.assembly64.model.PlaylistEntry)14 ContentEntry (se.light.assembly64.model.ContentEntry)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)4 ActionEvent (javafx.event.ActionEvent)4 ContextMenu (javafx.scene.control.ContextMenu)4 MenuItem (javafx.scene.control.MenuItem)4 PlaylistMenuItem (se.light.assembly64.model.PlaylistMenuItem)4 Set (java.util.Set)3 Executors (java.util.concurrent.Executors)3 Menu (javafx.scene.control.Menu)3 GenericType (javax.ws.rs.core.GenericType)3 SidTune (libsidplay.sidtune.SidTune)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Analytics (se.light.assembly64.Analytics)3 Support (se.light.assembly64.Support)3