Ejemplo n.º 1
0
 /**
  * Method to get text of the EditText View
  *
  * @param editText
  * @return String text
  * @throws ViewException
  */
 public static String getText(EditText editText) {
   String text = "";
   try {
     validNull(editText);
     text = editText.getText().toString().trim();
   } catch (ViewException e) {
     Log.e(TAG, e.getMessage());
     e.printStackTrace();
   }
   return text;
 }
Ejemplo n.º 2
0
  /**
   * Method to set blank error to editTexts
   *
   * @param editTexts
   * @throws ViewException
   */
  public static void setBlankError(EditText... editTexts) {

    if (editTexts == null || editTexts.length == 0) {
      try {
        throw new ViewException(ViewException.MessageType.NULL);
      } catch (ViewException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
      }
    }

    for (EditText editText : editTexts) {
      editText.setError(null);
    }
  }
Ejemplo n.º 3
0
  /**
   * Method to validate if the list EditText Views is blank
   *
   * @param editTexts
   * @return Boolean
   * @throws ViewException
   */
  public static boolean isBlank(EditText... editTexts) {

    if (editTexts == null || editTexts.length == 0) {
      try {
        throw new ViewException(ViewException.MessageType.NULL);
      } catch (ViewException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
      }
    }

    for (EditText editText : editTexts) {
      String text = getText(editText);
      if (text.equalsIgnoreCase("")) {
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 4
0
  /**
   * Method to verify if a editText is number
   *
   * @param editTexts
   * @return
   * @throws ViewException
   */
  public static boolean isNumber(EditText... editTexts) {

    if (editTexts == null || editTexts.length == 0) {
      try {
        throw new ViewException(ViewException.MessageType.NULL);
      } catch (ViewException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
      }
    }

    for (EditText editText : editTexts) {
      String text = getText(editText);
      try {
        Integer.parseInt(text);
      } catch (Exception e) {
        return false;
      }
    }

    return true;
  }