mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
When doing a message search, break it into "first 10" and "more" -
because a long SQL query takes more time before starting to return results, K-9 was increasingly slow on large folders. Doing two searches may take marginally more time but starts getting results back to the UI much faster.
This commit is contained in:
parent
e05784d41d
commit
d02ddda19b
@ -816,13 +816,11 @@ public class LocalStore extends Store implements Serializable
|
||||
{
|
||||
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
||||
Cursor cursor = null;
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
// pull out messages most recent first, since that's what the default sort is
|
||||
cursor = mDb.rawQuery(queryString, placeHolders);
|
||||
cursor = mDb.rawQuery(queryString + " LIMIT 10", placeHolders);
|
||||
|
||||
|
||||
int i = 0;
|
||||
while (cursor.moveToNext())
|
||||
{
|
||||
LocalMessage message = new LocalMessage(null, folder);
|
||||
@ -835,11 +833,26 @@ public class LocalStore extends Store implements Serializable
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (listener != null)
|
||||
cursor.close();
|
||||
cursor = mDb.rawQuery(queryString + " LIMIT -1 OFFSET 10", placeHolders);
|
||||
|
||||
while (cursor.moveToNext())
|
||||
{
|
||||
listener.messagesFinished(i);
|
||||
LocalMessage message = new LocalMessage(null, folder);
|
||||
message.populateFromGetMessageCursor(cursor);
|
||||
|
||||
messages.add(message);
|
||||
if (listener != null)
|
||||
{
|
||||
listener.messageFinished(message, i, -1);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.d(K9.LOG_TAG,"Got an exception "+e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (cursor != null)
|
||||
@ -847,6 +860,10 @@ public class LocalStore extends Store implements Serializable
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
if (listener != null)
|
||||
{
|
||||
listener.messagesFinished(i);
|
||||
}
|
||||
|
||||
return messages.toArray(EMPTY_MESSAGE_ARRAY);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user