Example #1
0
  /**
   * Lis toutes les balises contacts et créé de nouveaux contacts pour chacune
   *
   * @return La liste des nouveaux contacts
   */
  public ArrayList<EnveloppeContact> lireContacts() {
    ArrayList<EnveloppeContact> listeContacts = new ArrayList();
    EnveloppeContact nouveauContact;
    String nomContact;
    Bitmap image;

    NodeList nList = getNodesParBalise(BalisesCommClient.BALISE_CONTACTS);

    for (int i = 0; i < nList.getLength(); i++) {
      try {
        Node node = nList.item(i);

        ArrayList<Long> listeNumeroTelephones = new ArrayList<>();
        NodeList nListNumero = getNodesParBalise(BalisesCommClient.BALISE_LISTE_NUMS_TEL);
        for (int j = 0; j < nListNumero.getLength(); j++) {
          Node nodeNum = nListNumero.item(j);
          listeNumeroTelephones.add(
              Long.parseLong(getElementParBalise(nodeNum, BalisesCommClient.BALISE_NUM_TEL)));
        }

        nomContact = getElementParBalise(node, BalisesCommClient.BALISE_NOM);
        image =
            Formatage.convertirStringEnImage(
                getElementParBalise(node, BalisesCommClient.BALISE_IMAGE_CONTACT));

        nouveauContact = new EnveloppeContact(listeNumeroTelephones, nomContact, null);
        listeContacts.add(nouveauContact);
      } catch (NumberFormatException nfe) {
        System.out.println(MESSAGE_ERREUR_TELEPHONE);
        i = nList.getLength();
      }
    }

    return listeContacts;
  }