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);
}
}
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);
}
}
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);
}
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();
}
}
Aggregations