From 3c5cad2c466d5e49a5f53f08e19b4da57b535fe4 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Sun, 21 Mar 2010 16:38:29 +0100 Subject: [PATCH] MessageListAdapter: Add a bunch of messages via addBulkMessages() --- src/org/yaaic/adapter/MessageListAdapter.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/org/yaaic/adapter/MessageListAdapter.java b/src/org/yaaic/adapter/MessageListAdapter.java index 050b2e7..d6907e7 100644 --- a/src/org/yaaic/adapter/MessageListAdapter.java +++ b/src/org/yaaic/adapter/MessageListAdapter.java @@ -90,6 +90,28 @@ public class MessageListAdapter extends BaseAdapter notifyDataSetChanged(); } + /** + * Add a list of messages to the list + * + * @param messages + */ + public void addBulkMessages(LinkedList messages) + { + LinkedList mMessages = this.messages; + Context mContext = this.context; + int mSize = messages.size(); + + for (int i = 0; i < mSize; i++) { + mMessages.add(messages.get(i).renderTextView(mContext)); + + if (mMessages.size() > Conversation.HISTORY_SIZE) { + mMessages.remove(0); + } + } + + notifyDataSetChanged(); + } + /** * Get number of items *