use of de.westnordost.streetcomplete.data.osmnotes.CreateNote in project StreetComplete by westnordost.
the class QuestController method createNote.
public void createNote(final String text, final ArrayList<String> imagePaths, LatLon position) {
workerHandler.post(() -> {
CreateNote createNote = new CreateNote();
createNote.position = position;
createNote.text = text;
createNote.imagePaths = imagePaths;
createNoteDB.add(createNote);
});
}
use of de.westnordost.streetcomplete.data.osmnotes.CreateNote in project StreetComplete by westnordost.
the class QuestController method createNote.
/**
* Create a note for the given OSM Quest instead of answering it. The quest will turn
* invisible.
*/
public void createNote(final long osmQuestId, final String questTitle, final String text, final ArrayList<String> imagePaths) {
workerHandler.post(() -> {
OsmQuest q = osmQuestDB.get(osmQuestId);
// race condition: another thread may have removed the element already (#288)
if (q == null)
return;
CreateNote createNote = new CreateNote();
createNote.position = q.getMarkerLocation();
createNote.text = text;
createNote.questTitle = questTitle;
createNote.elementType = q.getElementType();
createNote.elementId = q.getElementId();
createNote.imagePaths = imagePaths;
createNoteDB.add(createNote);
/* The quests that reference the same element for which the user was not able to
answer the question are removed because the to-be-created note blocks quest
creation for other users, so those quests should be removed from the user's
own display as well. As soon as the note is resolved, the quests will be re-
created next time they are downloaded */
List<OsmQuest> questsForThisOsmElement = osmQuestDB.getAll(null, QuestStatus.NEW, null, q.getElementType(), q.getElementId());
List<Long> otherQuestIdsForThisOsmElement = new ArrayList<>(questsForThisOsmElement.size());
for (OsmQuest quest : questsForThisOsmElement) {
if (quest.getId() != osmQuestId)
otherQuestIdsForThisOsmElement.add(quest.getId());
}
/* creating a note instead of "really" solving the quest still counts as solving in
regards of the listener because the user answered to the quest and thats something
that needs to be uploaded */
osmQuestDB.delete(osmQuestId);
relay.onQuestSolved(osmQuestId, QuestGroup.OSM);
osmQuestDB.deleteAll(otherQuestIdsForThisOsmElement);
relay.onQuestsRemoved(otherQuestIdsForThisOsmElement, QuestGroup.OSM);
osmElementDB.deleteUnreferenced();
geometryDB.deleteUnreferenced();
});
}
Aggregations