Search in sources :

Example 1 with Task

use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.

the class AddEditTaskPresenter method createTask.

private void createTask(String title, String description) {
    Task newTask = new Task(title, description);
    if (newTask.isEmpty()) {
        mAddTaskView.showEmptyTaskError();
    } else {
        mTasksRepository.saveTask(newTask);
        mAddTaskView.showTasksList();
    }
}
Also used : Task(com.example.android.architecture.blueprints.todoapp.data.Task)

Example 2 with Task

use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.

the class TasksRepository method activateTask.

@Override
public void activateTask(@NonNull Task task) {
    checkNotNull(task);
    mTasksRemoteDataSource.activateTask(task);
    mTasksLocalDataSource.activateTask(task);
    Task activeTask = new Task(task.getTitle(), task.getDescription(), task.getId());
    // Do in memory cache update to keep the app UI up to date
    if (mCachedTasks == null) {
        mCachedTasks = new LinkedHashMap<>();
    }
    mCachedTasks.put(task.getId(), activeTask);
}
Also used : Task(com.example.android.architecture.blueprints.todoapp.data.Task)

Example 3 with Task

use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.

the class TasksRepository method completeTask.

@Override
public void completeTask(@NonNull Task task) {
    checkNotNull(task);
    mTasksRemoteDataSource.completeTask(task);
    mTasksLocalDataSource.completeTask(task);
    Task completedTask = new Task(task.getTitle(), task.getDescription(), task.getId(), true);
    // Do in memory cache update to keep the app UI up to date
    if (mCachedTasks == null) {
        mCachedTasks = new LinkedHashMap<>();
    }
    mCachedTasks.put(task.getId(), completedTask);
}
Also used : Task(com.example.android.architecture.blueprints.todoapp.data.Task)

Example 4 with Task

use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.

the class TasksRepository method activateTask.

@Override
public void activateTask(@NonNull String taskId) {
    checkNotNull(taskId);
    Task taskWithId = getTaskWithId(taskId);
    if (taskWithId != null) {
        activateTask(taskWithId);
    }
}
Also used : Task(com.example.android.architecture.blueprints.todoapp.data.Task)

Example 5 with Task

use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.

the class TasksRepository method completeTask.

@Override
public void completeTask(@NonNull String taskId) {
    checkNotNull(taskId);
    Task taskWithId = getTaskWithId(taskId);
    if (taskWithId != null) {
        completeTask(taskWithId);
    }
}
Also used : Task(com.example.android.architecture.blueprints.todoapp.data.Task)

Aggregations

Task (com.example.android.architecture.blueprints.todoapp.data.Task)35 Test (org.junit.Test)20 Optional (com.google.common.base.Optional)3 Before (org.junit.Before)3 TasksRepository (com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository)2 ImmediateSchedulerProvider (com.example.android.architecture.blueprints.todoapp.util.schedulers.ImmediateSchedulerProvider)2 Flowable (io.reactivex.Flowable)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 Disposable (io.reactivex.disposables.Disposable)2 TestSubscriber (io.reactivex.subscribers.TestSubscriber)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 NonNull (android.support.annotation.NonNull)1 LargeTest (android.support.test.filters.LargeTest)1 AddEditTaskActivity (com.example.android.architecture.blueprints.todoapp.addedittask.AddEditTaskActivity)1 TasksDataSource (com.example.android.architecture.blueprints.todoapp.data.source.TasksDataSource)1 EspressoIdlingResource (com.example.android.architecture.blueprints.todoapp.util.EspressoIdlingResource)1 BaseSchedulerProvider (com.example.android.architecture.blueprints.todoapp.util.schedulers.BaseSchedulerProvider)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 List (java.util.List)1