
co.fusionx.spotify.component.sync.SyncBaseComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotify-web-api Show documentation
Show all versions of spotify-web-api Show documentation
Library which allows easy async and sync access to the Spotify Web APIs
The newest version!
package co.fusionx.spotify.component.sync;
import com.fasterxml.jackson.databind.ObjectMapper;
import co.fusionx.spotify.component.BaseComponent;
import co.fusionx.spotify.json.JacksonConverter;
import co.fusionx.spotify.model.PagingObject;
import co.fusionx.spotify.util.Util;
import retrofit.RestAdapter;
public class SyncBaseComponent implements BaseComponent {
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
protected static final String SPOTIFY_URL = "https://api.spotify.com/v1";
protected final RestAdapter mRestAdapter;
public SyncBaseComponent() {
mRestAdapter = new RestAdapter.Builder()
.setEndpoint(SPOTIFY_URL)
.setConverter(new JacksonConverter(OBJECT_MAPPER))
.build();
}
@Override
public U previousPage(final PagingObject pagingObject, final Class result) {
if (Util.isEmpty(pagingObject.getPrevious())) {
return null;
}
return Util.getJsonPojoFromUrl(pagingObject.getPrevious(), result);
}
@Override
public U nextPage(final PagingObject pagingObject, final Class result) {
if (Util.isEmpty(pagingObject.getNext())) {
return null;
}
return Util.getJsonPojoFromUrl(pagingObject.getNext(), result);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy