Search in sources :

Example 6 with QuestType

use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.

the class QuestDownload method downloadQuestTypes.

private void downloadQuestTypes(BoundingBox bbox, List<QuestType> questTypes, Set<LatLon> notesPositions) {
    for (QuestType questType : questTypes) {
        if (cancelState.get())
            break;
        if (maxQuestTypes != null && downloadedQuestTypes >= maxQuestTypes)
            break;
        if (questType instanceof OsmElementQuestType) {
            OsmQuestDownload questDownload = questDownloadProvider.get();
            questDownload.setQuestListener(questListener);
            if (questDownload.download((OsmElementQuestType) questType, bbox, notesPositions)) {
                downloadedTilesDao.put(tiles, questType.getClass().getSimpleName());
            }
            downloadedQuestTypes++;
            dispatchProgress();
        }
    }
}
Also used : OsmNoteQuestType(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType) OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) QuestType(de.westnordost.streetcomplete.data.QuestType) OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) OsmQuestDownload(de.westnordost.streetcomplete.data.osm.download.OsmQuestDownload)

Example 7 with QuestType

use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.

the class QuestSelectionFragment method createQuestTypeVisibilityList.

private List<QuestSelectionAdapter.QuestVisibility> createQuestTypeVisibilityList() {
    List<QuestType> questTypes = new ArrayList<>(questTypeRegistry.getAll());
    questTypeOrderList.sort(questTypes);
    List<QuestSelectionAdapter.QuestVisibility> result = new ArrayList<>(questTypes.size());
    for (QuestType questType : questTypes) {
        QuestSelectionAdapter.QuestVisibility questVisibility = new QuestSelectionAdapter.QuestVisibility();
        questVisibility.questType = questType;
        questVisibility.visible = visibleQuestTypeDao.isVisible(questType);
        result.add(questVisibility);
    }
    return result;
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) ArrayList(java.util.ArrayList)

Example 8 with QuestType

use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.

the class QuestsMapFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    questTypeOrder = new HashMap<>();
    int order = 0;
    for (QuestType questType : questTypesProvider.get()) {
        questTypeOrder.put(questType, order++);
    }
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) Point(android.graphics.Point)

Example 9 with QuestType

use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.

the class TangramQuestSpriteSheetCreator method getQuestIconResourceIds.

private Set<Integer> getQuestIconResourceIds() {
    List<QuestType> questTypeList = questTypeRegistry.getAll();
    Set<Integer> questIconResIds = new HashSet<>(questTypeList.size());
    for (QuestType questType : questTypeList) {
        questIconResIds.add(questType.getIcon());
    }
    return questIconResIds;
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) HashSet(java.util.HashSet)

Example 10 with QuestType

use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.

the class OsmQuestUnlocker method unlockNewQuests.

public List<OsmQuest> unlockNewQuests(Element element) {
    ElementGeometry geometry = elementGeometryDB.get(element.getType(), element.getId());
    if (hasNoteAt(geometry.center))
        return new ArrayList<>();
    final ArrayList<OsmQuest> quests = new ArrayList<>();
    Set<QuestType> currentQuestTypes = getCurrentQuestTypes(element);
    for (QuestType questType : questTypesProvider.get()) {
        if (!(questType instanceof OsmElementQuestType))
            continue;
        OsmElementQuestType osmQuestType = (OsmElementQuestType) questType;
        if (currentQuestTypes.contains(osmQuestType))
            continue;
        Boolean appliesToElement = osmQuestType.isApplicableTo(element);
        if (appliesToElement == null || !appliesToElement)
            continue;
        quests.add(new OsmQuest(osmQuestType, element.getType(), element.getId(), geometry));
    }
    if (!quests.isEmpty()) {
        // Before new quests are unlocked, all reverted quests need to be removed for
        // this element so that they can be created anew as the case may be
        questDB.deleteAllReverted(element.getType(), element.getId());
        int questCount = questDB.addAll(quests);
        Log.i(TAG, "Unlocked " + questCount + " new quests" + " for " + element.getType().name() + "#" + element.getId());
    }
    return quests;
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) ArrayList(java.util.ArrayList)

Aggregations

QuestType (de.westnordost.streetcomplete.data.QuestType)11 ArrayList (java.util.ArrayList)5 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 OsmNoteQuestType (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType)3 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)2 List (java.util.List)2 Point (android.graphics.Point)1 LatLon (de.westnordost.osmapi.map.data.LatLon)1 QuestTypeRegistry (de.westnordost.streetcomplete.data.QuestTypeRegistry)1 OsmQuestDownload (de.westnordost.streetcomplete.data.osm.download.OsmQuestDownload)1 ElementGeometryDao (de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao)1 OsmQuestDao (de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao)1 TestQuestType (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType)1 TestQuestType2 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)1 TestQuestType3 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType3)1 TestQuestType4 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType4)1 TestQuestType5 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType5)1 OsmNoteQuestDao (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao)1 HashSet (java.util.HashSet)1