use of de.djuelg.neuronizer.domain.model.preview.TodoList in project Neuronizer by djuelg.
the class PreviewFragment method editItem.
private void editItem(int position) {
PreviewViewModel previewVM = mAdapter.getItem(position);
if (previewVM != null) {
BaseModel preview = previewVM.getPreview().getBaseItem();
if (preview instanceof TodoList) {
showEditTodoListDialog(this, preview.getUuid(), preview.getTitle(), preview.getPosition());
} else if (preview instanceof Note) {
showEditNoteDialog(this, preview.getUuid(), preview.getTitle(), preview.getPosition());
}
mAdapter.notifyItemChanged(position);
}
}
use of de.djuelg.neuronizer.domain.model.preview.TodoList in project Neuronizer by djuelg.
the class TodoListAppWidgetConfigure method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setResult(RESULT_CANCELED);
setContentView(R.layout.activity_widget_configure);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
repositoryName = sharedPreferences.getString(KEY_PREF_ACTIVE_REPO, FALLBACK_REALM);
List<TodoList> list = new TodoListRepositoryImpl(repositoryName).getAll();
radioGroup = findViewById(R.id.widget_config_radio_group);
todoLists = list.toArray(new TodoList[list.size()]);
radioButtons = new RadioButton[todoLists.length];
createRadioButtons();
}
use of de.djuelg.neuronizer.domain.model.preview.TodoList 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.preview.TodoList in project Neuronizer by djuelg.
the class AddTodoListInteractorImpl method run.
@Override
public void run() {
final int position = repository.preview().count();
// try to insert with new UUID on failure
TodoList item = new TodoList(title, position);
while (!repository.todoList().insert(item)) {
item = new TodoList(title, position);
}
final String uuid = item.getUuid();
final String title = item.getTitle();
// notify on the main thread that we have inserted this item
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onTodoListAdded(uuid, title);
}
});
}
use of de.djuelg.neuronizer.domain.model.preview.TodoList in project Neuronizer by djuelg.
the class EditTodoListInteractorImpl method run.
@Override
public void run() {
final Optional<TodoList> outDatedItem = repository.todoList().getTodoListById(uuid);
if (outDatedItem.isPresent()) {
final TodoList updatedItem = title.equals(outDatedItem.get().getTitle()) ? outDatedItem.get().update(title, position) : outDatedItem.get().update(title, position).updateLastChange();
repository.todoList().update(updatedItem);
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onTodoListUpdated(updatedItem);
}
});
}
}
Aggregations