Android Open Source - android-contacts-loader-demo Contact






From Project

Back to project page android-contacts-loader-demo.

License

The source code is released under:

Apache License

If you think the Android project android-contacts-loader-demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.codepath.examples.contactloader;
// w  w  w  .j av a2  s. co  m
import java.util.ArrayList;

public class Contact {
  public String id;
  public String name;
  public ArrayList<ContactEmail> emails;
  public ArrayList<ContactPhone> numbers;

  public Contact(String id, String name) {
    this.id = id;
    this.name = name;
    this.emails = new ArrayList<ContactEmail>();
    this.numbers = new ArrayList<ContactPhone>();
  }

  @Override
  public String toString() {
    String result = name;
    if (numbers.size() > 0) {
      ContactPhone number = numbers.get(0);
      result += " (" + number.number + " - " + number.type + ")";
    }
    if (emails.size() > 0) {
      ContactEmail email = emails.get(0);
      result += " [" + email.address + " - " + email.type + "]";
    }
    return result;
  }

  public void addEmail(String address, String type) {
    emails.add(new ContactEmail(address, type));
  }

  public void addNumber(String number, String type) {
    numbers.add(new ContactPhone(number, type));
  }
}




Java Source Code List

com.codepath.examples.contactloader.ContactEmail.java
com.codepath.examples.contactloader.ContactFetcher.java
com.codepath.examples.contactloader.ContactPhone.java
com.codepath.examples.contactloader.Contact.java
com.codepath.examples.contactloader.ContactsAdapter.java
com.codepath.examples.contactloader.MainActivity.java