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) });
}
});
}
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);
}
}
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();
}
}
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;
}
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());
}
}
}
Aggregations