Properly override updateItem method of list cells
This commit is contained in:
		@@ -28,7 +28,10 @@ public class ContactListCell extends ListCell<Contact> {
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void updateItem(Contact contact, boolean empty) {
 | 
			
		||||
		super.updateItem(contact, empty);
 | 
			
		||||
		if (!empty && contact != null) {
 | 
			
		||||
		if (empty || contact == null) {
 | 
			
		||||
			setText(null);
 | 
			
		||||
			setGraphic(null);
 | 
			
		||||
		} else {
 | 
			
		||||
			// the infoLabel displays specific contact info, i.e. status of a user or amount
 | 
			
		||||
			// of members in a group
 | 
			
		||||
			Label infoLabel = null;
 | 
			
		||||
@@ -51,7 +54,7 @@ public class ContactListCell extends ListCell<Contact> {
 | 
			
		||||
						break;
 | 
			
		||||
				}
 | 
			
		||||
				infoLabel.setTextFill(textColor);
 | 
			
		||||
			} else 
 | 
			
		||||
			} else
 | 
			
		||||
				// group specific infos
 | 
			
		||||
				infoLabel = new Label(String.valueOf(((Group) contact).getContacts().size()) + " members");
 | 
			
		||||
			setGraphic(new VBox(new Label(contact.getName()), infoLabel));
 | 
			
		||||
 
 | 
			
		||||
@@ -45,10 +45,15 @@ public class MessageListCell extends ListCell<Message> {
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void updateItem(Message message, boolean empty) {
 | 
			
		||||
		super.updateItem(message, empty);
 | 
			
		||||
		setGraphic(!empty && message != null ? new HBox(
 | 
			
		||||
		if(empty || message == null) {
 | 
			
		||||
			setText(null);
 | 
			
		||||
			setGraphic(null);
 | 
			
		||||
		} else {
 | 
			
		||||
			setGraphic(new HBox(
 | 
			
		||||
					new VBox(
 | 
			
		||||
					 new Label(dateFormat.format(message.getCreationDate())),
 | 
			
		||||
					 new Label(message.getText())),
 | 
			
		||||
					new Label("", new ImageView(statusImages.get(message.getStatus())))) : null);
 | 
			
		||||
					new Label("", new ImageView(statusImages.get(message.getStatus())))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user