#15699: Display contact list in adaptyer
diff --git a/src/com/savoirfairelinux/sflphone/client/CallContact.java b/src/com/savoirfairelinux/sflphone/client/CallContact.java
index bd8720b..bb7dbb6 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallContact.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallContact.java
@@ -57,4 +57,9 @@
{
return mEmail;
}
+
+ public String toString()
+ {
+ return mDisplayName;
+ }
}
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementList.java b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
index d492bba..255666a 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallElementList.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
@@ -59,6 +59,8 @@
import android.view.*;
import android.widget.*;
import android.widget.SearchView.OnQueryTextListener;
+import java.util.List;
+import java.util.ArrayList;
import com.savoirfairelinux.sflphone.R;
@@ -128,6 +130,7 @@
@Override
public void run()
{
+/*
ImageView photo_view = (ImageView) view.findViewById(R.id.photo);
TextView phones_txt = (TextView) view.findViewById(R.id.phones);
@@ -146,6 +149,7 @@
phones_txt.setVisibility(View.VISIBLE);
} else
phones_txt.setVisibility(View.GONE);
+*/
}
});
@@ -160,21 +164,43 @@
class CallElementAdapter extends ArrayAdapter
{
private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
+ private ContactManager mContactManager;
- public CallElementAdapter(Context context)
+ public CallElementAdapter(Context context, ContactManager manager)
{
- super(context, 0);
+ super(context, R.layout.call_element, manager.getContactList());
+ mContactManager = manager;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
- LayoutInflater inflater = LayoutInflater.from(getActivity());
- final long contact_id = 0;
- View v = inflater.inflate(R.layout.call_element, parent, false);
- infos_fetcher.execute(new InfosLoader(getActivity(), v, contact_id));
+ View rowView = convertView;
+ CallElementView callElementView = null;
- return v;
+ if(rowView == null) {
+ LayoutInflater inflater = LayoutInflater.from(getActivity());
+ final long contact_id = 0;
+ rowView = inflater.inflate(R.layout.call_element, parent, false);
+ infos_fetcher.execute(new InfosLoader(getActivity(), rowView, contact_id));
+
+ callElementView = new CallElementView();
+ // callElementView.toggleButton = (ImageButton) rowView.findViewById(R.id.toggleButton1);
+ // callElementView.button = (Button) rowView.findViewById(R.id.button2);
+ // callElementView.photo = (ImageView) rowView.findViewById(R.id.photo);
+ callElementView.displayName = (TextView) rowView.findViewById(R.id.display_name);
+ callElementView.phones = (TextView) rowView.findViewById(R.id.phones);
+
+ rowView.setTag(callElementView);
+ } else {
+ callElementView = (CallElementView) rowView.getTag();
+ }
+
+ CallContact c = mContactManager.getContact(position);
+ callElementView.displayName.setText(c.getDisplayName());
+ callElementView.phones.setText(c.getPhone());
+
+ return rowView;
}
/*
@@ -206,6 +232,15 @@
*/
};
+
+ public class CallElementView
+ {
+ protected ImageButton toggleButton;
+ protected Button button;
+ protected ImageView photo;
+ protected TextView displayName;
+ protected TextView phones;
+ }
@Override
public void onActivityCreated(Bundle savedInstanceState)
@@ -219,19 +254,21 @@
// We have a menu item to show in action bar.
setHasOptionsMenu(true);
+ mContactManager = new ContactManager(getActivity());
+
// Create an empty adapter we will use to display the loaded data.
- mAdapter = new CallElementAdapter(getActivity());
+ mAdapter = new CallElementAdapter(getActivity(), mContactManager);
setListAdapter(mAdapter);
// Start out with a progress indicator.
//setListShown(false);
- mContactManager = new ContactManager(getActivity());
-
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
getLoaderManager().initLoader(0, null, this);
+
+
}
@Override
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementView.java b/src/com/savoirfairelinux/sflphone/client/CallElementView.java
index 9ccd7bc..82606f0 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallElementView.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementView.java
@@ -63,9 +63,9 @@
protected void onAttachedToWindow()
{
// Layouts may be inflated or we may use fragments.
- contactCard = (ViewGroup) findViewById(R.id.contactview);
- callCard = (ViewGroup) findViewById(R.id.callview);
- callCard.setVisibility(View.GONE);
+ // contactCard = (ViewGroup) findViewById(R.id.contactview);
+ // callCard = (ViewGroup) findViewById(R.id.callview);
+ //callCard.setVisibility(View.GONE);
}
private Interpolator accelerator = new AccelerateInterpolator();
diff --git a/src/com/savoirfairelinux/sflphone/client/ContactManager.java b/src/com/savoirfairelinux/sflphone/client/ContactManager.java
index 07c5598..a0d9e25 100644
--- a/src/com/savoirfairelinux/sflphone/client/ContactManager.java
+++ b/src/com/savoirfairelinux/sflphone/client/ContactManager.java
@@ -115,5 +115,10 @@
{
return contactList.get(position);
}
+
+ public ArrayList<CallContact> getContactList()
+ {
+ return contactList;
+ }
}