use of com.frostwire.gui.theme.DialogFinishedListener in project frostwire by frostwire.
the class LibraryUtils method createNewPlaylist.
static void createNewPlaylist(final List<? extends AbstractLibraryTableDataLine<?>> lines) {
DialogFinishedListener dialogListener = new DialogFinishedListener() {
@Override
public void onDialogCancelled() {
}
@Override
public void onDialogOk(String playlistName) {
if (playlistName != null && playlistName.length() > 0) {
final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);
playlist.save();
LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
LibraryMediator.instance().getLibraryPlaylists().markBeginImport(playlist);
Thread t = new Thread(new Runnable() {
public void run() {
addToPlaylist(playlist, lines);
playlist.save();
asyncAddToPlaylistFinalizer(playlist);
}
}, "createNewPlaylist");
t.setDaemon(true);
t.start();
UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
}
}
};
FrostwireInputDialog.showInputDialog(GUIMediator.getAppFrame(), I18n.tr("Playlist name"), I18n.tr("Playlist name"), GUIMediator.getThemeImage("playlist"), suggestPlaylistName(lines), dialogListener);
}
use of com.frostwire.gui.theme.DialogFinishedListener in project frostwire by frostwire.
the class LibraryUtils method createNewPlaylist.
static void createNewPlaylist(final PlaylistItem[] playlistItems, boolean starred) {
if (starred) {
createStarredPlaylist(playlistItems);
} else {
DialogFinishedListener listener = new DialogFinishedListener() {
@Override
public void onDialogCancelled() {
}
@Override
public void onDialogOk(String playlistName) {
if (playlistName != null && playlistName.length() > 0) {
final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);
Thread t = new Thread(new Runnable() {
public void run() {
try {
playlist.save();
addToPlaylist(playlist, playlistItems);
playlist.save();
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
}
});
UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
} finally {
asyncAddToPlaylistFinalizer(playlist);
}
}
}, "createNewPlaylist");
t.setDaemon(true);
t.start();
}
}
};
FrostwireInputDialog.showInputDialog(GUIMediator.getAppFrame(), I18n.tr("Playlist name"), I18n.tr("Playlist name"), GUIMediator.getThemeImage("playlist"), suggestPlaylistName(playlistItems), listener);
}
}
use of com.frostwire.gui.theme.DialogFinishedListener in project frostwire by frostwire.
the class LibraryUtils method createNewPlaylist.
static void createNewPlaylist(final File[] files, final boolean starred) {
final DialogFinishedListener listener = new DialogFinishedListener() {
@Override
public void onDialogCancelled() {
}
@Override
public void onDialogOk(String playlistName) {
if (StringUtils.isNullOrEmpty(playlistName, true)) {
return;
}
if (playlistName.length() > 0) {
GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY);
final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);
playlist.save();
GUIMediator.safeInvokeLater(new Runnable() {
@Override
public void run() {
LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
LibraryMediator.instance().getLibraryPlaylists().markBeginImport(playlist);
}
});
Thread t = new Thread(new Runnable() {
public void run() {
try {
Set<File> ignore = TorrentUtil.getIgnorableFiles();
addToPlaylist(playlist, files, starred, ignore);
playlist.save();
} finally {
asyncAddToPlaylistFinalizer(playlist);
}
}
}, "createNewPlaylist");
t.setDaemon(true);
t.start();
UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
}
}
};
GUIMediator.safeInvokeAndWait(new Runnable() {
@Override
public void run() {
File[] mediaFiles = files;
if (files.length == 1 && files[0].isDirectory()) {
mediaFiles = FileUtils.getFilesRecursive(files[0], null);
}
FrostwireInputDialog.showInputDialog(GUIMediator.getAppFrame(), I18n.tr("Playlist name"), I18n.tr("Playlist name"), GUIMediator.getThemeImage("playlist"), suggestPlaylistName(mediaFiles), listener);
}
});
}
Aggregations