equal
deleted
inserted
replaced
77 } |
77 } |
78 }; |
78 }; |
79 |
79 |
80 private int mID; |
80 private int mID; |
81 private int mStatus; |
81 private int mStatus; |
82 private String mJID; |
82 private final String mJID; |
83 private String mSelectedRes; |
83 private String mSelectedRes; |
84 private String mMsgState; |
84 private String mMsgState; |
85 private List<String> mRes; |
85 private List<String> mRes; |
86 private List<String> mGroups; |
86 private final List<String> mGroups = new ArrayList<String>(); |
87 private String mName; |
87 private String mName; |
88 |
|
89 /** |
|
90 * Constructor. |
|
91 */ |
|
92 public Contact() { |
|
93 } |
|
94 |
88 |
95 /** |
89 /** |
96 * Construct a contact from a parcel. |
90 * Construct a contact from a parcel. |
97 * @param in parcel to use for construction |
91 * @param in parcel to use for construction |
98 */ |
92 */ |
102 mJID = in.readString(); |
96 mJID = in.readString(); |
103 mSelectedRes = in.readString(); |
97 mSelectedRes = in.readString(); |
104 mName = in.readString(); |
98 mName = in.readString(); |
105 mMsgState = in.readString(); |
99 mMsgState = in.readString(); |
106 mRes = new ArrayList<String>(); |
100 mRes = new ArrayList<String>(); |
107 mGroups = new ArrayList<String>(); |
|
108 in.readStringList(mRes); |
101 in.readStringList(mRes); |
109 in.readStringList(mGroups); |
102 in.readStringList(mGroups); |
110 } |
103 } |
111 |
104 |
112 /** |
105 /** |
121 mRes = new ArrayList<String>(); |
114 mRes = new ArrayList<String>(); |
122 String res = StringUtils.parseResource(jid); |
115 String res = StringUtils.parseResource(jid); |
123 mSelectedRes = res; |
116 mSelectedRes = res; |
124 if (!"".equals(res)) |
117 if (!"".equals(res)) |
125 mRes.add(res); |
118 mRes.add(res); |
126 mGroups = new ArrayList<String>(); |
|
127 } |
119 } |
128 |
120 |
129 /** |
121 /** |
130 * Create a contact from a Uri. |
122 * Create a contact from a Uri. |
131 * @param uri an uri for the contact |
123 * @param uri an uri for the contact |
141 mMsgState = null; |
133 mMsgState = null; |
142 mRes = new ArrayList<String>(); |
134 mRes = new ArrayList<String>(); |
143 String res = StringUtils.parseResource(enduri); |
135 String res = StringUtils.parseResource(enduri); |
144 mSelectedRes = res; |
136 mSelectedRes = res; |
145 mRes.add(res); |
137 mRes.add(res); |
146 mGroups = new ArrayList<String>(); |
|
147 } |
138 } |
148 |
139 |
149 /** |
140 /** |
150 * {@inheritDoc} |
141 * {@inheritDoc} |
151 */ |
142 */ |
281 /** |
272 /** |
282 * Set the groups the contact is in. |
273 * Set the groups the contact is in. |
283 * @param groups the mGroups to set |
274 * @param groups the mGroups to set |
284 */ |
275 */ |
285 public void setGroups(List<String> groups) { |
276 public void setGroups(List<String> groups) { |
286 this.mGroups = groups; |
277 mGroups.clear(); |
|
278 mGroups.addAll(groups); |
287 } |
279 } |
288 |
280 |
289 /** |
281 /** |
290 * set the id of te contact on the phone contact list. |
282 * set the id of te contact on the phone contact list. |
291 * @param mid the mID to set |
283 * @param mid the mID to set |
292 */ |
284 */ |
293 public void setID(int mid) { |
285 public void setID(int mid) { |
294 mID = mid; |
286 mID = mid; |
295 } |
|
296 |
|
297 /** |
|
298 * Set the Jabber ID of the contact. |
|
299 * @param jid the jabber ID to set |
|
300 */ |
|
301 public void setJID(String jid) { |
|
302 mJID = jid; |
|
303 } |
287 } |
304 |
288 |
305 /** |
289 /** |
306 * Set the resource of the contact. |
290 * Set the resource of the contact. |
307 * @param resource to set. |
291 * @param resource to set. |
363 * @param presence The presence packet which contains the status |
347 * @param presence The presence packet which contains the status |
364 */ |
348 */ |
365 public void setStatus(PresenceAdapter presence) { |
349 public void setStatus(PresenceAdapter presence) { |
366 mStatus = presence.getStatus(); |
350 mStatus = presence.getStatus(); |
367 mMsgState = presence.getStatusText(); |
351 mMsgState = presence.getStatusText(); |
368 |
|
369 } |
352 } |
370 |
353 |
371 /** |
354 /** |
372 * {@inheritDoc} |
355 * {@inheritDoc} |
373 */ |
356 */ |
421 StringBuilder build = new StringBuilder(mJID); |
404 StringBuilder build = new StringBuilder(mJID); |
422 if (!"".equals(mSelectedRes)) |
405 if (!"".equals(mSelectedRes)) |
423 build.append('/').append(mSelectedRes); |
406 build.append('/').append(mSelectedRes); |
424 return build.toString(); |
407 return build.toString(); |
425 } |
408 } |
|
409 |
|
410 @Override |
|
411 public boolean equals(Object other) { |
|
412 if (!(other instanceof Contact)) |
|
413 return false; |
|
414 if (other == this) |
|
415 return true; |
|
416 Contact c = (Contact) other; |
|
417 return c.getJID().equals(getJID()); |
|
418 } |
|
419 |
|
420 @Override |
|
421 public int hashCode() { |
|
422 return mJID.hashCode(); |
|
423 } |
|
424 |
426 } |
425 } |