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();
}
}
}
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;
}
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++);
}
}
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;
}
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;
}
Aggregations