Compare commits
No commits in common. "6f1bd41cc9b13ed9c2ad3e75dfe92edbc043a01a" and "312bbaa5a6e8ad710d78fccb0202cfa0166c5119" have entirely different histories.
6f1bd41cc9
...
312bbaa5a6
1 changed files with 5 additions and 25 deletions
|
|
@ -5,7 +5,6 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
|
@ -13,38 +12,19 @@ public class UserActiveIndicatorController implements Initializable {
|
|||
|
||||
@FXML
|
||||
private Circle circle;
|
||||
private PeerUser user;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (user != null) {
|
||||
circle.getStyleClass().clear();
|
||||
if (user.isActive()) {
|
||||
circle.getStyleClass().add("active-user-dot");
|
||||
} else {
|
||||
circle.getStyleClass().add("inactive-user-dot");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onStateChange(PropertyChangeEvent propertyChangeEvent) {
|
||||
if (propertyChangeEvent.getPropertyName().equals("state")) {
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUser(PeerUser user) {
|
||||
if (this.user != null) {
|
||||
// remove old observer before setting new user
|
||||
this.user.removeObserver(this::onStateChange);
|
||||
circle.getStyleClass().clear();
|
||||
if (user.isActive()) {
|
||||
circle.getStyleClass().add("active-user-dot");
|
||||
} else {
|
||||
circle.getStyleClass().add("inactive-user-dot");
|
||||
}
|
||||
this.user = user;
|
||||
user.addObserver(this::onStateChange);
|
||||
updateState();
|
||||
}
|
||||
|
||||
public void setSize(double value) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue