use of de.westnordost.streetcomplete.data.QuestGroup in project StreetComplete by westnordost.
the class FindQuestSourceComponent method findSource.
public void findSource(final long questId, final QuestGroup group, final Location[] locations, final Listener listener) {
Double distance = getDistanceToElementInMeters(questId, group, locations);
if (dontShowAgain || distance != null && distance < MAX_DISTANCE_TO_ELEMENT_FOR_SURVEY) {
listener.onFindQuestSourceResult(SURVEY);
} else {
View inner = LayoutInflater.from(activity).inflate(R.layout.quest_source_dialog_layout, null, false);
final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain);
AlertDialogBuilder alertDialogBuilder = new AlertDialogBuilder(activity);
alertDialogBuilder.setTitle(R.string.quest_source_dialog_title).setView(inner).setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) -> {
++timesShown;
dontShowAgain = checkBox.isChecked();
listener.onFindQuestSourceResult(SURVEY);
}).setNegativeButton(android.R.string.cancel, null);
checkBox.setVisibility(timesShown < 2 ? View.GONE : View.VISIBLE);
alertDialogBuilder.show();
}
}
use of de.westnordost.streetcomplete.data.QuestGroup in project StreetComplete by westnordost.
the class QuestAnswerComponentTest method testListener.
public void testListener() {
QuestAnswerComponent c1 = new QuestAnswerComponent();
final int expectQuestId = 3;
final QuestGroup expectGroup = QuestGroup.OSM_NOTE;
final String expectNote = "test";
final String expectQuestTitle = "What?";
final Bundle expectBundle = new Bundle();
final ArrayList<String> expectImagePaths = new ArrayList<>();
expectImagePaths.add("dings");
expectImagePaths.add("dongs");
expectBundle.putString("A", "B");
c1.onAttach(new OsmQuestAnswerListener() {
@Override
public void onAnsweredQuest(long questId, QuestGroup group, Bundle answer) {
assertEquals(expectQuestId, questId);
assertEquals(expectGroup, group);
assertEquals(expectBundle, answer);
}
@Override
public void onLeaveNote(long questId, QuestGroup group, String questTitle, String note, ArrayList<String> imagePaths) {
assertEquals(expectQuestId, questId);
assertEquals(expectGroup, group);
assertEquals(expectNote, note);
assertEquals(expectQuestTitle, questTitle);
assertEquals(expectImagePaths, imagePaths);
}
@Override
public void onSkippedQuest(long questId, QuestGroup group) {
assertEquals(expectQuestId, questId);
assertEquals(expectGroup, group);
}
});
c1.onCreate(QuestAnswerComponent.createArguments(expectQuestId, expectGroup));
c1.onLeaveNote(expectQuestTitle, expectNote, expectImagePaths);
c1.onAnswerQuest(expectBundle);
c1.onSkippedQuest();
}
Aggregations