mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-02 00:25:10 -04:00
Remove duplicate code between two message counting routines in ImapStore
This commit is contained in:
parent
9321a045d9
commit
7a543b45b1
@ -908,8 +908,8 @@ public class ImapStore extends Store
|
||||
return mMessageCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnreadMessageCount() throws MessagingException
|
||||
|
||||
private int getMessageCount(String criteria) throws MessagingException
|
||||
{
|
||||
checkOpen();
|
||||
try
|
||||
@ -917,7 +917,7 @@ public class ImapStore extends Store
|
||||
int count = 0;
|
||||
int start = 1;
|
||||
|
||||
List<ImapResponse> responses = executeSimpleCommand(String.format("SEARCH %d:* UNSEEN NOT DELETED", start));
|
||||
List<ImapResponse> responses = executeSimpleCommand(String.format("SEARCH %d:* "+criteria, start));
|
||||
for (ImapResponse response : responses)
|
||||
{
|
||||
if (ImapResponseParser.equalsIgnoreCase(response.get(0), "SEARCH"))
|
||||
@ -931,31 +931,20 @@ public class ImapStore extends Store
|
||||
{
|
||||
throw ioExceptionHandler(mConnection, ioe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnreadMessageCount() throws MessagingException
|
||||
{
|
||||
return getMessageCount("UNSEEN NOT DELETED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlaggedMessageCount() throws MessagingException
|
||||
{
|
||||
checkOpen();
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
int start = 1;
|
||||
|
||||
List<ImapResponse> responses = executeSimpleCommand(String.format("SEARCH %d:* FLAGGED NOT DELETED", start));
|
||||
for (ImapResponse response : responses)
|
||||
{
|
||||
if (ImapResponseParser.equalsIgnoreCase(response.get(0), "SEARCH"))
|
||||
{
|
||||
count += response.size() - 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
throw ioExceptionHandler(mConnection, ioe);
|
||||
}
|
||||
return getMessageCount("FLAGGED NOT DELETED");
|
||||
}
|
||||
|
||||
protected int getHighestUid()
|
||||
|
Loading…
Reference in New Issue
Block a user