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;
}
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();
}
}
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;
}
Aggregations