Performed updating of the UI on the UI thread
This commit is contained in:
parent
d61cd8a36e
commit
de00601a2c
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
/target/
|
/target/
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
@ -17,6 +17,7 @@ import envoy.event.EventBus;
|
|||||||
import envoy.event.MessageStatusChangeEvent;
|
import envoy.event.MessageStatusChangeEvent;
|
||||||
import envoy.event.UserStatusChangeEvent;
|
import envoy.event.UserStatusChangeEvent;
|
||||||
import envoy.util.EnvoyLog;
|
import envoy.util.EnvoyLog;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@ -74,7 +75,7 @@ public final class ChatSceneController {
|
|||||||
chat.getMessages().add(message);
|
chat.getMessages().add(message);
|
||||||
|
|
||||||
// Update UI if in current chat
|
// Update UI if in current chat
|
||||||
if (chat == currentChat) messageList.getItems().add(message);
|
if (chat == currentChat) Platform.runLater(() -> messageList.getItems().add(message));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to message status changes
|
// Listen to message status changes
|
||||||
@ -83,11 +84,11 @@ public final class ChatSceneController {
|
|||||||
message.setStatus(e.get());
|
message.setStatus(e.get());
|
||||||
|
|
||||||
// Update UI if in current chat
|
// Update UI if in current chat
|
||||||
if (currentChat != null && message.getSenderID() == currentChat.getRecipient().getID()) messageList.refresh();
|
if (currentChat != null && message.getSenderID() == currentChat.getRecipient().getID()) Platform.runLater(() -> messageList.refresh());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to user status changes
|
// Listen to user status changes
|
||||||
eventBus.register(UserStatusChangeEvent.class, e -> userList.refresh());
|
eventBus.register(UserStatusChangeEvent.class, e -> Platform.runLater(() -> userList.refresh()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeData(LocalDB localDB, Client client, WriteProxy writeProxy) {
|
void initializeData(LocalDB localDB, Client client, WriteProxy writeProxy) {
|
||||||
@ -96,7 +97,6 @@ public final class ChatSceneController {
|
|||||||
this.writeProxy = writeProxy;
|
this.writeProxy = writeProxy;
|
||||||
|
|
||||||
// TODO: handle offline mode
|
// TODO: handle offline mode
|
||||||
// userList.setItems(FXCollections.observableList(client.getContacts()));
|
|
||||||
userList.setItems(FXCollections.observableList(localDB.getUser().getContacts().stream().collect(Collectors.toList())));
|
userList.setItems(FXCollections.observableList(localDB.getUser().getContacts().stream().collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user