Use new api getChatMessages() call.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-11-16 21:33:04 +01:00
parent 6c1039126e
commit 74bf89ef26
1 changed files with 12 additions and 24 deletions

View File

@ -58,6 +58,7 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient;
import org.moire.ultrasonic.api.subsonic.models.AlbumListType;
import org.moire.ultrasonic.api.subsonic.models.JukeboxAction;
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild;
import org.moire.ultrasonic.api.subsonic.response.ChatMessagesResponse;
import org.moire.ultrasonic.api.subsonic.response.GenresResponse;
import org.moire.ultrasonic.api.subsonic.response.GetAlbumList2Response;
import org.moire.ultrasonic.api.subsonic.response.GetAlbumListResponse;
@ -86,6 +87,7 @@ import org.moire.ultrasonic.api.subsonic.response.StreamResponse;
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse;
import org.moire.ultrasonic.data.APIAlbumConverter;
import org.moire.ultrasonic.data.APIArtistConverter;
import org.moire.ultrasonic.data.APIChatMessageConverter;
import org.moire.ultrasonic.data.APIIndexesConverter;
import org.moire.ultrasonic.data.APIJukeboxConverter;
import org.moire.ultrasonic.data.APILyricsConverter;
@ -1245,31 +1247,17 @@ public class RESTMusicService implements MusicService
return APIUserConverter.toDomainEntity(response.body().getUser());
}
@Override
public List<ChatMessage> getChatMessages(Long since, Context context, ProgressListener progressListener) throws Exception
{
checkServerVersion(context, "1.2", "Chat not supported.");
@Override
public List<ChatMessage> getChatMessages(Long since,
Context context,
ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<ChatMessagesResponse> response = subsonicAPIClient.getApi()
.getChatMessages(since).execute();
checkResponseSuccessful(response);
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS);
List<String> parameterNames = new ArrayList<String>();
List<Object> parameterValues = new ArrayList<Object>();
parameterNames.add("since");
parameterValues.add(since);
Reader reader = getReader(context, progressListener, "getChatMessages", params, parameterNames, parameterValues);
try
{
return new ChatMessageParser(context).parse(reader, progressListener);
}
finally
{
Util.close(reader);
}
}
return APIChatMessageConverter.toDomainEntitiesList(response.body().getChatMessages());
}
@Override
public void addChatMessage(String message, Context context, ProgressListener progressListener) throws Exception