Search in sources :

Example 6 with TodoList

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);
    }
}
Also used : BaseModel(de.djuelg.neuronizer.domain.model.BaseModel) PreviewViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel) Note(de.djuelg.neuronizer.domain.model.preview.Note) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 7 with TodoList

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();
}
Also used : SharedPreferences(android.content.SharedPreferences) TodoListRepositoryImpl(de.djuelg.neuronizer.storage.TodoListRepositoryImpl) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 8 with TodoList

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);
        }
    });
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) InputMismatchException(java.util.InputMismatchException) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 9 with TodoList

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);
        }
    });
}
Also used : TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 10 with TodoList

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);
            }
        });
    }
}
Also used : TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Aggregations

TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)12 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)5 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)3 TodoListRepositoryImpl (de.djuelg.neuronizer.storage.TodoListRepositoryImpl)2 TodoListDAO (de.djuelg.neuronizer.storage.model.TodoListDAO)2 Realm (io.realm.Realm)2 InputMismatchException (java.util.InputMismatchException)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 RemoteViews (android.widget.RemoteViews)1 BaseModel (de.djuelg.neuronizer.domain.model.BaseModel)1 Note (de.djuelg.neuronizer.domain.model.preview.Note)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 PreviewViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel)1 TodoListDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListDAOConverter)1 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)1 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)1 ArrayList (java.util.ArrayList)1