Adjusted ChatControl constructor and added Javadoc
This commit is contained in:
parent
d2ec04b568
commit
7b6b3a28f3
@ -114,8 +114,17 @@ public class Chat implements Serializable {
|
||||
messages.add(0, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the unreadMessagesAmount by 1
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public void incrementUnreadAmount() { unreadAmount++; }
|
||||
|
||||
/**
|
||||
* @return the amount of unreadMesages in this chat
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public int getUnreadAmount() { return unreadAmount; }
|
||||
|
||||
/**
|
||||
|
@ -22,10 +22,10 @@ import envoy.data.User;
|
||||
public class ChatControl extends HBox {
|
||||
|
||||
/**
|
||||
* @param contact the contact that should be formatted
|
||||
* @param chat the chat to display
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public ChatControl(Chat chat, int unreadMessagesAmount) {
|
||||
public ChatControl(Chat chat) {
|
||||
// Container with contact name
|
||||
final var vBox = new VBox();
|
||||
final var nameLabel = new Label(chat.getRecipient().getName());
|
||||
@ -41,11 +41,11 @@ public class ChatControl extends HBox {
|
||||
vBox.getChildren().add(new Label(((Group) chat.getRecipient()).getContacts().size() + " members"));
|
||||
|
||||
getChildren().add(vBox);
|
||||
if (unreadMessagesAmount != 0) {
|
||||
if (chat.getUnreadAmount() != 0) {
|
||||
Region spacing = new Region();
|
||||
setHgrow(spacing, Priority.ALWAYS);
|
||||
getChildren().add(spacing);
|
||||
final var unreadMessagesLabel = new Label("" + unreadMessagesAmount);
|
||||
final var unreadMessagesLabel = new Label(Integer.toString(chat.getUnreadAmount()));
|
||||
unreadMessagesLabel.setMinSize(15, 15);
|
||||
var vBox2 = new VBox();
|
||||
vBox2.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
@ -36,7 +36,7 @@ public class ContactListCellFactory extends ListCell<Chat> {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
final var control = new ChatControl(chat, chat.getUnreadAmount());
|
||||
final var control = new ChatControl(chat);
|
||||
prefWidthProperty().bind(listView.widthProperty().subtract(40));
|
||||
setGraphic(control);
|
||||
}
|
||||
|
Reference in New Issue
Block a user