Search in sources :

Example 6 with PlaylistInfo

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

the class SidifyViewPublicPlaylistsController method init.

public void init(Runnable updateCallback) {
    publicLists.setPlaceholder(new Label("No more public lists to follow"));
    name.setCellValueFactory(new PropertyValueFactory<PlaylistInfo, String>("name"));
    ownerAlias.setCellValueFactory(new PropertyValueFactory<PlaylistInfo, String>("ownerAlias"));
    playListService = PlaylistService.getInstance();
    populateList();
    publicLists.setOnMousePressed(event -> {
        PlaylistInfo selectedItem = publicLists.getSelectionModel().getSelectedItem();
        if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
            final ContextMenu contextMenu = new ContextMenu();
            MenuItem infoItem = new MenuItem("Playlistinfo");
            infoItem.setOnAction((ActionEvent event2) -> {
                GuiUtils.showDialog("sidifyViewPublicPlaylistInfo.fxml", Boolean.TRUE, "Playlistinfo", getStage(), new Object[] { selectedItem });
            });
            MenuItem mItem = new MenuItem("Subscribe to list");
            mItem.setOnAction((ActionEvent event2) -> {
                Analytics.sendEvent("sidify", "subscribe_playlist");
                playListService.subscribeToPlaylist(selectedItem.getId());
                playListService.resetAndGetPublicPlaylists();
                populateList();
                updateCallback.run();
            });
            MenuItem mItem2 = new MenuItem("Copy & add to new playlist");
            mItem2.setOnAction((ActionEvent event2) -> {
                Analytics.sendEvent("sidify", "copyadd_playlist");
                SidifyCreatePlaylistController controller = GuiUtils.showDialog("sidifyCreateNewPlaylist.fxml", Boolean.TRUE, "Create new playlist", getStage(), new Object[] { null, true });
                playListService.copyPlaylist(selectedItem.getId(), controller.getNewlyCreatedPlayList().getId());
                updateCallback.run();
            });
            Menu mItem3 = new Menu("Copy & add to existing playlist");
            for (PlaylistInfo plist : playListService.getPlaylistInfo()) {
                Analytics.sendEvent("sidify", "add_to_existing_playlist");
                PlaylistMenuItem menuItemPl = new PlaylistMenuItem(plist);
                menuItemPl.setOnAction((ActionEvent event2) -> {
                    playListService.copyPlaylist(selectedItem.getId(), menuItemPl.getPlaylist().getId());
                });
                mItem3.getItems().add(menuItemPl);
            }
            contextMenu.getItems().add(infoItem);
            contextMenu.getItems().add(mItem);
            contextMenu.getItems().add(mItem2);
            contextMenu.getItems().add(mItem3);
            publicLists.setContextMenu(contextMenu);
        } else if (event.getClickCount() == 2) {
            GuiUtils.showDialog("sidifyViewPublicPlaylist.fxml", Boolean.TRUE, "Contents of playlist", getStage(), new Object[] { playListService.getSongsForPlaylist(selectedItem) });
        }
    });
}
Also used : PlaylistMenuItem(se.light.assembly64.model.PlaylistMenuItem) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) PlaylistMenuItem(se.light.assembly64.model.PlaylistMenuItem) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Example 7 with PlaylistInfo

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

the class PlaylistService method copyPlaylist.

public PlaylistInfo copyPlaylist(String id, String targetId) {
    if (!myPlaylistIds().contains(id)) {
        PlaylistInfo newPlaylist = getClient().target(server).path("/leet/playlistsnew/copyplaylist/" + id + "/" + targetId).request().header("email", email).header("token", token).get(PlaylistInfo.class);
        String tmpId = newPlaylist.getId();
        PlaylistInfo playlistInfo = playlists.stream().filter(item -> item.getId().equals(tmpId)).findFirst().get();
        playlistInfo.setChecksum(newPlaylist.getChecksum());
        newPlaylist = playlistInfo;
        FileUtils.deleteQuietly(resolvePlaylistFilename(newPlaylist));
        playlistSongs.remove(newPlaylist.getId());
        flush(playlists, resolvePlaylistInfoFilename());
        Analytics.sendEvent("sidify", "copyplaylist");
        getSongsForPlaylist(newPlaylist);
        return newPlaylist;
    } else {
        return getPlaylistInfo(id);
    }
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 8 with PlaylistInfo

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

the class PlaylistService method renamePlaylist.

public void renamePlaylist(String id, String name, Boolean publicList) {
    Response response = null;
    try {
        response = getClient().target(server).path("/leet/playlistsnew/alterplaylist/" + id + "/" + name + "/" + Boolean.toString(publicList)).request().header("email", email).header("token", token).get();
        if (response.getStatus() == 200) {
            Optional<PlaylistInfo> list = getPlaylistInfo(false).stream().filter(item -> item.getId().equals(id)).findFirst();
            if (list.isPresent()) {
                list.get().setName(name);
                list.get().setPublicList(false);
            }
        }
        flushPlaylistInfo();
        Analytics.sendEvent("sidify", "renameplaylist");
    } finally {
        response.close();
    }
}
Also used : Response(javax.ws.rs.core.Response) Support.isOffline(se.light.assembly64.Support.isOffline) ReturningTask(se.light.assembly64.model.ReturningTask) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Support.getBackendServer(se.light.assembly64.Support.getBackendServer) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) ArrayList(java.util.ArrayList) Support.getSessionInfo(se.light.assembly64.Support.getSessionInfo) Support.getChksum(se.light.assembly64.Support.getChksum) ExecutorUtil.executeAsyncWithRetry(se.light.assembly64.util.ExecutorUtil.executeAsyncWithRetry) Map(java.util.Map) Support(se.light.assembly64.Support) PlaylistChecksum(se.light.assembly64.model.PlaylistChecksum) Support.flush(se.light.assembly64.Support.flush) ContentEntry(se.light.assembly64.model.ContentEntry) MD5Method(libsidplay.sidtune.MD5Method) Analytics(se.light.assembly64.Analytics) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SidTune(libsidplay.sidtune.SidTune) SidFileInfo(se.light.assembly64.model.SidFileInfo) Support.getClient(se.light.assembly64.Support.getClient) Set(java.util.Set) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) Entity(javax.ws.rs.client.Entity) File(java.io.File) Executors(java.util.concurrent.Executors) GenericType(javax.ws.rs.core.GenericType) Support.readList(se.light.assembly64.Support.readList) List(java.util.List) Response(javax.ws.rs.core.Response) Entry(java.security.KeyStore.Entry) Optional(java.util.Optional) StringKeys(se.light.assembly64.model.StringKeys) PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 9 with PlaylistInfo

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

the class Support method getChksumPInfo.

public static long getChksumPInfo(List<PlaylistInfo> playlistInfoList, boolean isPublic) {
    long sum = 0;
    int ctr = 1;
    for (PlaylistInfo item : playlistInfoList) {
        if (!item.getId().equals("-1")) {
            sum += item.getChecksum() * ctr;
            sum += getSumOfName(item.getId());
            sum += getSumOfName(item.getName());
            sum += getSumOfName(item.getOwnerAlias());
            if (isPublic) {
                sum += item.getFollowers();
            }
            sum += getSumOfName(item.getPublicList().toString()) * ctr;
        }
    }
    return sum;
}
Also used : PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

Example 10 with PlaylistInfo

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

the class SidifyMainContoller method updateSelectedSong.

private void updateSelectedSong() {
    if (songlist.getItems().size() > 0) {
        PlaylistEntry firstItemInViewedList = songlist.getItems().get(0);
        PlaylistInfo entrysPlaylist = playListService.getPlaylistForSong(firstItemInViewedList);
        if (entrysPlaylist != null && entrysPlaylist.getId().equals(activePlaylist.getId())) {
            // songlist.getSelectionModel().select(getActiveSongInList());
            clearAndSelect(getActiveSongInList());
        }
    }
}
Also used : PlaylistEntry(se.light.assembly64.model.PlaylistEntry) PlaylistInfo(se.light.assembly64.model.PlaylistInfo)

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