1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-02 14:02:17 -05:00

Extract out the listener we're using when we ask for new messages.

It may eventually get further extracted.
This commit is contained in:
Jesse Vincent 2009-12-27 16:51:45 +00:00
parent 9d417133b5
commit 94e61ab62c

View File

@ -546,14 +546,7 @@ public class MessagingController implements Runnable
} }
Folder localFolder = null; Folder localFolder = null;
MessageRetrievalListener retrievalListener =
try
{
Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication);
localFolder = localStore.getFolder(folder);
localFolder.open(OpenMode.READ_WRITE);
localFolder.getMessages(
new MessageRetrievalListener() new MessageRetrievalListener()
{ {
List<Message> pendingMessages = new ArrayList<Message>(); List<Message> pendingMessages = new ArrayList<Message>();
@ -572,7 +565,7 @@ public class MessagingController implements Runnable
totalDone++; totalDone++;
if (pendingMessages.size() > 10) if (pendingMessages.size() > 10)
{ {
callbackPending(); addPendingMessages();
} }
} }
@ -591,9 +584,9 @@ public class MessagingController implements Runnable
} }
public void messagesFinished(int number) public void messagesFinished(int number)
{ {
callbackPending(); addPendingMessages();
} }
private void callbackPending() private void addPendingMessages()
{ {
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
{ {
@ -605,7 +598,18 @@ public class MessagingController implements Runnable
} }
pendingMessages.clear(); pendingMessages.clear();
} }
}, };
try
{
Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication);
localFolder = localStore.getFolder(folder);
localFolder.open(OpenMode.READ_WRITE);
localFolder.getMessages(
retrievalListener,
false // Skip deleted messages false // Skip deleted messages
); );
if (K9.DEBUG) if (K9.DEBUG)