Fixed NullPointerException on empty date
This commit is contained in:
parent
bab984fb1f
commit
5201eaa320
@ -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();
|
||||
}
|
||||
|
@ -33,12 +33,15 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
||||
|
||||
setOpaque(true);
|
||||
|
||||
final String text = value.getContent().get(0).getText();
|
||||
final String date = value.getMetaData().getDate() == null ? ""
|
||||
: new SimpleDateFormat("dd.MM.yyyy hh:mm ")
|
||||
.format(value.getMetaData().getDate().toGregorianCalendar().getTime());
|
||||
|
||||
setText(String.format(
|
||||
"<html><p style=\"color:#d2d235\"><b><small>%s</b></small><br><p style=\"color:white\">%s</html>",
|
||||
new SimpleDateFormat("dd.MM.yyyy hh:mm ")
|
||||
.format(value.getMetaData().getDate().toGregorianCalendar().getTime()),
|
||||
value.getContent().get(0).getText()));
|
||||
|
||||
date,
|
||||
text));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user