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 04cd3b4..b879390 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 @@ -201,6 +201,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 5adb539..7465434 100644 --- a/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt +++ b/survey/src/main/java/com.quickbirdstudios.surveykit/survey/SurveyView.kt @@ -91,6 +91,8 @@ class SurveyView @JvmOverloads constructor( //region Overrides + override var onStepBegin: (Step?) -> Unit = { _ -> } + override var onStepResult: (Step?, StepResult?) -> Unit = { _, _ -> } override var onSurveyFinish: (TaskResult, FinishReason) -> Unit = { _, _ -> } @@ -121,6 +123,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() @@ -135,6 +140,9 @@ class SurveyView @JvmOverloads constructor( taskNavigator.previousStep(step) ?: return StepData( FinishReason.Failed ) + + onStepBegin(previousStep) + val newResult = presenter( Presenter.Transition.SlideFromLeft, previousStep, @@ -150,6 +158,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()