@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_simulation, container, false);
    initializeWidgets(view);

    mSimulationType = STROOP_EFFECT_CONGRUENT;
    mCurrentSimulationNumber = 0;
    mTotalTries = 0;

    currentResult.setGender(getArguments().getString(TESTER_GENDER));

    stopWatch.start();

    simulate(mSimulationType);

    for (int i = 0; i < imgViewsArray.length; ++i) {
      final int index = i;
      imgViewsArray[i].setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              processClick(index);
            }
          });
    }

    return view;
  }
  private void processClick(int optionClicked) {
    mTotalTries++;

    if (mCorrectAnswer == optionClicked) {
      mCurrentSimulationNumber++;

      if (mCurrentSimulationNumber == MAX_SIMULATIONS) {
        long elapsedTime = stopWatch.getElapsedMilliseconds();
        currentResult.setElapsedTime(mSimulationType, elapsedTime);
        currentResult.setErrorPercentage(mSimulationType, 1 - 1.0 * MAX_SIMULATIONS / mTotalTries);
        stopWatch.restart();

        if (mSimulationType == STROOP_EFFECT_INCONGRUENT) {
          String message = "Thanks for participating.";
          Toast.makeText(getActivity().getApplicationContext(), message, Toast.LENGTH_LONG).show();
          ((MainActivity) getActivity()).insertResultIntoDatabase(currentResult);
          ((MainActivity) getActivity()).startHomeFragment();
        }

        mSimulationType++;

        mCurrentSimulationNumber = 0;
        mTotalTries = 0;
      }
      simulate(mSimulationType);
    } else {
      errorToast.show();
      Handler handler = new Handler();
      handler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              errorToast.cancel();
            }
          },
          TOAST_DURATION);
    }
  }