diff --git a/example/src/main/java/com/quickbirdstudios/example/ui/main/MainActivity.kt b/example/src/main/java/com/quickbirdstudios/example/ui/main/MainActivity.kt index 5691cb8..dbf9747 100644 --- a/example/src/main/java/com/quickbirdstudios/example/ui/main/MainActivity.kt +++ b/example/src/main/java/com/quickbirdstudios/example/ui/main/MainActivity.kt @@ -199,6 +199,16 @@ class MainActivity : AppCompatActivity() { } } + surveyView.onStepBegin = { step -> + when (step) { + is QuestionStep -> { + Log.w ("ASDF", "step '${step?.id}': ${step.title} (${step.text})") + } + else -> + Log.w ("ASDF", "step '${step?.id}'") + } + } + val configuration = SurveyTheme( themeColorDark = ContextCompat.getColor(this, R.color.cyan_dark), themeColor = ContextCompat.getColor(this, R.color.cyan_normal), diff --git a/survey/src/main/java/com.quickbirdstudios.surveykit/survey/Survey.kt b/survey/src/main/java/com.quickbirdstudios.surveykit/survey/Survey.kt index 436b015..ad8e5e5 100644 --- a/survey/src/main/java/com.quickbirdstudios.surveykit/survey/Survey.kt +++ b/survey/src/main/java/com.quickbirdstudios.surveykit/survey/Survey.kt @@ -8,6 +8,7 @@ import com.quickbirdstudios.surveykit.result.TaskResult import com.quickbirdstudios.surveykit.steps.Step internal interface Survey { + var onStepBegin: (Step?) -> Unit var onStepResult: (Step?, StepResult?) -> Unit var onSurveyFinish: (TaskResult, FinishReason) -> Unit diff --git a/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt b/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt index 90aac23..69f7b82 100644 --- a/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt +++ b/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt @@ -92,6 +92,8 @@ class SurveyView @JvmOverloads constructor( //region Overrides + override var onStepBegin: (Step?) -> Unit = { _ -> } + override var onStepResult: (Step?, StepResult?) -> Unit = { _, _ -> } override var onSurveyFinish: (TaskResult, FinishReason) -> Unit = { _, _ -> } @@ -122,6 +124,9 @@ class SurveyView @JvmOverloads constructor( val newStep = taskNavigator.nextStep(step, result) ?: return StepData( FinishReason.Completed ) + + onStepBegin(newStep) + val newResult = presenter( Presenter.Transition.SlideFromRight, newStep, resultGatherer.retrieve(newStep.id) ).storeResult() @@ -136,6 +141,9 @@ class SurveyView @JvmOverloads constructor( taskNavigator.previousStep(step) ?: return StepData( FinishReason.Failed ) + + onStepBegin(previousStep) + val newResult = presenter( Presenter.Transition.SlideFromLeft, previousStep, @@ -151,6 +159,9 @@ class SurveyView @JvmOverloads constructor( val newStep = taskNavigator.nextStep(step) ?: return StepData( FinishReason.Completed ) + + onStepBegin(newStep) + val newResult = presenter( Presenter.Transition.SlideFromRight, newStep, resultGatherer.retrieve(newStep.id) ).storeResult()