Use new subsonic api star request.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-08-17 22:38:23 +02:00
parent fdd9540f75
commit 864488510c
2 changed files with 15 additions and 36 deletions

View File

@ -317,42 +317,21 @@ public class RESTMusicService implements MusicService
return String.format(Locale.US, "indexes-%d.ser", Math.abs(s.hashCode()));
}
@Override
public void star(String id, String albumId, String artistId, Context context, ProgressListener progressListener) throws Exception
{
checkServerVersion(context, "1.8", "Starring not supported.");
@Override
public void star(String id,
String albumId,
String artistId,
Context context,
ProgressListener progressListener) throws Exception {
Long apiId = id == null ? null : Long.valueOf(id);
Long apiAlbumId = albumId == null ? null : Long.valueOf(albumId);
Long apiArtistId = artistId == null ? null : Long.valueOf(artistId);
List<String> parameterNames = new LinkedList<String>();
List<Object> parameterValues = new LinkedList<Object>();
if (id != null)
{
parameterNames.add("id");
parameterValues.add(id);
}
if (albumId != null)
{
parameterNames.add("albumId");
parameterValues.add(albumId);
}
if (artistId != null)
{
parameterNames.add("artistId");
parameterValues.add(artistId);
}
Reader reader = getReader(context, progressListener, "star", null, parameterNames, parameterValues);
try
{
new ErrorParser(context).parse(reader);
}
finally
{
Util.close(reader);
}
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.star(apiId, apiAlbumId, apiArtistId).execute();
checkResponseSuccessful(response);
}
@Override
public void unstar(String id, String albumId, String artistId, Context context, ProgressListener progressListener) throws Exception

View File

@ -153,12 +153,12 @@ public class AlbumView extends UpdateView
album.setStarred(false);
}
final MusicService musicService = MusicServiceFactory.getMusicService(view.getContext());
new Thread(new Runnable()
{
@Override
public void run()
{
MusicService musicService = MusicServiceFactory.getMusicService(null);
boolean useId3 = Util.getShouldUseId3Tags(getContext());
try