Search in sources :

Example 26 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class PlaylistDB method getStarredPlaylist.

public static Playlist getStarredPlaylist(LibraryDatabase db) {
    String query = "SELECT playlistItemId, filePath, fileName, fileSize, fileExtension, trackTitle, trackDurationInSecs, trackArtist, trackAlbum, coverArtPath, trackBitrate, trackComment, trackGenre, trackNumber, trackYear, starred " + "FROM PlaylistItems WHERE starred = ?";
    List<List<Object>> result = db.query(query, true);
    Playlist playlist = new Playlist(db, LibraryDatabase.STARRED_PLAYLIST_ID, LibraryDatabase.STARRED_TABLE_NAME_DO_NOT_TRANSLATE_THIS, LibraryDatabase.STARRED_TABLE_NAME_DO_NOT_TRANSLATE_THIS);
    List<PlaylistItem> items = new ArrayList<>(result.size());
    Set<String> paths = new HashSet<>();
    for (List<Object> row : result) {
        PlaylistItem item = new PlaylistItem(playlist);
        PlaylistItemDB.fill(row, item);
        if (!paths.contains(item.getFilePath())) {
            items.add(item);
            paths.add(item.getFilePath());
        }
    }
    playlist.getItems().addAll(items);
    return playlist;
}
Also used : Playlist(com.frostwire.alexandria.Playlist) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PlaylistItem(com.frostwire.alexandria.PlaylistItem) HashSet(java.util.HashSet)

Example 27 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class PlaylistDB method save.

public static void save(LibraryDatabase db, Playlist obj) {
    if (obj.getId() == LibraryDatabase.OBJECT_INVALID_ID) {
        return;
    }
    if (obj.getId() == LibraryDatabase.OBJECT_NOT_SAVED_ID) {
        int id = db.insert("INSERT INTO Playlists (name, description) VALUES (LEFT(?, 500), LEFT(?, 10000))", obj.getName(), obj.getDescription());
        obj.setId(id);
    } else {
        db.update("DELETE FROM PlaylistItems WHERE playlistId = ?", obj.getId());
        Object[] statementObjects = createPlaylistUpdateStatement(obj);
        db.update((String) statementObjects[0], (Object[]) statementObjects[1]);
    }
    List<PlaylistItem> items = new ArrayList<>(obj.getItems());
    for (PlaylistItem item : items) {
        item.setId(LibraryDatabase.OBJECT_NOT_SAVED_ID);
        item.save();
    }
}
Also used : ArrayList(java.util.ArrayList) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 28 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class PlaylistItemDB method getPlaylistItems.

public static List<PlaylistItem> getPlaylistItems(LibraryDatabase db, Playlist playlist) {
    String query = "SELECT playlistItemId, filePath, fileName, fileSize, fileExtension, trackTitle, trackDurationInSecs, trackArtist, trackAlbum, coverArtPath, trackBitrate, trackComment, trackGenre, trackNumber, trackYear, starred, sortIndex " + "FROM PlaylistItems WHERE playlistId = ? ORDER BY sortIndex ASC";
    List<List<Object>> result = db.query(query, playlist.getId());
    List<PlaylistItem> items = new ArrayList<>(result.size());
    for (List<Object> row : result) {
        PlaylistItem item = new PlaylistItem(playlist);
        PlaylistItemDB.fill(row, item);
        items.add(item);
    }
    return items;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Aggregations

PlaylistItem (com.frostwire.alexandria.PlaylistItem)28 ArrayList (java.util.ArrayList)8 File (java.io.File)7 Transferable (java.awt.datatransfer.Transferable)4 Playlist (com.frostwire.alexandria.Playlist)3 Item (com.frostwire.gui.library.LibraryPlaylistsTableTransferable.Item)3 List (java.util.List)3 TagsReader (com.frostwire.gui.library.tags.TagsReader)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 SkinPopupMenu (com.frostwire.gui.theme.SkinPopupMenu)2 MigLayout (net.miginfocom.swing.MigLayout)2 TagsData (com.frostwire.gui.library.tags.TagsData)1 IsoFile (com.frostwire.mp4.IsoFile)1 FileTransferable (com.limegroup.gnutella.gui.dnd.FileTransferable)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 HashSet (java.util.HashSet)1