Search in sources :

Example 1 with QuestStatus

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);
}
Also used : Note(de.westnordost.osmapi.notes.Note) ArrayList(java.util.ArrayList) QuestStatus(de.westnordost.streetcomplete.data.QuestStatus) Date(java.util.Date)

Example 2 with QuestStatus

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;
}
Also used : QuestStatus(de.westnordost.streetcomplete.data.QuestStatus) OsmNoteQuest(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuest)

Example 3 with QuestStatus

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);
}
Also used : OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) StringMapChanges(de.westnordost.streetcomplete.data.osm.changes.StringMapChanges) Element(de.westnordost.osmapi.map.data.Element) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) QuestStatus(de.westnordost.streetcomplete.data.QuestStatus) Date(java.util.Date)

Aggregations

QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)3 Date (java.util.Date)2 Element (de.westnordost.osmapi.map.data.Element)1 Note (de.westnordost.osmapi.notes.Note)1 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)1 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)1 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)1 StringMapChanges (de.westnordost.streetcomplete.data.osm.changes.StringMapChanges)1 OsmNoteQuest (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuest)1 ArrayList (java.util.ArrayList)1