use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class NoteDiscussionForm method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
View contentView = setContentView(R.layout.quest_note_discussion);
View buttonPanel = setButtonsView(R.layout.quest_notediscussion_buttonbar);
Button buttonOk = buttonPanel.findViewById(R.id.buttonOk);
buttonOk.setOnClickListener(v -> onClickOk());
Button buttonNo = buttonPanel.findViewById(R.id.buttonNo);
buttonNo.setOnClickListener(v -> skipQuest());
noteInput = contentView.findViewById(R.id.noteInput);
noteDiscussion = contentView.findViewById(R.id.noteDiscussion);
buttonOtherAnswers.setVisibility(View.GONE);
new InlineAsyncTask<Note>() {
@Override
protected Note doInBackground() throws Exception {
return noteDb.get(getQuestId()).getNote();
}
@Override
public void onSuccess(Note result) {
if (getActivity() != null && result != null) {
inflateNoteDiscussion(result);
}
}
@Override
public void onError(Exception e) {
Log.e(TAG, "Error fetching note quest " + getQuestId() + " from DB.", e);
}
}.execute();
return view;
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUploadTest method testCreateNoteOnExistingNoteWillCommentOnExistingNote.
public void testCreateNoteOnExistingNoteWillCommentOnExistingNote() {
CreateNote createNote = createACreateNote();
createNote.elementType = Element.Type.WAY;
createNote.elementId = 5L;
Note note = createNote(createNote);
setUpThereIsANoteFor(createNote, note);
when(notesDao.comment(anyLong(), anyString())).thenReturn(note);
assertNotNull(createNoteUpload.uploadCreateNote(createNote));
verify(notesDao).comment(note.id, createNote.text);
verifyNoteInsertedIntoDb(createNote.id, note);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUploadTest method testCreateNoteWithNoAssociatedElement.
public void testCreateNoteWithNoAssociatedElement() {
CreateNote createNote = createACreateNote();
Note note = createNote(null);
when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
assertNotNull(createNoteUpload.uploadCreateNote(createNote));
verify(notesDao).create(createNote.position, createNote.text);
verifyNoteInsertedIntoDb(createNote.id, note);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUploadTest method testCreateNoteWithNoQuestTitleButAssociatedElement.
public void testCreateNoteWithNoQuestTitleButAssociatedElement() {
CreateNote createNote = createACreateNote();
createNote.elementType = Element.Type.WAY;
createNote.elementId = 5L;
when(mapDataDao.getWay(createNote.elementId)).thenReturn(mock(Way.class));
Note note = createNote(null);
when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
assertNotNull(createNoteUpload.uploadCreateNote(createNote));
verify(notesDao).create(createNote.position, "for https://www.openstreetmap.org/way/5 via " + ApplicationConstants.USER_AGENT + ":\n\njo ho");
verifyNoteInsertedIntoDb(createNote.id, note);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUploadTest method createNote.
private Note createNote(CreateNote fitsTo) {
Note note = new Note();
note.id = 2;
note.status = Note.Status.OPEN;
note.dateCreated = new Date();
note.position = new OsmLatLon(1, 2);
NoteComment comment = new NoteComment();
comment.text = "bla bla";
if (fitsTo != null) {
comment.text += CreateNoteUpload.getAssociatedElementString(fitsTo);
}
comment.action = NoteComment.Action.OPENED;
comment.date = new Date();
note.comments.add(0, comment);
return note;
}
Aggregations