use of com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction in project frostwire by frostwire.
the class BTDownloadMediatorAdvancedMenuFactory method createAddToPlaylistSubMenu.
public static SkinMenu createAddToPlaylistSubMenu() {
BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();
if (downloaders.length == 0) {
return null;
}
for (BTDownload dler : downloaders) {
if (!dler.isCompleted()) {
return null;
}
File saveLocation = dler.getSaveLocation();
if (saveLocation.isDirectory()) {
// If the file(s) is(are) inside a folder
if (!LibraryUtils.directoryContainsAudio(saveLocation)) {
return null;
}
} else if (!MediaPlayer.isPlayableFile(saveLocation)) {
return null;
}
}
SkinMenu menu = new SkinMenu(I18n.tr("Add to playlist"));
menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
Library library = LibraryMediator.getLibrary();
List<Playlist> playlists = library.getPlaylists();
if (playlists.size() > 0) {
menu.addSeparator();
for (Playlist playlist : library.getPlaylists()) {
menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
}
}
return menu;
}
Aggregations