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

remove 100loc by replacing a pattern with a method.

This commit is contained in:
Jesse Vincent 2010-11-28 20:28:58 +00:00
parent fa64f4c3a8
commit 9784d0e943

View File

@ -501,10 +501,7 @@ public class MessagingController implements Runnable
{ {
for (Folder localFolder : localFolders) for (Folder localFolder : localFolders)
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
} }
} }
@ -590,10 +587,7 @@ public class MessagingController implements Runnable
{ {
for (Folder localFolder : localFolders) for (Folder localFolder : localFolders)
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
} }
} }
@ -715,10 +709,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
} }
@ -1316,18 +1307,26 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (providedRemoteFolder == null && remoteFolder != null) if (providedRemoteFolder == null)
{ {
remoteFolder.close(); closeFolder(remoteFolder);
}
if (tLocalFolder != null)
{
tLocalFolder.close();
} }
closeFolder(tLocalFolder);
} }
} }
private void closeFolder(Folder f)
{
if (f != null)
{
f.close();
}
}
/* /*
* If the folder is a "special" folder we need to see if it exists * If the folder is a "special" folder we need to see if it exists
* on the remote server. It if does not exist we'll try to create it. If we * on the remote server. It if does not exist we'll try to create it. If we
@ -1518,8 +1517,6 @@ public class MessagingController implements Runnable
// fp.add(FetchProfile.Item.ENVELOPE); // fp.add(FetchProfile.Item.ENVELOPE);
downloadSmallMessages(account, remoteFolder, localFolder, smallMessages, progress, unreadBeforeStart, newMessages, todo, fp); downloadSmallMessages(account, remoteFolder, localFolder, smallMessages, progress, unreadBeforeStart, newMessages, todo, fp);
smallMessages.clear(); smallMessages.clear();
/* /*
@ -1527,9 +1524,6 @@ public class MessagingController implements Runnable
*/ */
fp.clear(); fp.clear();
fp.add(FetchProfile.Item.STRUCTURE); fp.add(FetchProfile.Item.STRUCTURE);
downloadLargeMessages(account, remoteFolder, localFolder, largeMessages, progress, unreadBeforeStart, newMessages, todo, fp); downloadLargeMessages(account, remoteFolder, localFolder, largeMessages, progress, unreadBeforeStart, newMessages, todo, fp);
largeMessages.clear(); largeMessages.clear();
@ -1695,8 +1689,7 @@ public class MessagingController implements Runnable
} }
// And include it in the view // And include it in the view
if (message.getSubject() != null && if (message.getSubject() != null && message.getFrom() != null)
message.getFrom() != null)
{ {
/* /*
* We check to make sure that we got something worth * We check to make sure that we got something worth
@ -1707,10 +1700,7 @@ public class MessagingController implements Runnable
if (!isMessageSuppressed(account, folder, message)) if (!isMessageSuppressed(account, folder, message))
{ {
// Store the new message locally // Store the new message locally
localFolder.appendMessages(new Message[] localFolder.appendMessages(new Message[] { message });
{
message
});
Message localMessage = localFolder.getMessage(message.getUid()); Message localMessage = localFolder.getMessage(message.getUid());
syncFlags(localMessage, message); syncFlags(localMessage, message);
@ -1736,10 +1726,7 @@ public class MessagingController implements Runnable
} }
} }
public void messageStarted(String uid, int number, int ofTotal) public void messageStarted(String uid, int number, int ofTotal) {}
{
}
public void messagesFinished(int total) {} public void messagesFinished(int total) {}
}); });
} }
@ -1836,14 +1823,11 @@ public class MessagingController implements Runnable
catch (MessagingException me) catch (MessagingException me)
{ {
addErrorMessage(account, null, me); addErrorMessage(account, null, me);
Log.e(K9.LOG_TAG, "SYNC: fetch small messages", me); Log.e(K9.LOG_TAG, "SYNC: fetch small messages", me);
} }
} }
public void messageStarted(String uid, int number, int ofTotal) public void messageStarted(String uid, int number, int ofTotal) {}
{
}
public void messagesFinished(int total) {} public void messagesFinished(int total) {}
}); });
@ -2339,11 +2323,7 @@ public class MessagingController implements Runnable
*/ */
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.BODY); fp.add(FetchProfile.Item.BODY);
localFolder.fetch(new Message[] localFolder.fetch(new Message[] { localMessage } , fp, null);
{
localMessage
}
, fp, null);
String oldUid = localMessage.getUid(); String oldUid = localMessage.getUid();
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true); localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
remoteFolder.appendMessages(new Message[] { localMessage }); remoteFolder.appendMessages(new Message[] { localMessage });
@ -2408,14 +2388,8 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(remoteFolder);
{ closeFolder(localFolder);
remoteFolder.close();
}
if (localFolder != null)
{
localFolder.close();
}
} }
} }
private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, boolean isCopy, String uids[]) private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, boolean isCopy, String uids[])
@ -2527,14 +2501,8 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteSrcFolder != null) closeFolder(remoteSrcFolder);
{ closeFolder(remoteDestFolder);
remoteSrcFolder.close();
}
if (remoteDestFolder != null)
{
remoteDestFolder.close();
}
} }
@ -2621,10 +2589,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(remoteFolder);
{
remoteFolder.close();
}
} }
} }
@ -2673,10 +2638,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(remoteFolder);
{
remoteFolder.close();
}
} }
} }
private void queueExpunge(final Account account, final String folderName) private void queueExpunge(final Account account, final String folderName)
@ -2727,10 +2689,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(remoteFolder);
{
remoteFolder.close();
}
} }
} }
@ -2868,14 +2827,8 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{ closeFolder(remoteFolder);
localFolder.close();
}
if (remoteFolder != null)
{
remoteFolder.close();
}
} }
} }
@ -3060,10 +3013,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
}//setMesssageFlag }//setMesssageFlag
@ -3163,16 +3113,9 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder!=null) closeFolder(remoteFolder);
{ closeFolder(localFolder);
remoteFolder.close(); }
}
if (localFolder!=null)
{
localFolder.close();
}
}//finally
}//run }//run
}); });
} }
@ -3367,14 +3310,8 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(localFolder);
{ closeFolder(remoteFolder);
remoteFolder.close();
}
if (localFolder != null)
{
localFolder.close();
}
} }
} }
}); });
@ -3512,10 +3449,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
return false; return false;
} }
@ -3689,17 +3623,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
try
{
localFolder.close();
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Exception while closing folder", e);
}
}
} }
} }
@ -3945,10 +3869,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
} }
@ -4096,15 +4017,8 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
closeFolder(localFolder);
if (localFolder != null) closeFolder(localTrashFolder);
{
localFolder.close();
}
if (localTrashFolder != null)
{
localTrashFolder.close();
}
} }
} }
@ -4137,10 +4051,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (remoteFolder != null) closeFolder(remoteFolder);
{
remoteFolder.close();
}
} }
} }
@ -4182,10 +4093,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
localFolder.close();
}
} }
} }
}); });
@ -4525,10 +4433,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (tLocalFolder != null) closeFolder(tLocalFolder);
{
tLocalFolder.close();
}
} }
} }
} }
@ -5208,17 +5113,7 @@ public class MessagingController implements Runnable
} }
finally finally
{ {
if (localFolder != null) closeFolder(localFolder);
{
try
{
localFolder.close();
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Unable to close localFolder", e);
}
}
latch.countDown(); latch.countDown();
} }