blob: 9e78f380320d8ce4a9b9c88fbda82a91a02a63be [file] [log] [blame]
// Copyright 2016 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package io.v.todos.persistence;
import android.app.Activity;
import io.v.todos.model.ListMetadata;
import io.v.todos.model.ListSpec;
import io.v.todos.model.Task;
import io.v.todos.model.TaskSpec;
public final class PersistenceFactory {
private PersistenceFactory() {
}
/**
* Indicates whether {@link #getMainPersistence(Activity, ListEventListener)} may block. This
* can affect whether a progress indicator is shown and whether a worker thread is used.
*/
public static boolean mightGetMainPersistenceBlock() {
return false;
}
/**
* Instantiates a persistence object that can be used to manipulate todo lists.
*/
public static MainPersistence getMainPersistence(Activity activity,
ListEventListener<ListMetadata> listener) {
return new MockMainPersistence();
}
/**
* Indicates whether {@link #getTodoListPersistence(Activity, String, TodoListListener)} may
* block. This can affect whether a progress indicator is shown and whether a worker thread is
* used.
*/
public static boolean mightGetTodoListPersistenceBlock() {
return false;
}
/**
* Instantiates a persistence object that can be used to manipulate a todo list.
*/
public static TodoListPersistence getTodoListPersistence(Activity activity, String key,
TodoListListener listener) {
return new MockTodoListPersistence();
}
static class MockMainPersistence implements MainPersistence {
@Override
public void addTodoList(ListSpec listSpec) {
}
@Override
public void deleteTodoList(String key) {
}
@Override
public void setCompletion(ListMetadata listMetadata, boolean done) {
}
@Override
public void close() {
}
}
static class MockTodoListPersistence implements TodoListPersistence {
@Override
public void updateTodoList(ListSpec listSpec) {
}
@Override
public void deleteTodoList() {
}
@Override
public void shareTodoList(Iterable<String> emails) {
}
@Override
public void addTask(TaskSpec task) {
}
@Override
public void updateTask(Task task) {
}
@Override
public void deleteTask(String key) {
}
@Override
public void setShowDone(boolean showDone) {
}
@Override
public void close() {
}
}
}