|
|
|
@ -4,6 +4,8 @@ import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import com.todoroo.astrid.dao.TaskDao;
|
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
|
import io.reactivex.Completable;
|
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
import org.tasks.injection.BroadcastComponent;
|
|
|
|
|
import org.tasks.injection.InjectingBroadcastReceiver;
|
|
|
|
@ -23,12 +25,17 @@ public class CompleteTaskReceiver extends InjectingBroadcastReceiver {
|
|
|
|
|
long taskId = intent.getLongExtra(TASK_ID, 0);
|
|
|
|
|
boolean flipState = intent.getBooleanExtra(TOGGLE_STATE, false);
|
|
|
|
|
Timber.i("Completing %s", taskId);
|
|
|
|
|
Task task = taskDao.fetch(taskId);
|
|
|
|
|
if (task != null) {
|
|
|
|
|
taskDao.setComplete(task, !flipState || !task.isCompleted());
|
|
|
|
|
} else {
|
|
|
|
|
Timber.e("Could not find task with id %s", taskId);
|
|
|
|
|
}
|
|
|
|
|
Completable.fromAction(
|
|
|
|
|
() -> {
|
|
|
|
|
Task task = taskDao.fetch(taskId);
|
|
|
|
|
if (task != null) {
|
|
|
|
|
taskDao.setComplete(task, !flipState || !task.isCompleted());
|
|
|
|
|
} else {
|
|
|
|
|
Timber.e("Could not find task with id %s", taskId);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
|
.subscribe();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|