Search in sources :

Example 1 with SyncDownloadRetrofitErrorEvent

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;
}
Also used : OsmDto(io.jawg.osmcontributor.rest.dtos.osm.OsmDto) SyncDownloadRetrofitErrorEvent(io.jawg.osmcontributor.rest.events.error.SyncDownloadRetrofitErrorEvent) IOException(java.io.IOException) NoteDto(io.jawg.osmcontributor.rest.dtos.osm.NoteDto)

Aggregations

NoteDto (io.jawg.osmcontributor.rest.dtos.osm.NoteDto)1 OsmDto (io.jawg.osmcontributor.rest.dtos.osm.OsmDto)1 SyncDownloadRetrofitErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncDownloadRetrofitErrorEvent)1 IOException (java.io.IOException)1