File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
AndroidSDK/src/com/leanplum Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -306,9 +306,25 @@ public List<String> messagesIds() {
306306 try {
307307 Collections .sort (messageIds , new Comparator <String >() {
308308 @ Override
309- public int compare (String firstMessage , String secondMessage ) {
310- Date firstDate = messageForId (firstMessage ).getDeliveryTimestamp ();
311- Date secondDate = messageForId (secondMessage ).getDeliveryTimestamp ();
309+ public int compare (String firstMessageId , String secondMessageId ) {
310+ // Message that is null will be moved to the back of the list.
311+ LeanplumInboxMessage firstMessage = messageForId (firstMessageId );
312+ if (firstMessage == null ) {
313+ return -1 ;
314+ }
315+ LeanplumInboxMessage secondMessage = messageForId (secondMessageId );
316+ if (secondMessage == null ) {
317+ return 1 ;
318+ }
319+ // Message with null date will be moved to the back of the list.
320+ Date firstDate = firstMessage .getDeliveryTimestamp ();
321+ if (firstDate == null ) {
322+ return -1 ;
323+ }
324+ Date secondDate = secondMessage .getDeliveryTimestamp ();
325+ if (secondDate == null ) {
326+ return 1 ;
327+ }
312328 return firstDate .compareTo (secondDate );
313329 }
314330 });
Original file line number Diff line number Diff line change @@ -146,9 +146,13 @@ public Date deliveryTimestamp() {
146146 }
147147
148148 /**
149- * Returns the delivery timestamp of the newsfeed message.
149+ * Returns the delivery timestamp of the newsfeed message,
150+ * or null if delivery timestamp is not present.
150151 */
151152 public Date getDeliveryTimestamp () {
153+ if (deliveryTimestamp == null ) {
154+ return null ;
155+ }
152156 return new Date (deliveryTimestamp );
153157 }
154158
You can’t perform that action at this time.
0 commit comments