Exemplo n.º 1
0
  /** *** CHECK FOR EMPTY FIELDS **** */
  private void checkEmpty() {

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

    /** GET THE REQUIRED DATA * */
    MEAL_NAME = edtDishName.getText().toString();
    MEAL_DESCRIPTION = edtDishDescription.getText().toString();
    MEAL_PRICE = edtDishPrice.getText().toString();

    if (MEAL_NAME.length() == 0) {
      inputDishName.setError("Menu / Dish name cannot be empty!");
      edtDishName.requestFocus();
    } else if (MEAL_DESCRIPTION.length() == 0) {
      inputDishDescription.setError("Please provide the Menu / Dish Description");
      edtDishDescription.requestFocus();
    } else if (MEAL_PRICE.length() == 0) {
      inputDishPrice.setError("The Menu / Dish needs to have a Price");
      edtDishPrice.requestFocus();
    } else {
      /* REMOVE THE ERRORS (IF SHOWN) */
      inputDishName.setErrorEnabled(false);
      inputDishDescription.setErrorEnabled(false);
      inputDishPrice.setErrorEnabled(false);

      /* CHECK FOR UNIQUE MENU / DISH NAME */
      new checkUniqueDishName().execute();
    }
  }
Exemplo n.º 2
0
  /** *** 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();
    }
  }