protected Step getStep(int position) {
   if (position >= sSteps.size()) {
     return null;
   }
   Step step = sSteps.get(position);
   step.setContext(this);
   return step;
 }
 protected Step getPostStep() {
   int position = mStepIndex;
   if (position >= sSteps.size()) {
     return null;
   }
   Step step = sSteps.get(position);
   if (sStepOptional.containsKey(step) && !sStepOptional.get(step).check()) {
     mStepIndex++;
     return getPostStep();
   }
   step.setContext(this);
   System.out.println("Returning " + position);
   hideSoftInput();
   return step;
 }
 protected Step getPreviousStep() {
   System.out.println("They called previous step! " + mStepIndex);
   if (mStepIndex >= sSteps.size()) {
     return null;
   }
   Step step = sSteps.get(mStepIndex);
   if (sStepOptional.containsKey(step) && !sStepOptional.get(step).check()) {
     mStepIndex--;
     if (mStepIndex < 0) {
       finish();
       return null;
     }
     return getPreviousStep();
   }
   step.setContext(this);
   System.out.println("Returning " + mStepIndex);
   return step;
 }
  protected void nextStep() {
    Step step = getCurrentStep();
    boolean checkStep = checkStep();
    if (!checkStep) {
      if (!error) {
        error = true;
        errorSwitcher.setText(step.getError(this));
      }
    } else {
      error = false;
    }
    if (error) {
      return;
    }
    setupData = step.save(setupData);

    stepIndex++;
    updateStep();
  }
  private void updateViews() {
    Step step = getCurrentStep();

    if (stepIndex + 1 >= steps.size()) {
      nextButton.setImageDrawable(buttonFinishIcon);
      nextButton.setContentDescription(getString(R.string.finish));
      step.updateView(true);
    } else {
      nextButton.setImageDrawable(buttonNextIcon);
      nextButton.setContentDescription(getString(R.string.next_step));
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    inputSwitcher.setDisplayedChild(stepIndex);
    errorSwitcher.setText("");
    detailsSwitcher.setText(step.getDetails(this));
    titleSwitcher.setText(step.getTitle(this));
    stepText.setText(getString(R.string.page_number, stepIndex + 1, steps.size()));

    stepText.setTextColor(detailsTextColor);

    updateProgressbar();
  }
  private void updateViews() {
    Step step = getCurrentStep();
    if (step == null) {
      if (mStepIndex >= stepsSize()) {
        hideSoftInput();
        onFormFinished(setupData);

        mStepIndex--; // reset stepIndex to last step
        finish();
        return;
      }
    }
    if (mStepIndex + 1 >= stepsSize()) {
      mNextButton.setImageDrawable(mButtonFinishIcon);
      step.updateView(true);
    } else {
      hideSoftInput();
      mNextButton.setImageDrawable(mButtonNextIcon);
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    mInputSwitcher.setDisplayedChild(mStepIndex);
    mErrorSwitcher.setText("");
    mDetailsSwitcher.setText(step.getDetails());
    mTitleSwitcher.setText(step.getTitle());
    mStepText.setText(getString(R.string.page_number, mStepIndex + 1, stepsSize()));

    mStepText.setTextColor(mDetailsTextColor);
    if (step instanceof TextStep) System.out.println(step.getView().requestFocus());

    updateProgressbar();
  }