Improved memory/performances on History

This commit is contained in:
Sylvain Berfini 2012-06-22 15:23:14 +02:00
parent b8f8b69703
commit 5613cd79dd

View file

@ -27,6 +27,8 @@ import org.linphone.core.LinphoneCallLog;
import org.linphone.core.LinphoneCallLog.CallStatus; import org.linphone.core.LinphoneCallLog.CallStatus;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -133,8 +135,10 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
} }
class CallHistoryAdapter extends BaseAdapter { class CallHistoryAdapter extends BaseAdapter {
private Bitmap missedCall, outgoingCall, incomingCall;
CallHistoryAdapter(Context aContext) { CallHistoryAdapter(Context aContext) {
missedCall = BitmapFactory.decodeResource(getResources(), R.drawable.missed_call);
if (onlyDisplayMissedCalls) { if (onlyDisplayMissedCalls) {
List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>(); List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>();
@ -144,6 +148,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
} }
} }
mLogs = missedCalls; mLogs = missedCalls;
} else {
outgoingCall = BitmapFactory.decodeResource(getResources(), R.drawable.outgoing_call);
incomingCall = BitmapFactory.decodeResource(getResources(), R.drawable.incoming_call);
} }
} }
public int getCount() { public int getCount() {
@ -151,11 +158,10 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
} }
public Object getItem(int position) { public Object getItem(int position) {
return position; return mLogs.get(position);
} }
public long getItemId(int position) { public long getItemId(int position) {
return position; return position;
} }
@ -179,13 +185,13 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
if (log.getDirection() == CallDirection.Incoming) { if (log.getDirection() == CallDirection.Incoming) {
address = log.getFrom(); address = log.getFrom();
if (log.getStatus() == CallStatus.Missed) { if (log.getStatus() == CallStatus.Missed) {
callDirection.setImageResource(R.drawable.missed_call); callDirection.setImageBitmap(missedCall);
} else { } else {
callDirection.setImageResource(R.drawable.incoming_call); callDirection.setImageBitmap(incomingCall);
} }
} else { } else {
address = log.getTo(); address = log.getTo();
callDirection.setImageResource(R.drawable.outgoing_call); callDirection.setImageBitmap(outgoingCall);
} }
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver()); LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());