1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Minor refactoring for readability

This commit is contained in:
Jesse Vincent 2010-11-28 20:28:53 +00:00
parent b7617a3497
commit fa64f4c3a8

View File

@ -1568,70 +1568,73 @@ public class MessagingController implements Runnable
if (message.isSet(Flag.DELETED)) if (message.isSet(Flag.DELETED))
{ {
syncFlagMessages.add(message); syncFlagMessages.add(message);
return;
} }
else if (!isMessageSuppressed(account, folder, message)) else if (isMessageSuppressed(account, folder, message))
{ {
Message localMessage = localFolder.getMessage(message.getUid()); return;
}
if (localMessage == null) Message localMessage = localFolder.getMessage(message.getUid());
if (localMessage == null)
{
if (!flagSyncOnly)
{ {
if (!flagSyncOnly) if (!message.isSet(Flag.X_DOWNLOADED_FULL) && !message.isSet(Flag.X_DOWNLOADED_PARTIAL))
{
if (!message.isSet(Flag.X_DOWNLOADED_FULL) && !message.isSet(Flag.X_DOWNLOADED_PARTIAL))
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " has not yet been downloaded");
unsyncedMessages.add(message);
}
else
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " is partially or fully downloaded");
// Store the updated message locally
localFolder.appendMessages(new Message[] { message });
localMessage = localFolder.getMessage(message.getUid());
localMessage.setFlag(Flag.X_DOWNLOADED_FULL, message.isSet(Flag.X_DOWNLOADED_FULL));
localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, message.isSet(Flag.X_DOWNLOADED_PARTIAL));
for (MessagingListener l : getListeners())
{
l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage);
if (!localMessage.isSet(Flag.SEEN))
{
l.synchronizeMailboxNewMessage(account, folder, localMessage);
}
}
}
}
}
else if (!localMessage.isSet(Flag.DELETED))
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " is present in the local store");
if (!localMessage.isSet(Flag.X_DOWNLOADED_FULL) && !localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL))
{ {
if (K9.DEBUG) if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " has not yet been downloaded");
+ " is not downloaded, even partially; trying again");
unsyncedMessages.add(message); unsyncedMessages.add(message);
} }
else else
{ {
String newPushState = remoteFolder.getNewPushState(localFolder.getPushState(), message); if (K9.DEBUG)
if (newPushState != null) Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " is partially or fully downloaded");
// Store the updated message locally
localFolder.appendMessages(new Message[] { message });
localMessage = localFolder.getMessage(message.getUid());
localMessage.setFlag(Flag.X_DOWNLOADED_FULL, message.isSet(Flag.X_DOWNLOADED_FULL));
localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, message.isSet(Flag.X_DOWNLOADED_PARTIAL));
for (MessagingListener l : getListeners())
{ {
localFolder.setPushState(newPushState); l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage);
if (!localMessage.isSet(Flag.SEEN))
{
l.synchronizeMailboxNewMessage(account, folder, localMessage);
}
} }
syncFlagMessages.add(message);
} }
} }
} }
else if (!localMessage.isSet(Flag.DELETED))
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid() + " is present in the local store");
if (!localMessage.isSet(Flag.X_DOWNLOADED_FULL) && !localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL))
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Message with uid " + message.getUid()
+ " is not downloaded, even partially; trying again");
unsyncedMessages.add(message);
}
else
{
String newPushState = remoteFolder.getNewPushState(localFolder.getPushState(), message);
if (newPushState != null)
{
localFolder.setPushState(newPushState);
}
syncFlagMessages.add(message);
}
}
} }
private void fetchUnsyncedMessages(final Account account, final Folder remoteFolder, private void fetchUnsyncedMessages(final Account account, final Folder remoteFolder,