use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class ItemFragment method addOrEditItemWithCurrentViewInput.
private void addOrEditItemWithCurrentViewInput(boolean addAnother) {
String title = titleEditText.getText().toString();
if (title.isEmpty() || mPresenter == null) {
Toast.makeText(getActivity(), R.string.title_mandatory, Toast.LENGTH_SHORT).show();
return;
}
TodoListHeader header = ((TodoListHeader) headerSpinner.getSelectedItem());
boolean important = importantSwitch.isChecked();
String details = (richEditor.getHtml() != null) ? richEditor.getHtml() : "";
if (isEditMode()) {
mPresenter.editItem(itemUuid, title, item.getPosition(), important, details, item.isDone(), todoListUuid, header.getUuid());
} else {
mPresenter.expandHeaderOfItem(header.getUuid(), header.getTitle(), header.getPosition());
if (addAnother) {
mPresenter.addItemAndAnother(title, important, details, todoListUuid, header.getUuid());
} else {
mPresenter.addItem(title, important, details, todoListUuid, header.getUuid());
}
}
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class ItemFragment method onHeadersLoaded.
@Override
public void onHeadersLoaded(List<TodoListHeader> headers) {
ArrayAdapter<TodoListHeader> spinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item, headers);
headerSpinner.setAdapter(spinnerAdapter);
for (TodoListHeader header : headers) {
if (isEditMode() && header.getUuid().equals(item.getParentHeaderUuid()))
headerSpinner.setSelection(headers.indexOf(header));
}
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getHeaderById.
@Override
public Optional<TodoListHeader> getHeaderById(String uuid) {
Realm realm = Realm.getInstance(configuration);
Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("uuid", uuid).findFirst());
Optional<TodoListHeader> header = headerDAO.transform(new TodoListHeaderDAOConverter());
realm.close();
return header;
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class EditHeaderInteractorImpl method run.
@Override
public void run() {
final Optional<TodoListHeader> outDatedItem = repository.todoList().getHeaderById(uuid);
if (!outDatedItem.isPresent()) {
throw new InputMismatchException("Item not existing!");
}
final TodoListHeader updatedItem = outDatedItem.get().update(title, position, expanded);
repository.todoList().update(updatedItem);
final Optional<TodoList> todoList = repository.todoList().getTodoListById(updatedItem.getParentTodoListUuid());
final TodoListHeader itemFromUI = new TodoListHeader(uuid, title, outDatedItem.get().getCreatedAt(), outDatedItem.get().getChangedAt(), position, expanded, outDatedItem.get().getParentTodoListUuid());
if (todoList.isPresent() && !outDatedItem.get().equals(itemFromUI))
repository.todoList().update(todoList.get().updateLastChange());
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onHeaderUpdated(updatedItem);
}
});
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testTodoListHeaderInsert.
@Test
public void testTodoListHeaderInsert() {
TodoListHeader header = createHeader();
boolean success = repository.insert(header);
assertTrue(success);
TodoListHeaderDAO dao = realm.where(TodoListHeaderDAO.class).equalTo("uuid", header.getUuid()).findFirst();
assertNotNull(dao);
}
Aggregations