1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

extract the "synchronize one folder" method

This commit is contained in:
Jesse Vincent 2010-11-28 20:28:46 +00:00
parent 36bb10fb2c
commit 3404edca28

View File

@ -4355,7 +4355,6 @@ public class MessagingController implements Runnable
Store localStore = account.getLocalStore();
for (final Folder folder : localStore.getPersonalNamespaces(false))
{
folder.open(Folder.OpenMode.READ_WRITE);
folder.refresh(prefs);
@ -4371,7 +4370,7 @@ public class MessagingController implements Runnable
" which is in display mode " + fDisplayClass + " while account is in display mode " + aDisplayMode);
*/
return;
continue;
}
if (modeMismatch(aSyncMode, fSyncClass))
@ -4383,8 +4382,58 @@ public class MessagingController implements Runnable
" which is in sync mode " + fSyncClass + " while account is in sync mode " + aSyncMode);
*/
return;
continue;
}
synchronizeFolder(context, account, folder, ignoreLastCheckedTime, accountInterval, notifMgr, listener);
}
}
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to synchronize account " + account.getName(), e);
addErrorMessage(account, null, e);
}
finally
{
putBackground("clear notification flag for " + account.getDescription(), null, new Runnable()
{
public void run()
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Clearing notification flag for " + account.getDescription());
account.setRingNotified(false);
try
{
AccountStats stats = account.getStats(context);
if (stats == null || stats.unreadMessageCount == 0)
{
notifyAccountCancel(context, account);
}
}
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to getUnreadMessageCount for account: " + account, e);
}
}
}
);
}
}
private void synchronizeFolder(
final Context context, final Account account,
final Folder folder,
final boolean ignoreLastCheckedTime,
final long accountInterval,
final NotificationManager notifMgr,
final MessagingListener listener
)
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Folder " + folder.getName() + " was last synced @ " +
@ -4471,45 +4520,12 @@ public class MessagingController implements Runnable
}
}
);
}
}
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to synchronize account " + account.getName(), e);
addErrorMessage(account, null, e);
}
finally
{
putBackground("clear notification flag for " + account.getDescription(), null, new Runnable()
{
public void run()
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Clearing notification flag for " + account.getDescription());
account.setRingNotified(false);
try
{
AccountStats stats = account.getStats(context);
if (stats == null || stats.unreadMessageCount == 0)
{
notifyAccountCancel(context, account);
}
}
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to getUnreadMessageCount for account: " + account, e);
}
}
}
);
}
}
public void compact(final Account account, final MessagingListener ml)
{
putBackground("compact:" + account.getDescription(), ml, new Runnable()