mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-07 02:30:10 -05:00
Initial implementation of loading only 25 rows from the message list
from SQLite at once. The hope is that this will improve perceived performance on large folders by starting message display sooner. In the case of a background sync while we're loading, we _may_ end up doing more work than necessary, since we implement paging by "date received"
This commit is contained in:
parent
aa4f3535eb
commit
a1302afe75
@ -1264,8 +1264,14 @@ public class LocalStore extends Store implements Serializable
|
||||
open(OpenMode.READ_WRITE);
|
||||
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
||||
Cursor cursor = null;
|
||||
int totalSeen = 0;
|
||||
int i;
|
||||
try
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
// pull out messages most recent first, since that's what the default sort is
|
||||
cursor = mDb.rawQuery(
|
||||
"SELECT subject, sender_list, date, uid, flags, id, to_list, cc_list, "
|
||||
@ -1273,14 +1279,14 @@ public class LocalStore extends Store implements Serializable
|
||||
+ "FROM messages "
|
||||
+ "WHERE "
|
||||
+ (includeDeleted ? "" : "deleted = 0 AND ")
|
||||
+ " folder_id = ? ORDER BY date DESC"
|
||||
+ " folder_id = ? ORDER BY date DESC LIMIT 25 OFFSET "+ totalSeen
|
||||
, new String[]
|
||||
{
|
||||
Long.toString(mFolderId)
|
||||
});
|
||||
|
||||
|
||||
int i = 0;
|
||||
i = 0;
|
||||
ArrayList<LocalMessage> messagesForHeaders = new ArrayList<LocalMessage>();
|
||||
while (cursor.moveToNext())
|
||||
{
|
||||
@ -1294,10 +1300,20 @@ public class LocalStore extends Store implements Serializable
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (listener != null)
|
||||
{
|
||||
listener.messagesFinished(i);
|
||||
totalSeen += i;
|
||||
if ( i == 0 ) {
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
listener.messagesFinished(totalSeen);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -1599,6 +1615,8 @@ public class LocalStore extends Store implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void saveHeaders(long id, MimeMessage message)
|
||||
{
|
||||
deleteHeaders(id);
|
||||
@ -2042,6 +2060,7 @@ public class LocalStore extends Store implements Serializable
|
||||
private int mAttachmentCount;
|
||||
private String mSubject;
|
||||
|
||||
|
||||
private boolean mHeadersLoaded = false;
|
||||
private boolean mMessageDirty = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user