1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-01-22 13:13:23 +01:00

Use new subsonic api call to create playlist.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-09-02 20:51:10 +02:00
parent bb64b9e3ca
commit fcb5210a3b

View File

@ -573,38 +573,25 @@ public class RESTMusicService implements MusicService
return APIPlaylistConverter.toDomainEntitiesList(response.body().getPlaylists()); return APIPlaylistConverter.toDomainEntitiesList(response.body().getPlaylists());
} }
@Override @Override
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries, Context context, ProgressListener progressListener) throws Exception public void createPlaylist(String id,
{ String name,
List<String> parameterNames = new LinkedList<String>(); List<MusicDirectory.Entry> entries,
List<Object> parameterValues = new LinkedList<Object>(); Context context,
ProgressListener progressListener) throws Exception {
Long pId = id == null ? null : Long.valueOf(id);
List<Long> pSongIds = new ArrayList<>(entries.size());
for (MusicDirectory.Entry entry : entries) {
if (entry.getId() != null) {
pSongIds.add(Long.valueOf(entry.getId()));
}
}
if (id != null) updateProgressListener(progressListener, R.string.parser_reading);
{ Response<SubsonicResponse> response = subsonicAPIClient.getApi()
parameterNames.add("playlistId"); .createPlaylist(pId, name, pSongIds).execute();
parameterValues.add(id); checkResponseSuccessful(response);
} }
if (name != null)
{
parameterNames.add("name");
parameterValues.add(name);
}
for (MusicDirectory.Entry entry : entries)
{
parameterNames.add("songId");
parameterValues.add(entry.getId());
}
Reader reader = getReader(context, progressListener, "createPlaylist", null, parameterNames, parameterValues);
try
{
new ErrorParser(context).parse(reader);
}
finally
{
Util.close(reader);
}
}
@Override @Override
public void deletePlaylist(String id, Context context, ProgressListener progressListener) throws Exception public void deletePlaylist(String id, Context context, ProgressListener progressListener) throws Exception