diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index 05d96eb24..fb5c94427 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -369,10 +369,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC @Override public View getView(final int position, View convertView, ViewGroup parent) { LinphoneChatMessage message = history.get(position); - RelativeLayout rlayout = new RelativeLayout(context); + RelativeLayout rlayout; + if (convertView != null) { + rlayout = (RelativeLayout) convertView; + View bbv = rlayout.getChildAt(0); + rlayout.removeAllViews(); + BubbleChat bbc = (BubbleChat) bbv.getTag(); + bbc.destroy(); + } else { + rlayout = new RelativeLayout(context); + } BubbleChat bubble = new BubbleChat(context, message, contact); View v = bubble.getView(); + v.setTag(bubble); registerForContextMenu(v); @@ -470,7 +480,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC adapter.refreshHistory(); adapter.notifyDataSetChanged(); } else { - adapter = new ChatMessageAdapter(getActivity()); + adapter = new ChatMessageAdapter(getActivity().getApplicationContext()); messagesList.setAdapter(adapter); } } diff --git a/src/org/linphone/HistoryListFragment.java b/src/org/linphone/HistoryListFragment.java index 98aff2296..53357bf36 100644 --- a/src/org/linphone/HistoryListFragment.java +++ b/src/org/linphone/HistoryListFragment.java @@ -208,7 +208,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs()); if (!hideHistoryListAndDisplayMessageIfEmpty()) { historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); - historyList.setAdapter(new CallHistoryAdapter(getActivity())); + historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext())); } } diff --git a/src/org/linphone/ui/BubbleChat.java b/src/org/linphone/ui/BubbleChat.java index 651ca6087..50b3d4ea6 100644 --- a/src/org/linphone/ui/BubbleChat.java +++ b/src/org/linphone/ui/BubbleChat.java @@ -236,6 +236,10 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen public View getView() { return view; } + + public void destroy() { + defaultBitmap.recycle(); + } private String timestampToHumanDate(Context context, long timestamp) { try {