Example #1
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      final ViewContactHolder holder;
      final Contact item = (Contact) ListContacts.get(position);

      if (convertView == null) {
        LayoutInflater inflater =
            (LayoutInflater) ctxt.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        holder = new ViewContactHolder();
        convertView = inflater.inflate(R.layout.item_equipe, parent, false);
        holder.nameContact = (TextView) convertView.findViewById(R.id.nameMember);
        holder.addPhoto = (ImageView) convertView.findViewById(R.id.imgContact);
        convertView.setTag(holder);
      } else holder = (ViewContactHolder) convertView.getTag();

      if (item.getIdContact() != null) {
        Uri uriImage = Utils.getPhotoFromId(getActivity(), Integer.parseInt(item.getIdContact()));
        if (uriImage != null) {
          holder.addPhoto.setImageURI(uriImage);
        } else holder.addPhoto.setImageResource(R.drawable.ic_contact_picture_180_holo_light);

        String name = Utils.getContactNamebyId(getActivity(), item.getIdContact());
        if (name != null) {
          holder.nameContact.setVisibility(View.VISIBLE);
          holder.nameContact.setText(name);
        }
      } else {
        holder.nameContact.setVisibility(View.GONE);
        holder.addPhoto.setImageResource(android.R.drawable.ic_menu_add);
      }

      return convertView;
    }
Example #2
0
 private boolean contactExist(String contactId) {
   for (Contact c : contacts) {
     if (c.getIdContact().equals(contactId)) return true;
   }
   return false;
 }