use of com.zype.fire.api.Model.PlaylistsResponse in project zype-firebuilder by zype.
the class ZypeApi method getPlaylists.
public PlaylistsResponse getPlaylists(int page) {
try {
HashMap<String, String> params = new HashMap<>();
params.put(APP_KEY, ZypeSettings.APP_KEY);
params.put(PER_PAGE, String.valueOf(300));
Response response = apiImpl.getPlaylists(page, params).execute();
if (response.isSuccessful()) {
return (PlaylistsResponse) response.body();
} else {
return null;
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
use of com.zype.fire.api.Model.PlaylistsResponse in project zype-firebuilder by zype.
the class ZypeDataDownloader method loadPlaylists.
private List<PlaylistData> loadPlaylists() {
List<PlaylistData> result = new ArrayList<>();
int page = 1;
PlaylistsResponse playlistsResponse = ZypeApi.getInstance().getPlaylists(page);
if (playlistsResponse != null && playlistsResponse.response != null) {
result.addAll(playlistsResponse.response);
if (playlistsResponse.pagination != null && playlistsResponse.pagination.pages > 1) {
for (page = playlistsResponse.pagination.next; page <= playlistsResponse.pagination.pages; page++) {
playlistsResponse = ZypeApi.getInstance().getPlaylists(page);
if (playlistsResponse != null && playlistsResponse.response != null) {
result.addAll(playlistsResponse.response);
}
}
}
}
return result;
}
Aggregations