From 1ded9df82ba68c48c109bd1d661c61432d32a10d Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 23 Oct 2019 17:17:15 +0200 Subject: [PATCH] Fixed NullPointerException on empty date --- src/main/java/envoy/client/ui/ChatWindow.java | 12 +++++------- .../java/envoy/client/ui/MessageListRenderer.java | 11 +++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 8f11ec2..cce9e73 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -233,14 +233,12 @@ public class ChatWindow extends JFrame { new Timer(5000, (evt) -> { Messages unreadMessages = client.getUnreadMessages(client.getSender().getID()); - System.out.println(unreadMessages.getMessage().get(0)); - for (int i = 0; i < unreadMessages.getMessage().size(); i++) { - for (int j = 0; j < partnerChatList.size(); j++) { - if(partnerChatList.get(j).getRecipient().getID() == unreadMessages.getMessage().get(i).getMetaData().getSender()) { + for (int i = 0; i < unreadMessages.getMessage().size(); i++) + for (int j = 0; j < partnerChatList.size(); j++) + if (partnerChatList.get(j) + .getRecipient() + .getID() == unreadMessages.getMessage().get(i).getMetaData().getSender()) partnerChatList.get(j).appendMessage(unreadMessages.getMessage().get(i)); - } - } - } }).start(); contentPane.revalidate(); } diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index ad965c4..a61ae5f 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -33,12 +33,15 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer

%s

%s", - new SimpleDateFormat("dd.MM.yyyy hh:mm ") - .format(value.getMetaData().getDate().toGregorianCalendar().getTime()), - value.getContent().get(0).getText())); - + date, + text)); return this; } }