Search in sources :

Example 11 with PlaylistEntry

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

the class SidifyMainContoller method downloadPlaylistOffline.

private void downloadPlaylistOffline(PlaylistInfo playlist, boolean showPopup) {
    for (PlaylistEntry entry : playListService.getSongsForPlaylist(playlist)) {
        File sid = new File(pathService.getSidFolderAsString() + resolveFilename(entry.getId(), entry.getCategory(), entry.getName()));
        if (!sid.exists()) {
            try {
                downloadService.downloadTo(sid, entry.getId(), entry.getCategory(), entry.getFileId());
                Platform.runLater(() -> {
                    // update downloaded status
                    songlist.getColumns().get(0).setVisible(false);
                    songlist.getColumns().get(0).setVisible(true);
                });
            } catch (Exception e) {
                LOGGER.info("Unable to download " + entry.getName());
            }
        }
    }
    if (showPopup) {
        GenericMessageDialogController.withInfoProps("Sidify", "Playlist was downloaded", true).showAndWait();
    }
    playListService.makePlaylistAvailableOffline(playlist, Boolean.TRUE);
    Platform.runLater(() -> {
        populateLeftList();
    });
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry) File(java.io.File) SearchException(se.light.assembly64.model.SearchException) SongNotAvailableException(se.light.assembly64.model.SongNotAvailableException) SpecifyFileIdException(se.light.assembly64.model.SpecifyFileIdException)

Example 12 with PlaylistEntry

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

the class SidifyMainContoller method refreshCurrentSongList.

private void refreshCurrentSongList(PlaylistInfo playlist) {
    songs.clear();
    for (PlaylistEntry entry : playListService.getSongsForPlaylist(playlist)) {
        songs.add(entry);
    }
    songlist.setItems(songs);
    if (activePlaylist != null && (playlist.getId().equals(activePlaylist.getId()))) {
        // songlist.getSelectionModel().select(getActiveSongInList());
        clearAndSelect(getActiveSongInList());
    }
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 13 with PlaylistEntry

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

the class SidifyMainContoller method refreshPlaylistIfNeeded.

private void refreshPlaylistIfNeeded(PlaylistInfo playlistOperatedOn) {
    if (playlistOperatedOn != null) {
        clearSongList();
        for (PlaylistEntry entry : playListService.getSongsForPlaylist(playlistOperatedOn)) {
            songs.add(entry);
        }
        // songlist.getSelectionModel().select(getActiveSongInList());
        clearAndSelect(getActiveSongInList());
        songlist.getSelectionModel().focus(songlist.getSelectionModel().getSelectedIndex());
    }
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 14 with PlaylistEntry

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

the class SidifyViewPublicPlaylistController method init.

public void init(List<PlaylistEntry> entries) {
    Analytics.sendEvent("sidify", "view_playlist");
    name.setCellValueFactory(new PropertyValueFactory<PlaylistEntry, String>("name"));
    songs.clear();
    for (PlaylistEntry item : entries) {
        songs.add(item);
    }
    songlist.setItems(songs);
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Example 15 with PlaylistEntry

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

the class Support method flattenAndEnrichEntries.

public static List<ContentEntry> flattenAndEnrichEntries(List<PlaylistEntry> selectedItems, List<List<ContentEntry>> contentEntries) {
    if (selectedItems.size() != contentEntries.size()) {
        throw new IllegalStateException("?!?!?!?");
    }
    Iterator<PlaylistEntry> items = selectedItems.iterator();
    Iterator<List<ContentEntry>> contentItems = contentEntries.iterator();
    while (items.hasNext()) {
        PlaylistEntry currEntry = items.next();
        List<ContentEntry> currContentsForEntry = contentItems.next();
        for (ContentEntry entry : currContentsForEntry) {
            entry.setFullPlaylistInfo(currEntry);
        }
    }
    return contentEntries.stream().flatMap(item -> item.stream()).collect(Collectors.toList());
}
Also used : X509Certificate(java.security.cert.X509Certificate) SSLContext(javax.net.ssl.SSLContext) LoggerFactory(org.slf4j.LoggerFactory) TrustManager(javax.net.ssl.TrustManager) PathService(se.light.assembly64.service.PathService) StringUtils(org.apache.commons.lang3.StringUtils) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ArtifactType(se.light.assembly64.model.ArtifactType) Matcher(java.util.regex.Matcher) Map(java.util.Map) Method(java.lang.reflect.Method) MapType(com.fasterxml.jackson.databind.type.MapType) ContentEntry(se.light.assembly64.model.ContentEntry) TextField(javafx.scene.control.TextField) Artifact(se.light.assembly64.model.Artifact) Collectors(java.util.stream.Collectors) LocalStorageUtil(se.light.assembly64.util.LocalStorageUtil) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) IOUtils(org.apache.commons.io.IOUtils) Base64(java.util.Base64) List(java.util.List) LocalDate(java.time.LocalDate) Pattern(java.util.regex.Pattern) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) GuiLocation(se.light.assembly64.model.GuiLocation) Client(javax.ws.rs.client.Client) HashMap(java.util.HashMap) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) GlobalRepoService(se.light.assembly64.service.GlobalRepoService) SessionInfo(se.light.assembly64.model.SessionInfo) ArrayList(java.util.ArrayList) ClientBuilder(javax.ws.rs.client.ClientBuilder) ExecutorService(java.util.concurrent.ExecutorService) CollectionLikeType(com.fasterxml.jackson.databind.type.CollectionLikeType) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileUtils(org.apache.commons.io.FileUtils) CertificateException(java.security.cert.CertificateException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) File(java.io.File) AtomicLong(java.util.concurrent.atomic.AtomicLong) URLEncoder(java.net.URLEncoder) Paths(java.nio.file.Paths) X509TrustManager(javax.net.ssl.X509TrustManager) DateTimeFormatter(java.time.format.DateTimeFormatter) ObservableValue(javafx.beans.value.ObservableValue) Comparator(java.util.Comparator) ChangeListener(javafx.beans.value.ChangeListener) LocationAndInstallationStatus(se.light.assembly64.model.LocationAndInstallationStatus) ContentEntry(se.light.assembly64.model.ContentEntry) List(java.util.List) ArrayList(java.util.ArrayList) PlaylistEntry(se.light.assembly64.model.PlaylistEntry)

Aggregations

PlaylistEntry (se.light.assembly64.model.PlaylistEntry)19 PlaylistInfo (se.light.assembly64.model.PlaylistInfo)11 File (java.io.File)9 ContentEntry (se.light.assembly64.model.ContentEntry)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)6 Set (java.util.Set)5 Executors (java.util.concurrent.Executors)5 SidTune (libsidplay.sidtune.SidTune)5 SearchException (se.light.assembly64.model.SearchException)5 SongNotAvailableException (se.light.assembly64.model.SongNotAvailableException)5 SpecifyFileIdException (se.light.assembly64.model.SpecifyFileIdException)5 Comparator (java.util.Comparator)4 ChangeListener (javafx.beans.value.ChangeListener)4 ObservableValue (javafx.beans.value.ObservableValue)4 ActionEvent (javafx.event.ActionEvent)4 ContextMenu (javafx.scene.control.ContextMenu)4 Menu (javafx.scene.control.Menu)4 MenuItem (javafx.scene.control.MenuItem)4