Optimize new message notifications (1)

pull/160/head
M66B 6 years ago
parent e642c378f2
commit ac71c03f21

@ -1985,24 +1985,29 @@ class Core {
// Difference // Difference
for (String group : groupMessages.keySet()) { for (String group : groupMessages.keySet()) {
List<Notification> notifications = getNotificationUnseen(context, group, groupMessages.get(group)); // Difference
final List<Long> add = new ArrayList<>(); final List<Long> add = new ArrayList<>();
final List<Long> remove = new ArrayList<>(groupNotifying.get(group)); final List<Long> remove = new ArrayList<>(groupNotifying.get(group));
for (TupleMessageEx message : groupMessages.get(group)) {
long id = (message.content ? message.id : -message.id);
if (remove.contains(id)) {
remove.remove(id);
Log.i("Notify existing=" + id);
} else {
remove.remove(-id);
add.add(id);
Log.i("Notify adding=" + id);
}
}
for (Notification notification : notifications) { if (remove.size() + add.size() == 0) {
Long id = notification.extras.getLong("id", 0); Log.i("Notify unchanged");
if (id != 0) continue;
if (remove.contains(id)) {
remove.remove(id);
Log.i("Notify existing=" + id);
} else {
remove.remove(-id);
add.add(id);
Log.i("Notify adding=" + id);
}
} }
// Build notifications
List<Notification> notifications = getNotificationUnseen(context, group, groupMessages.get(group));
Log.i("Notify group=" + group + " count=" + notifications.size() + Log.i("Notify group=" + group + " count=" + notifications.size() +
" added=" + add.size() + " removed=" + remove.size()); " added=" + add.size() + " removed=" + remove.size());

Loading…
Cancel
Save