Improved memory while in chat view

This commit is contained in:
Sylvain Berfini 2016-05-12 12:26:04 +02:00
parent cebe5d9b00
commit 19381472a4
3 changed files with 17 additions and 3 deletions

View file

@ -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);
}
}

View file

@ -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()));
}
}

View file

@ -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 {