aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/persistance/DatabaseBackend.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-06-14 16:59:07 +0200
committeriNPUTmice <daniel@gultsch.de>2014-06-14 16:59:07 +0200
commit7f1a4a6fb8f9a56236a3278b5f57348e61590948 (patch)
tree6fb9c6dc95f4206cbe5d8772139a082f33242a26 /src/eu/siacs/conversations/persistance/DatabaseBackend.java
parent7bdee8c19b642110882c71350557f6557857a143 (diff)
infite scrolling
Diffstat (limited to 'src/eu/siacs/conversations/persistance/DatabaseBackend.java')
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java22
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 26d09378..fbf45d25 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 {