Search in sources :

Example 1 with PlaylistStreamEntity

use of org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity in project NewPipe by TeamNewPipe.

the class LocalPlaylistManager method updateJoin.

public Completable updateJoin(final long playlistId, final List<Long> streamIds) {
    List<PlaylistStreamEntity> joinEntities = new ArrayList<>(streamIds.size());
    for (int i = 0; i < streamIds.size(); i++) {
        joinEntities.add(new PlaylistStreamEntity(playlistId, streamIds.get(i), i));
    }
    return Completable.fromRunnable(() -> database.runInTransaction(() -> {
        playlistStreamTable.deleteBatch(playlistId);
        playlistStreamTable.insertAll(joinEntities);
    })).subscribeOn(Schedulers.io());
}
Also used : PlaylistStreamEntity(org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity) ArrayList(java.util.ArrayList)

Example 2 with PlaylistStreamEntity

use of org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity in project NewPipe by TeamNewPipe.

the class LocalPlaylistManager method upsertStreams.

private List<Long> upsertStreams(final long playlistId, final List<StreamEntity> streams, final int indexOffset) {
    List<PlaylistStreamEntity> joinEntities = new ArrayList<>(streams.size());
    final List<Long> streamIds = streamTable.upsertAll(streams);
    for (int index = 0; index < streamIds.size(); index++) {
        joinEntities.add(new PlaylistStreamEntity(playlistId, streamIds.get(index), index + indexOffset));
    }
    return playlistStreamTable.insertAll(joinEntities);
}
Also used : PlaylistStreamEntity(org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 PlaylistStreamEntity (org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity)2