From 63fa7910d03dcfbba1b85af43e125c69b8e97815 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Sun, 14 Mar 2010 00:04:18 +0100 Subject: [PATCH] Remove old messages from the conversation view if messages.count() > HISTORY_SIZE --- src/org/yaaic/adapter/MessageListAdapter.java | 5 +++++ src/org/yaaic/model/Conversation.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/org/yaaic/adapter/MessageListAdapter.java b/src/org/yaaic/adapter/MessageListAdapter.java index f903e14..afc30d8 100644 --- a/src/org/yaaic/adapter/MessageListAdapter.java +++ b/src/org/yaaic/adapter/MessageListAdapter.java @@ -78,6 +78,11 @@ public class MessageListAdapter extends BaseAdapter public synchronized void addMessage(Message message) { messages.add(message.renderTextView(context)); + + if (messages.size() > Conversation.HISTORY_SIZE) { + messages.remove(0); + } + notifyDataSetChanged(); } diff --git a/src/org/yaaic/model/Conversation.java b/src/org/yaaic/model/Conversation.java index 01e08ef..569510e 100644 --- a/src/org/yaaic/model/Conversation.java +++ b/src/org/yaaic/model/Conversation.java @@ -39,7 +39,7 @@ public abstract class Conversation public static final int TYPE_QUERY = 2; public static final int TYPE_SERVER = 3; - private static final int HISTORY_SIZE = 30; + public static final int HISTORY_SIZE = 30; private List buffer; private List history;