diff options
author | Alan Young <consult.awy@gmail.com> | 2016-06-03 15:19:28 (GMT) |
---|---|---|
committer | Alan Young <consult.awy@gmail.com> | 2016-06-03 15:19:28 (GMT) |
commit | 8708b7b01cf4f36524bff3dc9aa5a7a6534ce221 (patch) | |
tree | ddcf591d8a37d326b3989b4f9a70c3d828dde964 | |
parent | 9d50093bee736d2b7b43756e9a41cfafbd568ee2 (diff) | |
download | stroke-8708b7b01cf4f36524bff3dc9aa5a7a6534ce221.zip stroke-8708b7b01cf4f36524bff3dc9aa5a7a6534ce221.tar.bz2 |
XMPPRosterImpl.getItems() needs to do deep copy.
And (therefore) XMPPRosterItem needs a copy constructor.
Change-Id: I9c4d833e559cf70d0c125fc6d841f16b8c2ce5b9
-rw-r--r-- | src/com/isode/stroke/roster/XMPPRosterImpl.java | 6 | ||||
-rw-r--r-- | src/com/isode/stroke/roster/XMPPRosterItem.java | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/com/isode/stroke/roster/XMPPRosterImpl.java b/src/com/isode/stroke/roster/XMPPRosterImpl.java index d87a20e..7b80104 100644 --- a/src/com/isode/stroke/roster/XMPPRosterImpl.java +++ b/src/com/isode/stroke/roster/XMPPRosterImpl.java @@ -73,7 +73,11 @@ public class XMPPRosterImpl extends XMPPRoster { @Override public Collection<XMPPRosterItem> getItems() { - return entries_.values(); + Collection<XMPPRosterItem> items = new ArrayList<XMPPRosterItem>(entries_.size()); + for (XMPPRosterItem item : entries_.values()) { + items.add(new XMPPRosterItem(item)); + } + return items; } @Override diff --git a/src/com/isode/stroke/roster/XMPPRosterItem.java b/src/com/isode/stroke/roster/XMPPRosterItem.java index 1412f83..25ebc47 100644 --- a/src/com/isode/stroke/roster/XMPPRosterItem.java +++ b/src/com/isode/stroke/roster/XMPPRosterItem.java @@ -5,6 +5,7 @@ package com.isode.stroke.roster; import java.util.Collection; +import java.util.ArrayList; import com.isode.stroke.elements.RosterItemPayload; import com.isode.stroke.jid.JID; @@ -21,6 +22,15 @@ public class XMPPRosterItem { this.groups = groups; this.subscription = subscription; } + + // Copy constructor + public XMPPRosterItem(XMPPRosterItem from) { + this(from.jid, from.name, null, from.subscription); + if (from.groups != null) { + groups = new ArrayList<String>(from.groups.size()); + groups.addAll(from.groups); + } + } public final JID getJID() { return jid; |