Remove unread count from MessagingListener.folderStatusChanged()
This commit is contained in:
parent
2dc75163a0
commit
aeef338efd
12 changed files with 25 additions and 38 deletions
|
@ -1000,7 +1000,7 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, folder, 0);
|
||||
l.folderStatusChanged(account, folder);
|
||||
}
|
||||
} finally {
|
||||
closeFolder(localFolder);
|
||||
|
@ -1085,14 +1085,8 @@ public class MessagingController {
|
|||
String folderServerId = entry.getKey();
|
||||
|
||||
// Notify listeners of changed folder status
|
||||
LocalFolder localFolder = localStore.getFolder(folderServerId);
|
||||
try {
|
||||
int unreadMessageCount = localFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, folderServerId, unreadMessageCount);
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
Timber.w(e, "Couldn't get unread count for folder: %s", folderServerId);
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, folderServerId);
|
||||
}
|
||||
|
||||
// TODO: Skip the remote part for all local-only folders
|
||||
|
@ -1134,9 +1128,8 @@ public class MessagingController {
|
|||
// Update the messages in the local store
|
||||
localFolder.setFlags(messages, Collections.singleton(flag), newState);
|
||||
|
||||
int unreadMessageCount = localFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, folderServerId, unreadMessageCount);
|
||||
l.folderStatusChanged(account, folderServerId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1682,7 +1675,7 @@ public class MessagingController {
|
|||
} catch (MessagingException me) {
|
||||
Timber.e(me, "Count not get unread count for account %s", account.getDescription());
|
||||
}
|
||||
l.folderStatusChanged(account, folderServerId, unreadMessageCount);
|
||||
l.folderStatusChanged(account, folderServerId);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1882,9 +1875,8 @@ public class MessagingController {
|
|||
if (unreadCountAffected) {
|
||||
// If this copy operation changes the unread count in the destination
|
||||
// folder, notify the listeners.
|
||||
int unreadMessageCount = localDestFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, destFolder, unreadMessageCount);
|
||||
l.folderStatusChanged(account, destFolder);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1908,8 +1900,8 @@ public class MessagingController {
|
|||
int unreadMessageCountSrc = localSrcFolder.getUnreadMessageCount();
|
||||
int unreadMessageCountDest = localDestFolder.getUnreadMessageCount();
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, srcFolder, unreadMessageCountSrc);
|
||||
l.folderStatusChanged(account, destFolder, unreadMessageCountDest);
|
||||
l.folderStatusChanged(account, srcFolder);
|
||||
l.folderStatusChanged(account, destFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2099,10 +2091,9 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, folder, localFolder.getUnreadMessageCount());
|
||||
l.folderStatusChanged(account, folder);
|
||||
if (localTrashFolder != null) {
|
||||
l.folderStatusChanged(account, account.getTrashFolder(),
|
||||
localTrashFolder.getUnreadMessageCount());
|
||||
l.folderStatusChanged(account, account.getTrashFolder());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2200,7 +2191,7 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
for (MessagingListener l : getListeners()) {
|
||||
l.folderStatusChanged(account, trashFolderServerId, 0);
|
||||
l.folderStatusChanged(account, trashFolderServerId);
|
||||
}
|
||||
|
||||
if (!isTrashLocalOnly) {
|
||||
|
@ -3021,9 +3012,9 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void folderStatusChanged(@NotNull String folderServerId, int unreadMessageCount) {
|
||||
public void folderStatusChanged(@NotNull String folderServerId) {
|
||||
for (MessagingListener messagingListener : getListeners(listener)) {
|
||||
messagingListener.folderStatusChanged(account, folderServerId, unreadMessageCount);
|
||||
messagingListener.folderStatusChanged(account, folderServerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface MessagingListener {
|
|||
void checkMailStarted(Context context, Account account);
|
||||
void checkMailFinished(Context context, Account account);
|
||||
|
||||
void folderStatusChanged(Account account, String folderServerId, int unreadMessageCount);
|
||||
void folderStatusChanged(Account account, String folderServerId);
|
||||
|
||||
void messageUidChanged(Account account, String folderServerId, String oldUid, String newUid);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public abstract class SimpleMessagingListener implements MessagingListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void folderStatusChanged(Account account, String folderServerId, int unreadMessageCount) {
|
||||
public void folderStatusChanged(Account account, String folderServerId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,7 +101,7 @@ public class MessageProvider extends ContentProvider {
|
|||
MessagingController messagingController = DI.get(MessagingController.class);
|
||||
messagingController.addListener(new SimpleMessagingListener() {
|
||||
@Override
|
||||
public void folderStatusChanged(Account account, String folderServerId, int unreadMessageCount) {
|
||||
public void folderStatusChanged(Account account, String folderServerId) {
|
||||
context.getContentResolver().notifyChange(CONTENT_URI, null);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ class MessageListWidgetUpdateListener(private val context: Context) : SimpleMess
|
|||
updateMailListWidget()
|
||||
}
|
||||
|
||||
override fun folderStatusChanged(account: Account, folderServerId: String, unreadMessageCount: Int) {
|
||||
override fun folderStatusChanged(account: Account, folderServerId: String) {
|
||||
updateMailListWidget()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class UnreadWidgetUpdateListener(private val unreadWidgetUpdater: UnreadWidgetUp
|
|||
updateUnreadWidget()
|
||||
}
|
||||
|
||||
override fun folderStatusChanged(account: Account, folderServerId: String, unreadMessageCount: Int) {
|
||||
override fun folderStatusChanged(account: Account, folderServerId: String) {
|
||||
updateUnreadWidget()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@ class FoldersLiveData(
|
|||
|
||||
private val messagingListener = object : SimpleMessagingListener() {
|
||||
override fun folderStatusChanged(
|
||||
account: Account?,
|
||||
folderServerId: String?,
|
||||
unreadMessageCount: Int
|
||||
account: Account,
|
||||
folderServerId: String
|
||||
) {
|
||||
if (account?.uuid == accountUuid) {
|
||||
loadFoldersAsync()
|
||||
|
|
|
@ -17,5 +17,5 @@ interface SyncListener {
|
|||
fun syncFinished(folderServerId: String, totalMessagesInMailbox: Int, numNewMessages: Int)
|
||||
fun syncFailed(folderServerId: String, message: String, exception: Exception?)
|
||||
|
||||
fun folderStatusChanged(folderServerId: String, unreadMessageCount: Int)
|
||||
fun folderStatusChanged(folderServerId: String)
|
||||
}
|
||||
|
|
|
@ -201,8 +201,7 @@ class ImapSync {
|
|||
int newMessages = downloadMessages(syncConfig, remoteFolder, backendFolder, remoteMessages, false,
|
||||
lastUid, listener);
|
||||
|
||||
int unreadMessageCount = backendFolder.getUnreadMessageCount();
|
||||
listener.folderStatusChanged(folder, unreadMessageCount);
|
||||
listener.folderStatusChanged(folder);
|
||||
|
||||
/* Notify listeners that we're finally done. */
|
||||
|
||||
|
|
|
@ -14,5 +14,5 @@ class SimpleSyncListener : SyncListener {
|
|||
override fun syncFlagChanged(folderServerId: String, messageServerId: String) = Unit
|
||||
override fun syncFinished(folderServerId: String, totalMessagesInMailbox: Int, numNewMessages: Int) = Unit
|
||||
override fun syncFailed(folderServerId: String, message: String, exception: Exception?) = Unit
|
||||
override fun folderStatusChanged(folderServerId: String, unreadMessageCount: Int) = Unit
|
||||
override fun folderStatusChanged(folderServerId: String) = Unit
|
||||
}
|
||||
|
|
|
@ -196,8 +196,7 @@ class Pop3Sync {
|
|||
int newMessages = downloadMessages(syncConfig, remoteFolder, backendFolder, remoteMessages, false,
|
||||
listener);
|
||||
|
||||
int unreadMessageCount = backendFolder.getUnreadMessageCount();
|
||||
listener.folderStatusChanged(folder, unreadMessageCount);
|
||||
listener.folderStatusChanged(folder);
|
||||
|
||||
/* Notify listeners that we're finally done. */
|
||||
|
||||
|
|
|
@ -196,8 +196,7 @@ class WebDavSync {
|
|||
int newMessages = downloadMessages(syncConfig, remoteFolder, backendFolder, remoteMessages, false,
|
||||
listener);
|
||||
|
||||
int unreadMessageCount = backendFolder.getUnreadMessageCount();
|
||||
listener.folderStatusChanged(folder, unreadMessageCount);
|
||||
listener.folderStatusChanged(folder);
|
||||
|
||||
/* Notify listeners that we're finally done. */
|
||||
|
||||
|
|
Loading…
Reference in a new issue