Contact.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. package com.usai.Contacts;
  2. import android.graphics.Bitmap;
  3. import android.provider.ContactsContract;
  4. import java.io.ByteArrayOutputStream;
  5. public class Contact {
  6. public static final String NUMBER_TYPE_WORK = String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_WORK);
  7. public static final String NUMBER_TYPE_FAX_WORK = String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK);
  8. public static final String EMAIL_TYPE_WORK = String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_WORK);
  9. public static final String WEB_TYPE_HOMEPAGE = String.valueOf(ContactsContract.CommonDataKinds.Website.TYPE_HOMEPAGE);
  10. public static final String POSTAL_TYPE_WORK = String.valueOf(ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
  11. private String id;
  12. private String name;
  13. private String number;
  14. private String numberType;
  15. private String fax;
  16. private String faxType;
  17. private String email;
  18. private String emailType;
  19. private String homePage;
  20. private String homePageType;
  21. private String address;
  22. private String addressType;
  23. private Bitmap photo;
  24. public Contact(){
  25. }
  26. public Contact(Contact contact){
  27. copyContact(contact);
  28. }
  29. public void copyContact(Contact contact) {
  30. this.name = contact.getName();
  31. this.number = contact.getNumber();
  32. this.numberType = contact.getNumberType();
  33. this.email = contact.getEmail();
  34. this.emailType = contact.getEmailType();
  35. this.fax = contact.getFax();
  36. this.faxType = contact.getFaxType();
  37. this.homePage = contact.getHomePage();
  38. this.homePageType = contact.getHomePageType();
  39. this.address = contact.getAddress();
  40. this.addressType = contact.getAddressType();
  41. this.photo = contact.getPhoto();
  42. }
  43. public String getEmail() {
  44. return email;
  45. }
  46. public String getEmailType() {
  47. if (emailType == null) {
  48. return EMAIL_TYPE_WORK;
  49. }
  50. return emailType;
  51. }
  52. public String getId() {
  53. return id;
  54. }
  55. public String getName() {
  56. return name;
  57. }
  58. public String getNumber() {
  59. return number;
  60. }
  61. public String getNumberType() {
  62. if (numberType == null) {
  63. return NUMBER_TYPE_WORK;
  64. }
  65. return numberType;
  66. }
  67. public String getFax() {
  68. return fax;
  69. }
  70. public String getFaxType() {
  71. if (faxType == null) {
  72. return NUMBER_TYPE_FAX_WORK;
  73. }
  74. return faxType;
  75. }
  76. public String getAddress() {
  77. return address;
  78. }
  79. public String getAddressType() {
  80. if (addressType == null) {
  81. return POSTAL_TYPE_WORK;
  82. }
  83. return addressType;
  84. }
  85. public String getHomePage() {
  86. if (homePage == null) {
  87. return WEB_TYPE_HOMEPAGE;
  88. }
  89. return homePage;
  90. }
  91. public String getHomePageType() {
  92. return homePageType;
  93. }
  94. public Bitmap getPhoto() {
  95. return photo;
  96. }
  97. public byte[] getPhotoData() {
  98. if (photo == null) {
  99. return null;
  100. }
  101. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  102. photo.compress(Bitmap.CompressFormat.PNG, 100, baos);
  103. byte[] data = baos.toByteArray();
  104. return data;
  105. }
  106. public void setEmail(String email) {
  107. this.email = email;
  108. }
  109. public void setEmailType(String emailType) {
  110. this.emailType = emailType;
  111. }
  112. public void setId(String id) {
  113. this.id = id;
  114. }
  115. public void setName(String name) {
  116. this.name = name;
  117. }
  118. public void setNumber(String number) {
  119. this.number = number;
  120. }
  121. public void setNumberType(String numberType) {
  122. this.numberType = numberType;
  123. }
  124. public void setFax(String fax) {
  125. this.fax = fax;
  126. }
  127. public void setFaxType(String faxType) {
  128. this.faxType = faxType;
  129. }
  130. public void setHomePage(String homePage) {
  131. this.homePage = homePage;
  132. }
  133. public void setHomePageType(String homePageType) {
  134. this.homePageType = homePageType;
  135. }
  136. public void setAddress(String address) {
  137. this.address = address;
  138. }
  139. public void setAddressType(String addressType) {
  140. this.addressType = addressType;
  141. }
  142. public void setPhoto(Bitmap photo) {
  143. this.photo = photo;
  144. }
  145. }