Adjusted ChatControl constructor and added Javadoc

This commit is contained in:
DieGurke 2020-07-12 14:46:35 +02:00
parent a6efe7cd9b
commit 95cead4dee
3 changed files with 14 additions and 5 deletions

View File

@ -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; }
/**

View File

@ -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);

View File

@ -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);
}