use of de.westnordost.streetcomplete.data.QuestStatus in project StreetComplete by westnordost.
the class OsmNoteQuestDao method createObjectFrom.
@Override
protected OsmNoteQuest createObjectFrom(Cursor cursor) {
int colQuestId = cursor.getColumnIndexOrThrow(Columns.QUEST_ID), colNoteId = cursor.getColumnIndexOrThrow(Columns.NOTE_ID), colQuestStatus = cursor.getColumnIndexOrThrow(Columns.QUEST_STATUS), colComment = cursor.getColumnIndexOrThrow(Columns.COMMENT), colLastUpdate = cursor.getColumnIndexOrThrow(Columns.LAST_UPDATE), colImagePaths = cursor.getColumnIndexOrThrow(Columns.IMAGE_PATHS);
long questId = cursor.getLong(colQuestId);
String comment = null;
if (!cursor.isNull(colComment)) {
comment = cursor.getString(colComment);
}
QuestStatus status = QuestStatus.valueOf(cursor.getString(colQuestStatus));
ArrayList<String> imagePaths = new ArrayList<>();
if (!cursor.isNull(colImagePaths)) {
imagePaths = serializer.toObject(cursor.getBlob(colImagePaths), ArrayList.class);
}
Date lastUpdate = new Date(cursor.getLong(colLastUpdate));
Note note = null;
if (!cursor.isNull(colNoteId)) {
note = NoteDao.createObjectFrom(serializer, cursor);
}
return new OsmNoteQuest(questId, note, status, comment, lastUpdate, questType, imagePaths);
}
use of de.westnordost.streetcomplete.data.QuestStatus in project StreetComplete by westnordost.
the class ApplyNoteVisibilityChangedTask method doInBackground.
@Override
protected Void doInBackground(Void... voids) {
boolean showNonQuestionNotes = prefs.getBoolean(Prefs.SHOW_NOTES_NOT_PHRASED_AS_QUESTIONS, false);
for (OsmNoteQuest quest : osmNoteQuestDao.getAll(null, null)) {
if (quest.getStatus() == QuestStatus.NEW || quest.getStatus() == QuestStatus.INVISIBLE) {
boolean visible = quest.probablyContainsQuestion() || showNonQuestionNotes;
QuestStatus newQuestStatus = visible ? QuestStatus.NEW : QuestStatus.INVISIBLE;
if (quest.getStatus() != newQuestStatus) {
quest.setStatus(newQuestStatus);
osmNoteQuestDao.update(quest);
}
}
}
return null;
}
use of de.westnordost.streetcomplete.data.QuestStatus in project StreetComplete by westnordost.
the class AOsmQuestDao method createObjectFrom.
@Override
protected OsmQuest createObjectFrom(Cursor cursor) {
int colQuestId = cursor.getColumnIndexOrThrow(Columns.QUEST_ID), colElementId = cursor.getColumnIndexOrThrow(Columns.ELEMENT_ID), colElementType = cursor.getColumnIndexOrThrow(Columns.ELEMENT_TYPE), colQuestStatus = cursor.getColumnIndexOrThrow(Columns.QUEST_STATUS), colQuestType = cursor.getColumnIndexOrThrow(Columns.QUEST_TYPE), colChanges = cursor.getColumnIndexOrThrow(Columns.TAG_CHANGES), colChangesSource = cursor.getColumnIndexOrThrow(Columns.CHANGES_SOURCE), colLastChange = cursor.getColumnIndexOrThrow(Columns.LAST_UPDATE);
long questId = cursor.getLong(colQuestId);
long elementId = cursor.getLong(colElementId);
Element.Type elementType = Element.Type.valueOf(cursor.getString(colElementType));
QuestStatus questStatus = QuestStatus.valueOf(cursor.getString(colQuestStatus));
String questTypeName = cursor.getString(colQuestType);
OsmElementQuestType questType = (OsmElementQuestType) questTypeRegistry.getByName(questTypeName);
if (questType == null) {
throw new IllegalArgumentException("The quest type " + questTypeName + " does not exist!");
}
StringMapChanges changes = null;
if (!cursor.isNull(colChanges)) {
changes = serializer.toObject(cursor.getBlob(colChanges), StringMapChanges.class);
}
String changesSource = null;
if (!cursor.isNull(colChangesSource)) {
changesSource = cursor.getString(colChangesSource);
}
ElementGeometry geometry = ElementGeometryDao.createObjectFrom(serializer, cursor);
Date lastChange = new Date(cursor.getLong(colLastChange));
return new OsmQuest(questId, questType, elementType, elementId, questStatus, changes, changesSource, lastChange, geometry);
}
Aggregations