use of io.jawg.osmcontributor.rest.events.error.SyncDownloadRetrofitErrorEvent in project osm-contributor by jawg.
the class OSMSyncNoteManager method syncDownloadNotesInBox.
/**
* {@inheritDoc}
*/
@Override
public List<Note> syncDownloadNotesInBox(final Box box) {
Timber.d("Requesting osm for notes download");
String strBox = box.getWest() + "," + box.getSouth() + "," + box.getEast() + "," + box.getNorth();
Call<OsmDto> osmDtoCall = osmRestClient.getNotes(strBox);
try {
Response<OsmDto> response = osmDtoCall.execute();
if (response.isSuccessful()) {
OsmDto osmDto = response.body();
if (osmDto != null) {
List<NoteDto> noteDtos = osmDto.getNoteDtoList();
if (noteDtos != null && !noteDtos.isEmpty()) {
Timber.d("Updating %d note(s)", noteDtos.size());
bus.post(new SyncDownloadRetrofitErrorEvent());
return noteMapper.convertNoteDtosToNotes(noteDtos);
}
}
}
} catch (IOException e) {
Timber.e(e, e.getMessage());
}
return null;
}
Aggregations