use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class CommentAdapter method getView.
@Override
public View getView(final int position, View view, final ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final Comment comment = comments.get(position);
final ViewHolder holder;
if (view != null) {
holder = (ViewHolder) view.getTag();
} else {
view = inflater.inflate(R.layout.single_comment_layout, parent, false);
holder = new ViewHolder(view);
view.setTag(holder);
}
holder.getCommentContentTextView().setText(comment.getText());
holder.getActionTextView().setText(comment.getAction());
DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yy");
String date = comment.getCreatedDate() == null ? "" : fmt.print(comment.getCreatedDate());
if (comment.getUpdated()) {
date = context.getResources().getString(R.string.synchronizing);
}
holder.getDateTextView().setText(date);
return view;
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteManagerTest method getNote.
private Note getNote(int i) {
Note note = new Note();
note.setLatitude(42.0);
note.setLongitude(73.0);
note.setUpdated(true);
Comment newComment = new Comment();
newComment.setText("firstComment" + i);
newComment.setAction(Comment.ACTION_OPEN);
newComment.setNote(note);
newComment.setUpdated(true);
newComment.setCreatedDate(new DateTime());
note.getComments().add(newComment);
note.setStatus(Note.STATUS_SYNC);
return note;
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteManagerTest method testSaveAndQuery.
@Test
public void testSaveAndQuery() {
NoteManager noteManager = component.getNoteManager();
Note note = getNote(1);
Note saved = noteManager.saveNote(note);
Note queried = noteManager.queryForId(saved.getId());
Comment queriedComment = ((ArrayList<Comment>) queried.getComments()).get(0);
assertThat(queried.getLatitude()).isEqualTo(42.0);
assertThat(queried.getLongitude()).isEqualTo(73.0);
assertThat(queried.getUpdated()).isTrue();
assertThat(queriedComment.getText()).isEqualTo("firstComment1");
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteManagerTest method testBulkSaveAndBulkUpdate.
@Test
public void testBulkSaveAndBulkUpdate() {
NoteManager noteManager = component.getNoteManager();
// try to save and then update 1000 notes.
// 1000 because it can happen in real life and pose problems if we try to do an "IN" sql clause
List<Note> notes = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
notes.add(getNote(i));
}
noteManager.saveNotes(notes);
for (Note note : notes) {
assertThat(note.getId()).isNotNull();
}
for (Note note : notes) {
Comment newComment = new Comment();
newComment.setText("secondComment");
newComment.setAction(Comment.ACTION_OPEN);
newComment.setNote(note);
newComment.setUpdated(true);
newComment.setCreatedDate(new DateTime());
note.getComments().clear();
note.getComments().add(newComment);
}
List<Note> savedNotes = noteManager.saveNotes(notes);
for (Note note : savedNotes) {
assertThat(note.getComments()).hasSize(1);
Comment com = ((ArrayList<Comment>) note.getComments()).get(0);
assertThat(com.getText()).isEqualTo("secondComment");
}
}
Aggregations