Skip to content

Commit

Permalink
Don't allow empty port in server port TextEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoshibata committed Nov 13, 2019
1 parent c397931 commit a2866dd
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -71,8 +71,21 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {}

@Override
public void afterTextChanged(Editable editable) {
if (editable.length() >= 5 && Integer.parseInt(editable.toString()) > 65535)
serverPortTextView.setText("65535");
if (editable.length() > 0) {
String text = editable.toString();
int value = Integer.parseInt(text);
if (value == 0) {
serverPortTextView.setText("");
return;
}
if (value > 65535)
serverPortTextView.setText("65535");
else if (text.charAt(0) == '0')
serverPortTextView.setText(Integer.toString(value));
startStopButton.setEnabled(true);
} else {
startStopButton.setEnabled(false);
}
}
});

Expand Down

0 comments on commit a2866dd

Please sign in to comment.