Search in sources :

Example 1 with PreviewViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel in project Neuronizer by djuelg.

the class PreviewFragment method permanentDeleteItem.

private void permanentDeleteItem(int position) {
    if (mAdapter == null || mPresenter == null)
        return;
    PreviewViewModel adapterItem = mAdapter.getItem(position);
    mAdapter.clearSelection();
    if (adapterItem != null) {
        if (adapterItem.getPreview() instanceof TodoListPreview) {
            mPresenter.deleteTodoList(adapterItem.getUuid());
        } else if (adapterItem.getPreview() instanceof NotePreview) {
            mPresenter.deleteNote(adapterItem.getUuid());
        }
        mAdapter.removeItem(position);
    }
}
Also used : PreviewViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel) NotePreview(de.djuelg.neuronizer.domain.model.preview.NotePreview) TodoListPreview(de.djuelg.neuronizer.domain.model.preview.TodoListPreview)

Example 2 with PreviewViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel 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 3 with PreviewViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel in project Neuronizer by djuelg.

the class DisplayPreviewPresenterImpl method onPreviewsRetrieved.

@Override
public void onPreviewsRetrieved(List<Preview> previews) {
    List<PreviewViewModel> previewVMs = new ArrayList<>();
    for (Preview preview : previews) {
        previewVMs.add(new PreviewViewModel(preview));
    }
    mView.onPreviewsLoaded(previewVMs);
}
Also used : PreviewViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel) ArrayList(java.util.ArrayList) Preview(de.djuelg.neuronizer.domain.model.preview.Preview)

Example 4 with PreviewViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel in project Neuronizer by djuelg.

the class DisplayPreviewPresenterImpl method syncPreviews.

@Override
public void syncPreviews(List<PreviewViewModel> previews) {
    List<PreviewViewModel> reversedPreviews = Lists.reverse(Optional.fromNullable(previews).or(new ArrayList<PreviewViewModel>(0)));
    for (PreviewViewModel vm : reversedPreviews) {
        EditTodoListInteractor interactor = new EditTodoListInteractorImpl(mExecutor, mMainThread, this, repository, vm.getUuid(), vm.getTitle(), reversedPreviews.indexOf(vm));
        interactor.execute();
    }
}
Also used : PreviewViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel) ArrayList(java.util.ArrayList) EditTodoListInteractor(de.djuelg.neuronizer.domain.interactors.preview.EditTodoListInteractor) EditTodoListInteractorImpl(de.djuelg.neuronizer.domain.interactors.preview.impl.EditTodoListInteractorImpl)

Aggregations

PreviewViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel)4 ArrayList (java.util.ArrayList)2 EditTodoListInteractor (de.djuelg.neuronizer.domain.interactors.preview.EditTodoListInteractor)1 EditTodoListInteractorImpl (de.djuelg.neuronizer.domain.interactors.preview.impl.EditTodoListInteractorImpl)1 BaseModel (de.djuelg.neuronizer.domain.model.BaseModel)1 Note (de.djuelg.neuronizer.domain.model.preview.Note)1 NotePreview (de.djuelg.neuronizer.domain.model.preview.NotePreview)1 Preview (de.djuelg.neuronizer.domain.model.preview.Preview)1 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1