/** *** CHECK FOR NECESSARY DETAILS **** */
  private void checkCatDetails() {

    /* HIDE THE KEYBOARD */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtCategoryName.getWindowToken(), 0);

    /** CHECK THAT THE CATEGORY NAME AND THE CATEGORY THUMB ARE NOT EMPTY * */
    if (edtCategoryName.getText().toString().length() == 0 && CATEGORY_THUMB == null) {
      edtCategoryName.setError("You need to enter the Category Name");
      String strMessage = "An image representing the Category is necessary to save it!";
      Toast.makeText(getApplicationContext(), strMessage, Toast.LENGTH_SHORT).show();
    } else if (edtCategoryName.getText().toString().length() == 0 && CATEGORY_THUMB != null) {
      edtCategoryName.setError("You need to enter the Category Name");
    } else if (edtCategoryName.getText().toString().length() != 0 && CATEGORY_THUMB == null) {
      String strMessage = "An image representing the Category is necessary to save it!";
      Toast.makeText(getApplicationContext(), strMessage, Toast.LENGTH_SHORT).show();
    } else {
      /** *** CHECK FOR UNIQUE MEAL CATEGORY **** */
      new checkUniqueCategory().execute();
    }
  }
Beispiel #2
0
  private void validateData() {

    /** HIDE THE KEYBOARD * */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);

    /** * GRAB THE DATA ** */
    TAX_NAME = edtTaxName.getText().toString();
    TAX_PERCENTAGE = edtTaxPercentage.getText().toString();
    TAX_REGISTRATION = edtTaxRegistration.getText().toString();
    if (TAX_COMPLETE_AMOUNT) {
      TAX_PERCENT_OF_AMOUNT = "100";
    } else {
      TAX_PERCENT_OF_AMOUNT = edtTaxPercentageOfAmount.getText().toString();
    }

    /** *** CHECK FOR THE REQUIRED DATA **** */
    if (edtTaxName.getText().toString().length() == 0) {
      edtTaxName.setError(getResources().getString(R.string.tax_creator_tax_name_empty));
      edtTaxName.requestFocus();
    } else if (edtTaxPercentage.getText().toString().length() == 0) {
      edtTaxPercentage.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_empty));
      edtTaxPercentage.requestFocus();
    } else if (edtTaxPercentage.getText().toString().equals("0")
        || edtTaxPercentage.getText().toString().equals("0.0")
        || edtTaxPercentage.getText().toString().equals("0.00")) {
      edtTaxPercentage.setError(getResources().getString(R.string.tax_creator_tax_percentage_zero));
      edtTaxPercentage.requestFocus();
    } else if (edtTaxRegistration.getText().toString().length() == 0) {
      edtTaxRegistration.setError(
          getResources().getString(R.string.tax_creator_tax_registration_empty));
      edtTaxRegistration.requestFocus();
    } else if (!TAX_COMPLETE_AMOUNT
        && edtTaxPercentageOfAmount.getText().toString().length() == 0) {
      edtTaxPercentageOfAmount.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_of_amount_empty));
      edtTaxPercentageOfAmount.requestFocus();
    } else if (edtTaxPercentageOfAmount.getText().toString().equals("0")
        || edtTaxPercentageOfAmount.getText().toString().equals("0.0")
        || edtTaxPercentageOfAmount.getText().toString().equals("0.00")) {
      edtTaxPercentageOfAmount.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_of_amount_zero));
      edtTaxPercentageOfAmount.requestFocus();
    } else {
      /** CHECK FOR UNIQUE TAX NAME * */
      new checkUniqueTaxName().execute();
    }
  }