From bc2dc4d69236b5e75035c7877df068c3dc630ee7 Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Fri, 20 May 2022 07:44:35 -0400 Subject: [PATCH] ensure the notifications are sorted by time before display --- .../data/collection/NotificationsList.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/irccloud/android/data/collection/NotificationsList.java b/src/com/irccloud/android/data/collection/NotificationsList.java index b2992417..8e4cd51a 100644 --- a/src/com/irccloud/android/data/collection/NotificationsList.java +++ b/src/com/irccloud/android/data/collection/NotificationsList.java @@ -73,6 +73,8 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -557,6 +559,12 @@ private android.app.Notification buildNotification(String ticker, int cid, int b String uid = prefs.getString("uid", ""); int defaults = 0; String channelId = prefs.getBoolean("notify_channels", false) ? (uid + String.valueOf(bid)) : "highlight"; + Collections.sort(messages, new Comparator() { + @Override + public int compare(Notification notification, Notification t1) { + return Long.compare(notification.getEid(), t1.getEid()); + } + }); if(prefs.getBoolean("notify_channels", false)) createChannel(uid + String.valueOf(bid), title, NotificationManagerCompat.IMPORTANCE_HIGH, String.valueOf(cid)); NotificationCompat.Builder builder = new NotificationCompat.Builder(IRCCloudApplication.getInstance().getApplicationContext(), channelId) @@ -815,6 +823,13 @@ private synchronized void showMessageNotifications(String ticker) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()); String text = ""; final List notifications = getMessageNotifications(); + Collections.sort(notifications, new Comparator() { + @Override + public int compare(Notification notification, Notification t1) { + return Long.compare(notification.getEid(), t1.getEid()); + } + }); + boolean pref_avatarsOff = !prefs.getBoolean("avatars-off", true); boolean pref_avatarImages = prefs.getBoolean("avatar-images", false);