コード例 #1
0
  private boolean checkTitleStep(String title) {
    boolean titleIsCorrect = false;

    if (title.length() >= MIN_CHARACTERS_TITLE) {
      titleIsCorrect = true;
      verticalStepperForm.setActiveStepAsCompleted();
    } else {
      verticalStepperForm.setActiveStepAsUncompleted();
    }

    return titleIsCorrect;
  }
コード例 #2
0
  private boolean checkDays() {
    boolean thereIsAtLeastOneDaySelected = false;
    for (int i = 0; i < weekDays.length && !thereIsAtLeastOneDaySelected; i++) {
      if (weekDays[i]) {
        verticalStepperForm.setStepAsCompleted(DAYS_STEP_NUM);
        thereIsAtLeastOneDaySelected = true;
      }
    }
    if (!thereIsAtLeastOneDaySelected) {
      verticalStepperForm.setStepAsUncompleted(DAYS_STEP_NUM);
    }

    return thereIsAtLeastOneDaySelected;
  }
コード例 #3
0
 @Override
 public void onStepOpening(int stepNumber) {
   switch (stepNumber) {
     case TITLE_STEP_NUM:
       // When this step is open, we check that the title is correct
       checkTitleStep(titleEditText.getText().toString());
       break;
     case DESCRIPTION_STEP_NUM:
     case TIME_STEP_NUM:
       // As soon as they are open, these two steps are marked as completed because they
       // have default values
       verticalStepperForm.setStepAsCompleted(stepNumber);
       break;
     case DAYS_STEP_NUM:
       // When this step is open, we check the days to verify that at least one is selected
       checkDays();
       break;
   }
 }
コード例 #4
0
  private void initializeActivity() {

    // Time step vars
    time = new Pair(8, 30);
    setTimePicker(8, 30);

    // Week days step vars
    weekDays = new boolean[7];

    // Vertical Stepper form vars
    int colorPrimary = ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary);
    int colorPrimaryDark =
        ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark);
    String[] stepsNames = {"Title", "Description", "Time", "Week schedule"};

    // Here we find and initialize the form
    verticalStepperForm = (VerticalStepperFormLayout) findViewById(R.id.vertical_stepper_form);
    if (verticalStepperForm != null) {
      verticalStepperForm.initialiseVerticalStepperForm(
          stepsNames, colorPrimary, colorPrimaryDark, this, this);
    }
  }
コード例 #5
0
 private void confirmBack() {
   if (verticalStepperForm.isStepCompleted(0)) {
     BackConfirmationFragment backConfirmation = new BackConfirmationFragment();
     backConfirmation.setOnConfirmBack(
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             confirmBack = true;
           }
         });
     backConfirmation.setOnNotConfirmBack(
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             confirmBack = false;
             finish();
           }
         });
     backConfirmation.show(getSupportFragmentManager(), null);
   } else {
     confirmBack = false;
     finish();
   }
 }