Search in sources :

Example 1 with SingleElementHandler

use of de.westnordost.osmapi.common.SingleElementHandler in project StreetComplete by westnordost.

the class CreateNoteUpload method findAlreadyExistingNoteWithSameAssociatedElement.

private Note findAlreadyExistingNoteWithSameAssociatedElement(final CreateNote newNote) {
    SingleElementHandler<Note> handler = new SingleElementHandler<Note>() {

        @Override
        public void handle(Note oldNote) {
            if (newNote.hasAssociatedElement()) {
                String firstCommentText = oldNote.comments.get(0).text;
                String newNoteRegex = getAssociatedElementRegex(newNote);
                if (firstCommentText.matches(newNoteRegex)) {
                    super.handle(oldNote);
                }
            }
        }
    };
    final int hideClosedNoteAfter = 7;
    osmDao.getAll(new BoundingBox(newNote.position.getLatitude(), newNote.position.getLongitude(), newNote.position.getLatitude(), newNote.position.getLongitude()), handler, 10, hideClosedNoteAfter);
    return handler.get();
}
Also used : Note(de.westnordost.osmapi.notes.Note) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) SingleElementHandler(de.westnordost.osmapi.common.SingleElementHandler)

Aggregations

SingleElementHandler (de.westnordost.osmapi.common.SingleElementHandler)1 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)1 Note (de.westnordost.osmapi.notes.Note)1