deal with null bodys in message preview

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/utils/UIHelper.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/utils/UIHelper.java 🔗

@@ -95,10 +95,6 @@ public class UIHelper {
 		return sameDay(date,new Date(System.currentTimeMillis()));
 	}
 
-	public static boolean sameDay(long timestamp1, long timestamp2) {
-		return sameDay(new Date(timestamp1),new Date(timestamp2));
-	}
-
 	private static boolean sameDay(Date a, Date b) {
 		Calendar cal1 = Calendar.getInstance();
 		Calendar cal2 = Calendar.getInstance();
@@ -185,7 +181,9 @@ public class UIHelper {
 			}
 		} else {
 			String body = message.getBody();
-			if (body.length() > 256) {
+			if (body == null) {
+				body = "";
+			} else if (body.length() > 256) {
 				body = body.substring(0,256);
 			}
 			if (body.startsWith(Message.ME_COMMAND)) {