Ejemplo n.º 1
0
  private void validateAddress(boolean isTyping) {
    if (address == null) {
      String input = sendToAddressView.getText().toString().trim();

      try {
        if (!input.isEmpty()) {
          // Process fast the input string
          if (processInput(input)) return;

          // Try to fix address if needed
          parseAddress(GenericUtils.fixAddress(input));
        } else {
          // empty field should not raise error message
          clearAddress(false);
        }
        addressError.setVisibility(View.GONE);
      } catch (final AddressFormatException x) {
        // could not decode address at all
        if (!isTyping) {
          clearAddress(false);
          addressError.setText(R.string.address_error);
          addressError.setVisibility(View.VISIBLE);
        }
      }
      updateView();
    }
  }