use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryExplorer method refreshSelection.
void refreshSelection(boolean clearCache) {
LibraryNode node = (LibraryNode) tree.getLastSelectedPathComponent();
String searchPrompt = null;
if (node == null) {
return;
}
LibraryMediator.instance().clearLibraryTable();
DirectoryHolder directoryHolder = getSelectedDirectoryHolder();
// STARRED
if (directoryHolder instanceof StarredDirectoryHolder) {
Playlist playlist = LibraryMediator.getLibrary().getStarredPlaylist();
LibraryMediator.instance().updateTableItems(playlist);
String status = LibraryUtils.getPlaylistDurationInDDHHMMSS(playlist) + ", " + playlist.getItems().size() + " " + I18n.tr("tracks");
LibraryMediator.instance().getLibrarySearch().setStatus(status);
} else // TORRENTS
if (directoryHolder instanceof TorrentDirectoryHolder) {
LibraryMediator.instance().updateTableFiles(directoryHolder);
} else // SAVED FILES FOLDER
if (directoryHolder instanceof SavedFilesDirectoryHolder) {
if (clearCache) {
((SavedFilesDirectoryHolder) directoryHolder).clearCache();
}
LibraryMediator.instance().updateTableFiles(directoryHolder);
} else // MEDIA TYPES
if (directoryHolder instanceof MediaTypeSavedFilesDirectoryHolder) {
MediaTypeSavedFilesDirectoryHolder mtsfdh = (MediaTypeSavedFilesDirectoryHolder) directoryHolder;
if (clearCache) {
mtsfdh.clearCache();
}
LibraryMediator.instance().updateTableFiles(directoryHolder);
BackgroundExecutorService.schedule(new SearchByMediaTypeRunnable(mtsfdh));
}
saveLastSelectedDirectoryHolder();
if (searchPrompt == null) {
searchPrompt = I18n.tr("Search your") + " " + node.getUserObject();
}
LibraryMediator.instance().getLibrarySearch().clear();
LibraryMediator.instance().getLibrarySearch().setSearchPrompt(searchPrompt);
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class AbstractLibraryTableMediator method createAddToPlaylistSubMenu.
SkinMenu createAddToPlaylistSubMenu() {
SkinMenu menu = new SkinMenu(tr("Add to playlist"));
menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
Playlist currentPlaylist = LibraryMediator.instance().getSelectedPlaylist();
Playlist starredPlaylist = LibraryMediator.getLibrary().getStarredPlaylist();
if (currentPlaylist == null || !currentPlaylist.equals(starredPlaylist)) {
addToStarredPlaylistMenuItem(menu, starredPlaylist);
}
Library library = LibraryMediator.getLibrary();
List<Playlist> playlists = library.getPlaylists();
if (playlists.size() > 0) {
menu.addSeparator();
for (Playlist playlist : library.getPlaylists()) {
if (currentPlaylist != null && currentPlaylist.equals(playlist)) {
continue;
}
menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
}
}
return menu;
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class PlaylistDB method getPlaylist.
public static Playlist getPlaylist(LibraryDatabase db, String name) {
List<List<Object>> result = db.query("SELECT playlistId, name, description FROM Playlists WHERE name = ?", name);
Playlist playlist = null;
if (result.size() > 0) {
List<Object> row = result.get(0);
playlist = new Playlist(db);
PlaylistDB.fill(row, playlist);
}
return playlist;
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class PlaylistDB method getPlaylists.
public static List<Playlist> getPlaylists(LibraryDatabase db) {
List<List<Object>> result = db.query("SELECT playlistId, name, description FROM Playlists");
List<Playlist> playlists = new ArrayList<>(result.size());
for (List<Object> row : result) {
Playlist playlist = new Playlist(db);
PlaylistDB.fill(row, playlist);
playlists.add(playlist);
}
return playlists;
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryPlaylists method createNewPlaylist.
private void createNewPlaylist() {
if (!textName.isVisible()) {
return;
}
String name = textName.getText();
Library library = LibraryMediator.getLibrary();
Playlist playlist = library.newPlaylist(name, name);
playlist.save();
LibraryPlaylistsListCell cell = new LibraryPlaylistsListCell(null, null, GUIMediator.getThemeImage("playlist"), playlist, selectedPlaylistAction);
model.addElement(cell);
list.setSelectedValue(cell, true);
textName.setVisible(false);
UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
}
Aggregations