Skip to content

Commit

Permalink
Bug fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RedDragon0293 committed Apr 27, 2024
1 parent 16092bb commit e296a9b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/cn/reddragon/eportal/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public void updateUI() {
if (Authenticator.type == null) {
sb.append("(...)");
} else
for (LoginType it : LoginType.values()) {
if (Objects.equals(it, Authenticator.type)) {
sb.append('(');
sb.append(it.displayName);
sb.append(')');
break;
for (LoginType it : LoginType.values()) {
if (Objects.equals(it, Authenticator.type)) {
sb.append('(');
sb.append(it.displayName);
sb.append(')');
break;
}
}
}
} else {
button.setText("Login");
sb.append("Offline");
Expand All @@ -73,8 +73,9 @@ protected void onLoginButtonClick() {
button.setText("Logout");
} else if (button.getText().equals("Logout")) {
new Thread(() -> {
HttpURLConnection connection = null;
try {
HttpURLConnection connection = Authenticator.logout();
connection = Authenticator.logout();
if (connection == null) {
Platform.runLater(() -> {
resultText.setText("Error!");
Expand All @@ -90,6 +91,10 @@ protected void onLoginButtonClick() {
} catch (Exception e) {
e.printStackTrace();
Platform.runLater(() -> resultText.setText(e.getMessage()));
} finally {
if (connection != null) {
connection.disconnect();
}
}
Platform.runLater(() -> button.setDisable(false));
}).start();
Expand Down

0 comments on commit e296a9b

Please sign in to comment.