diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MemorizingMessagingListener.java b/k9mail/src/main/java/com/fsck/k9/controller/MemorizingMessagingListener.java index e19dff811..9dfbfbb7e 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MemorizingMessagingListener.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MemorizingMessagingListener.java @@ -12,15 +12,6 @@ import com.fsck.k9.Account; class MemorizingMessagingListener extends MessagingListener { Map memories = new HashMap<>(31); - private Memory getMemory(Account account, String folderName) { - Memory memory = memories.get(getMemoryKey(account, folderName)); - if (memory == null) { - memory = new Memory(account, folderName); - memories.put(getMemoryKey(memory.account, memory.folderName), memory); - } - return memory; - } - synchronized void removeAccount(Account account) { Iterator> memIt = memories.entrySet().iterator(); @@ -35,32 +26,6 @@ class MemorizingMessagingListener extends MessagingListener { } } - @Override - public synchronized void synchronizeMailboxStarted(Account account, String folder) { - Memory memory = getMemory(account, folder); - memory.syncingState = MemorizingState.STARTED; - memory.folderCompleted = 0; - memory.folderTotal = 0; - } - - @Override - public synchronized void synchronizeMailboxFinished(Account account, String folder, - int totalMessagesInMailbox, int numNewMessages) { - Memory memory = getMemory(account, folder); - memory.syncingState = MemorizingState.FINISHED; - memory.syncingTotalMessagesInMailbox = totalMessagesInMailbox; - memory.syncingNumNewMessages = numNewMessages; - } - - @Override - public synchronized void synchronizeMailboxFailed(Account account, String folder, - String message) { - - Memory memory = getMemory(account, folder); - memory.syncingState = MemorizingState.FAILED; - memory.failureMessage = message; - } - synchronized void refreshOther(MessagingListener other) { if (other != null) { @@ -151,6 +116,32 @@ class MemorizingMessagingListener extends MessagingListener { } } + @Override + public synchronized void synchronizeMailboxStarted(Account account, String folder) { + Memory memory = getMemory(account, folder); + memory.syncingState = MemorizingState.STARTED; + memory.folderCompleted = 0; + memory.folderTotal = 0; + } + + @Override + public synchronized void synchronizeMailboxFinished(Account account, String folder, + int totalMessagesInMailbox, int numNewMessages) { + Memory memory = getMemory(account, folder); + memory.syncingState = MemorizingState.FINISHED; + memory.syncingTotalMessagesInMailbox = totalMessagesInMailbox; + memory.syncingNumNewMessages = numNewMessages; + } + + @Override + public synchronized void synchronizeMailboxFailed(Account account, String folder, + String message) { + + Memory memory = getMemory(account, folder); + memory.syncingState = MemorizingState.FAILED; + memory.failureMessage = message; + } + @Override public synchronized void setPushActive(Account account, String folderName, boolean active) { Memory memory = getMemory(account, folderName); @@ -213,6 +204,15 @@ class MemorizingMessagingListener extends MessagingListener { memory.processingCommandTitle = null; } + private Memory getMemory(Account account, String folderName) { + Memory memory = memories.get(getMemoryKey(account, folderName)); + if (memory == null) { + memory = new Memory(account, folderName); + memories.put(getMemoryKey(memory.account, memory.folderName), memory); + } + return memory; + } + private static String getMemoryKey(Account taccount, String tfolderName) { return taccount.getDescription() + ":" + tfolderName; }