Can't getPlaylist
BRKNCD opened this issue · comments
Hello, I'm a very noob user, and I'm trying to retrieve a vary specific Playlist from a very specific userId. It seems that I'm not able to do it, the only examples I found are old and don't help me. Here's what I tried:
https://stackoverflow.com/questions/35110025/accessing-list-of-playlists-from-pager-object
SpotifyApi api = new SpotifyApi();
api.setAccessToken(token);
SpotifyService spotify = api.getService();
spotify.getPlaylists("USERID", new Callback<Pager<Playlist>>() {
@Override
public void success(Pager<Playlist> playlistPager, Response response) {
Log.d("TEST", "Got the playlists");
List<Playlist> playlists = playlistPager.items;
for (Playlist p : playlists) {
Log.e("TEST", p.name + " - " + p.id);
}
}
@Override
public void failure(RetrofitError error) {
Log.e("TEST", "Could not get playlists");
}
});
If I copy-paste this, it underlines Callback<Pager> and gives me the error:
Class 'Anonymous Class derived from Callback' must either be declared abstract or implement abstract method 'onResponse(Call, Response) in 'Callback'
if I press alt+enter and add this method and onFailure and I adapt the succes() and failure() methods to those, it will be:
spotify.getPlaylists("USERID", new Callback<Pager<Playlist>>() {
@Override
public void onResponse(Call<Pager<Playlist>> playlistPager, Response<Pager<Playlist>> response) {
Log.d("TEST", "Got the playlists");
List<Playlist> playlists = playlistPager.items;
for (Playlist p : playlists) {
Log.e("TEST", p.name + " - " + p.id);
}
}
@Override
public void onFailure(Call<Pager<Playlist>> call, Throwable t) {
Log.e("TEST", "Could not get playlists");
}
});
But now, items is red coloured and it gives me this error: Cannot resolve symbol 'items'
and I can't find any solution to this :(
Thank you, and sorry if it's a silly question