Commit 1153e8cf authored by Francisco Cunha's avatar Francisco Cunha

P4A-800 - Factoring code improving readability

parent 4fb06931
......@@ -1737,8 +1737,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
// Send a notification of this message
if (shouldNotifyForMessage(account, localFolder, message)) {
// Notify with the localMessage so that we don't have to recalculate the content preview.
messagesToNotify.add(localMessage);
messagesToNotify.add(localMessage);
}
}
} catch (MessagingException | RuntimeException me) {
......@@ -1752,6 +1751,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
@Override
public void messagesFinished(int total) {
// Notify with the localMessages so that we don't have to recalculate the content preview.
notificationController.addNewMailsNotification(account, messagesToNotify, unreadBeforeStart);
}
});
......@@ -1824,11 +1824,11 @@ public class MessagingController implements Sync.MessageToSendCallback {
}
// Send a notification of this message
if (shouldNotifyForMessage(account, localFolder, message)) {
// Notify with the localMessage so that we don't have to recalculate the content preview.
messagesToNotify.add(localMessage);
}
}
notificationController.addNewMailsNotification(account,messagesToNotify,unreadBeforeStart);
// Notify with the localMessages so that we don't have to recalculate the content preview.
notificationController.addNewMailsNotification(account, messagesToNotify, unreadBeforeStart);
Timber.d("SYNC: Done fetching large messages for folder %s", folder);
}
......
......@@ -25,6 +25,7 @@ import java.util.List;
* </p>
*/
class NewMailNotifications {
private static final int FIRST_POSITION = 0;
private final NotificationController controller;
private final NotificationContentCreator contentCreator;
private final DeviceNotifications deviceNotifications;
......@@ -55,9 +56,9 @@ class NewMailNotifications {
}
void addNewMailsNotification(Account account, List<LocalMessage> messages, int unreadMessageCount) {
for (int i = 0; i < messages.size(); i++) {
LocalMessage message = messages.get(i);
addNewMailNotification(account, message, unreadMessageCount, i != 0);
for (int position = 0; position < messages.size(); position++) {
LocalMessage message = messages.get(position);
addNewMailNotification(account, message, unreadMessageCount, position != FIRST_POSITION);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment