Merge pull request #15 from informatik-ag-ngl/f/multiple_chats
Fixed NullPointerException on empty date
This commit is contained in:
commit
96e94c2254
@ -233,14 +233,12 @@ public class ChatWindow extends JFrame {
|
|||||||
|
|
||||||
new Timer(5000, (evt) -> {
|
new Timer(5000, (evt) -> {
|
||||||
Messages unreadMessages = client.getUnreadMessages(client.getSender().getID());
|
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 i = 0; i < unreadMessages.getMessage().size(); i++) {
|
for (int j = 0; j < partnerChatList.size(); j++)
|
||||||
for (int j = 0; j < partnerChatList.size(); j++) {
|
if (partnerChatList.get(j)
|
||||||
if(partnerChatList.get(j).getRecipient().getID() == unreadMessages.getMessage().get(i).getMetaData().getSender()) {
|
.getRecipient()
|
||||||
|
.getID() == unreadMessages.getMessage().get(i).getMetaData().getSender())
|
||||||
partnerChatList.get(j).appendMessage(unreadMessages.getMessage().get(i));
|
partnerChatList.get(j).appendMessage(unreadMessages.getMessage().get(i));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
contentPane.revalidate();
|
contentPane.revalidate();
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,15 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
|||||||
|
|
||||||
setOpaque(true);
|
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(
|
setText(String.format(
|
||||||
"<html><p style=\"color:#d2d235\"><b><small>%s</b></small><br><p style=\"color:white\">%s</html>",
|
"<html><p style=\"color:#d2d235\"><b><small>%s</b></small><br><p style=\"color:white\">%s</html>",
|
||||||
new SimpleDateFormat("dd.MM.yyyy hh:mm ")
|
date,
|
||||||
.format(value.getMetaData().getDate().toGregorianCalendar().getTime()),
|
text));
|
||||||
value.getContent().get(0).getText()));
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user