Search in sources :

Example 1 with Playlist

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);
}
Also used : Playlist(com.frostwire.alexandria.Playlist)

Example 2 with Playlist

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;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) Playlist(com.frostwire.alexandria.Playlist) SkinMenu(com.frostwire.gui.theme.SkinMenu) Library(com.frostwire.alexandria.Library)

Example 3 with Playlist

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;
}
Also used : Playlist(com.frostwire.alexandria.Playlist) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with 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;
}
Also used : Playlist(com.frostwire.alexandria.Playlist) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with Playlist

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);
}
Also used : Playlist(com.frostwire.alexandria.Playlist) Library(com.frostwire.alexandria.Library)

Aggregations

Playlist (com.frostwire.alexandria.Playlist)18 Library (com.frostwire.alexandria.Library)4 PlaylistItem (com.frostwire.alexandria.PlaylistItem)3 DialogFinishedListener (com.frostwire.gui.theme.DialogFinishedListener)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SkinMenu (com.frostwire.gui.theme.SkinMenu)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 File (java.io.File)2 AddToPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction)1 CreateNewPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction)1 MediaSource (com.frostwire.gui.player.MediaSource)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1