diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-06-14 16:59:07 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-06-14 16:59:07 +0200 |
commit | 7f1a4a6fb8f9a56236a3278b5f57348e61590948 (patch) | |
tree | 6fb9c6dc95f4206cbe5d8772139a082f33242a26 /src/eu/siacs/conversations/persistance | |
parent | 7bdee8c19b642110882c71350557f6557857a143 (diff) |
infite scrolling
Diffstat (limited to 'src/eu/siacs/conversations/persistance')
-rw-r--r-- | src/eu/siacs/conversations/persistance/DatabaseBackend.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java index 26d09378e..fbf45d250 100644 --- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -128,14 +128,26 @@ public class DatabaseBackend extends SQLiteOpenHelper { } return list; } + + public List<Message> getMessages(Conversation conversations, int limit) { + return getMessages(conversations, limit,-1); + } - public List<Message> getMessages(Conversation conversation, int limit) { + public List<Message> getMessages(Conversation conversation, int limit, long timestamp) { List<Message> list = new CopyOnWriteArrayList<Message>(); SQLiteDatabase db = this.getReadableDatabase(); - String[] selectionArgs = { conversation.getUuid() }; - Cursor cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION - + "=?", selectionArgs, null, null, Message.TIME_SENT + " DESC", - String.valueOf(limit)); + Cursor cursor; + if (timestamp==-1) { + String[] selectionArgs = { conversation.getUuid() }; + cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION + + "=?", selectionArgs, null, null, Message.TIME_SENT + " DESC", + String.valueOf(limit)); + } else { + String[] selectionArgs = { conversation.getUuid() , ""+timestamp}; + cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION + + "=? and "+Message.TIME_SENT+"<?", selectionArgs, null, null, Message.TIME_SENT + " DESC", + String.valueOf(limit)); + } if (cursor.getCount() > 0) { cursor.moveToLast(); do { |