From fa11864c41bf92cba50ab1f8af83ab9ad719dfde Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 8 Apr 2016 15:54:58 +0200 Subject: [PATCH] Improve chat messages memory usage --- src/org/linphone/ChatFragment.java | 9 ++++++++- submodules/linphone | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index 9038f1cd8..6e30ddd1a 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -333,6 +333,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC this.history = history; this.context = context; } + + public void destroy() { + this.history = null; + } public void refreshHistory() { this.history = null; @@ -473,6 +477,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC public void dispayMessageList() { messagesList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); if(chatRoom != null) { + if (adapter != null) adapter.destroy(); adapter = new ChatMessageAdapter(getActivity(), chatRoom.getHistory()); messagesList.setAdapter(adapter); } @@ -779,7 +784,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } private LinphoneChatMessage getMessageForId(int id) { - for (LinphoneChatMessage message : chatRoom.getHistory()) { + if (adapter == null) return null; + for (int i = 0; i < adapter.getCount(); i++) { + LinphoneChatMessage message = adapter.getItem(i); if (message.getStorageId() == id) { return message; } diff --git a/submodules/linphone b/submodules/linphone index fae2bf32e..f0cd38ef2 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit fae2bf32e5df948f7db07d849cfcf9f1260a8f82 +Subproject commit f0cd38ef228cf26bfdd0fd8bd037fd74fb1e1c5a