diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index ca50f4688..b902e1e49 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 5ef687212..2674959b1 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -608,6 +608,7 @@
BY_NAME
+
diff --git a/app/build.gradle b/app/build.gradle
index 359402093..437ca1cf0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -84,6 +84,7 @@ dependencies {
implementation 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.6'
implementation "android.arch.lifecycle:extensions:1.1.1"
+
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation 'com.android.support:appcompat-v7:27.1.1'
diff --git a/app/src/main/java/org/sagebionetworks/research/app/MainActivity.java b/app/src/main/java/org/sagebionetworks/research/app/MainActivity.java
index eb0fe8474..8b598016d 100644
--- a/app/src/main/java/org/sagebionetworks/research/app/MainActivity.java
+++ b/app/src/main/java/org/sagebionetworks/research/app/MainActivity.java
@@ -57,7 +57,7 @@ protected void onCreate(Bundle savedInstanceState) {
.build();
}
if (performTaskFragment == null) {
- performTaskFragment = PerformTaskFragment.newInstance(taskView);
+ performTaskFragment = PerformTaskFragment.newInstance("taskId");
getSupportFragmentManager()
.beginTransaction()
diff --git a/data/src/main/java/org/sagebionetworks/research/data/FakeTaskRepository.java b/data/src/main/java/org/sagebionetworks/research/data/FakeTaskRepository.java
index 7b965fa8b..dd0b175be 100644
--- a/data/src/main/java/org/sagebionetworks/research/data/FakeTaskRepository.java
+++ b/data/src/main/java/org/sagebionetworks/research/data/FakeTaskRepository.java
@@ -38,6 +38,7 @@
import org.sagebionetworks.research.data.model.step.ConcreteUIStep;
import org.sagebionetworks.research.domain.Schema;
import org.sagebionetworks.research.domain.repository.TaskRepository;
+import org.sagebionetworks.research.domain.result.TaskResult;
import org.sagebionetworks.research.domain.step.Step;
import org.sagebionetworks.research.domain.step.ui.UIStep;
import org.sagebionetworks.research.domain.task.Task;
@@ -47,14 +48,12 @@
import java.util.List;
import java.util.UUID;
+import io.reactivex.Completable;
import io.reactivex.Single;
import javax.inject.Inject;
public class FakeTaskRepository implements TaskRepository {
- @Inject
- public FakeTaskRepository() {
- }
-
+ @Inject public FakeTaskRepository() {}
@Override
public Single getTask(final String taskIdentifier) {
return Single.just(new Task() {
@@ -106,6 +105,12 @@ public Single> getTaskSteps(final Task task) {
));
}
+ @NonNull
+ @Override
+ public Completable setTaskResult(final TaskResult taskResult) {
+ return Completable.error(new UnsupportedOperationException("Not implemented yet"));
+ }
+
private UIStep createUIStep(String id) {
return ConcreteUIStep.builder()
.setIdentifier(id)
diff --git a/domain/src/main/java/org/sagebionetworks/research/domain/repository/TaskRepository.java b/domain/src/main/java/org/sagebionetworks/research/domain/repository/TaskRepository.java
index 3f2918bd8..d88d6c337 100644
--- a/domain/src/main/java/org/sagebionetworks/research/domain/repository/TaskRepository.java
+++ b/domain/src/main/java/org/sagebionetworks/research/domain/repository/TaskRepository.java
@@ -32,13 +32,16 @@
package org.sagebionetworks.research.domain.repository;
+import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
+import org.sagebionetworks.research.domain.result.TaskResult;
import org.sagebionetworks.research.domain.step.Step;
import org.sagebionetworks.research.domain.task.Task;
import java.util.List;
+import io.reactivex.Completable;
import io.reactivex.Single;
public interface TaskRepository {
@@ -47,4 +50,8 @@ public interface TaskRepository {
@NonNull
Single> getTaskSteps(Task task);
+
+ @NonNull
+ @CheckResult
+ Completable setTaskResult(TaskResult taskResult);
}
diff --git a/domain/src/test/java/org/sagebionetworks/research/domain/task/navigation/strategy/next_step/ConstantNextStepStrategyTest.java b/domain/src/test/java/org/sagebionetworks/research/domain/task/navigation/strategy/next_step/ConstantNextStepStrategyTest.java
index 6aba20ba0..5372e8306 100644
--- a/domain/src/test/java/org/sagebionetworks/research/domain/task/navigation/strategy/next_step/ConstantNextStepStrategyTest.java
+++ b/domain/src/test/java/org/sagebionetworks/research/domain/task/navigation/strategy/next_step/ConstantNextStepStrategyTest.java
@@ -37,7 +37,7 @@
import org.sagebionetworks.research.domain.task.navigation.strategy.StepNavigationStrategy.NextStepStrategy;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.*;
public class ConstantNextStepStrategyTest {
diff --git a/mobile-ui/build.gradle b/mobile-ui/build.gradle
index 8e7045317..9c354f2a6 100644
--- a/mobile-ui/build.gradle
+++ b/mobile-ui/build.gradle
@@ -91,6 +91,7 @@ dependencies {
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
testImplementation 'junit:junit:4.12'
+ testImplementation "android.arch.core:core-testing:1.1.1"
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
diff --git a/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/mapper/TaskMapper.java b/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/mapper/TaskMapper.java
index d4edf8f54..09759befb 100644
--- a/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/mapper/TaskMapper.java
+++ b/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/mapper/TaskMapper.java
@@ -32,5 +32,10 @@
package org.sagebionetworks.research.mobile_ui.mapper;
+import javax.inject.Inject;
+
public class TaskMapper {
+ @Inject
+ public TaskMapper() {
+ }
}
diff --git a/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/perform_task/PerformTaskFragment.java b/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/perform_task/PerformTaskFragment.java
index 58520e3b8..620379eec 100644
--- a/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/perform_task/PerformTaskFragment.java
+++ b/mobile-ui/src/main/java/org/sagebionetworks/research/mobile_ui/perform_task/PerformTaskFragment.java
@@ -43,15 +43,15 @@
import android.view.View;
import android.view.ViewGroup;
+import com.google.common.base.Strings;
+
import org.sagebionetworks.research.domain.mobile_ui.R;
import org.sagebionetworks.research.mobile_ui.mapper.StepMapper;
-import org.sagebionetworks.research.mobile_ui.show_step.StepPresenter;
import org.sagebionetworks.research.mobile_ui.show_step.StepPresenterFactory;
import org.sagebionetworks.research.mobile_ui.show_step.view.ShowStepFragment;
import org.sagebionetworks.research.mobile_ui.show_step.view.ShowStepFragmentBase;
import org.sagebionetworks.research.presentation.model.StepView;
import org.sagebionetworks.research.presentation.model.StepView.NavDirection;
-import org.sagebionetworks.research.presentation.model.TaskView;
import org.sagebionetworks.research.presentation.perform_task.PerformTaskViewModel;
import org.sagebionetworks.research.presentation.perform_task.PerformTaskViewModelFactory;
@@ -70,7 +70,7 @@
* A placeholder fragment containing a simple view.
*/
public class PerformTaskFragment extends Fragment implements HasSupportFragmentInjector {
- private static final String ARGUMENT_TASK_VIEW = "TASK_VIEW";
+ private static final String ARGUMENT_TASK_IDENTIFIER = "TASK_VIEW";
@Inject
DispatchingAndroidInjector fragmentDispatchingAndroidInjector;
@@ -88,17 +88,15 @@ public class PerformTaskFragment extends Fragment implements HasSupportFragmentI
private PerformTaskViewModel performTaskViewModel;
- private StepPresenter stepPresenter;
-
- private TaskView taskView;
+ private String taskIdentifier;
private Unbinder unbinder;
- public static PerformTaskFragment newInstance(@NonNull TaskView taskView) {
- checkNotNull(taskView);
+ public static PerformTaskFragment newInstance(@NonNull String taskIdentifier) {
+ checkNotNull(taskIdentifier);
Bundle arguments = new Bundle();
- arguments.putParcelable(ARGUMENT_TASK_VIEW, taskView);
+ arguments.putString(ARGUMENT_TASK_IDENTIFIER, taskIdentifier);
PerformTaskFragment fragment = new PerformTaskFragment();
fragment.setArguments(arguments);
@@ -119,14 +117,14 @@ public void onCreate(Bundle savedInstanceState) {
if (savedInstanceState == null) {
Bundle arguments = getArguments();
if (arguments != null) {
- taskView = getArguments().getParcelable(ARGUMENT_TASK_VIEW);
+ taskIdentifier = getArguments().getString(ARGUMENT_TASK_IDENTIFIER);
}
} else {
- taskView = savedInstanceState.getParcelable(ARGUMENT_TASK_VIEW);
+ taskIdentifier = savedInstanceState.getString(ARGUMENT_TASK_IDENTIFIER);
}
- checkState(taskView != null, "no taskView found");
+ checkState(!Strings.isNullOrEmpty(taskIdentifier), "taskIdentifier cannot be null or empty");
- performTaskViewModel = ViewModelProviders.of(this, taskViewModelFactory.create(taskView))
+ performTaskViewModel = ViewModelProviders.of(this, taskViewModelFactory.create(taskIdentifier))
.get(PerformTaskViewModel.class);
performTaskViewModel.getStep().observe(this, this::showStep);
@@ -143,7 +141,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
@Override
public void onSaveInstanceState(Bundle outState) {
if (outState != null) {
- outState.putParcelable(ARGUMENT_TASK_VIEW, taskView);
+ outState.putString(ARGUMENT_TASK_IDENTIFIER, taskIdentifier);
}
}
diff --git a/presentation/build.gradle b/presentation/build.gradle
index 14f979af4..37bf43af6 100644
--- a/presentation/build.gradle
+++ b/presentation/build.gradle
@@ -69,6 +69,8 @@ dependencies {
implementation 'com.google.guava:guava:24.1-android'
implementation "android.arch.lifecycle:extensions:1.1.1"
+ annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
+
implementation 'org.slf4j:slf4j-api:1.7.21'
api 'com.google.dagger:dagger-android:2.15'
@@ -83,7 +85,11 @@ dependencies {
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.6'
implementation 'com.android.support:appcompat-v7:27.1.1'
+
testImplementation 'junit:junit:4.12'
+ testImplementation "android.arch.core:core-testing:1.1.1"
+ testImplementation 'org.mockito:mockito-core:2.8.9'
+
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
diff --git a/presentation/src/main/java/org/sagebionetworks/research/presentation/mapper/TaskMapper.java b/presentation/src/main/java/org/sagebionetworks/research/presentation/mapper/TaskMapper.java
index 07cdb6a95..86d6edbc0 100644
--- a/presentation/src/main/java/org/sagebionetworks/research/presentation/mapper/TaskMapper.java
+++ b/presentation/src/main/java/org/sagebionetworks/research/presentation/mapper/TaskMapper.java
@@ -40,10 +40,17 @@
import org.sagebionetworks.research.domain.task.Task;
import org.sagebionetworks.research.presentation.model.TaskView;
+import javax.inject.Inject;
+
/**
* Map a {@link Task} to a {@link TaskView} when data is moving between the Domain layer and this layer.
*/
public class TaskMapper implements Function {
+ @Inject
+ public TaskMapper() {
+
+ }
+
@Override
@NonNull
public TaskView apply(@NonNull Task input) {
diff --git a/presentation/src/main/java/org/sagebionetworks/research/presentation/perform_task/PerformTaskViewModel.java b/presentation/src/main/java/org/sagebionetworks/research/presentation/perform_task/PerformTaskViewModel.java
index 630905903..d40a89847 100644
--- a/presentation/src/main/java/org/sagebionetworks/research/presentation/perform_task/PerformTaskViewModel.java
+++ b/presentation/src/main/java/org/sagebionetworks/research/presentation/perform_task/PerformTaskViewModel.java
@@ -34,10 +34,10 @@
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
-import android.arch.lifecycle.Transformations;
import android.arch.lifecycle.ViewModel;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
import org.sagebionetworks.research.domain.presentation.model.LoadableResource;
import org.sagebionetworks.research.domain.repository.TaskRepository;
@@ -45,10 +45,9 @@
import org.sagebionetworks.research.domain.result.TaskResult;
import org.sagebionetworks.research.domain.step.Step;
import org.sagebionetworks.research.domain.task.Task;
-import org.sagebionetworks.research.domain.task.Task.Progress;
import org.sagebionetworks.research.domain.task.navigation.StepNavigator;
import org.sagebionetworks.research.domain.task.navigation.StepNavigatorFactory;
-import org.sagebionetworks.research.presentation.mapper.StepMapper;
+import org.sagebionetworks.research.presentation.mapper.TaskMapper;
import org.sagebionetworks.research.presentation.model.StepView;
import org.sagebionetworks.research.presentation.model.StepView.NavDirection;
import org.sagebionetworks.research.presentation.model.TaskView;
@@ -56,116 +55,76 @@
import org.slf4j.LoggerFactory;
import org.threeten.bp.Instant;
+import java.util.List;
import java.util.UUID;
+import io.reactivex.disposables.CompositeDisposable;
+
import static com.google.common.base.Preconditions.checkNotNull;
@MainThread
public class PerformTaskViewModel extends ViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(PerformTaskViewModel.class);
- private final MutableLiveData currentStepLiveData;
-
- private final LiveData nextStepLiveData;
-
- private final LiveData previousStepLiveData;
+ private final CompositeDisposable compositeDisposable;
- private final LiveData