mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
only fire roster listener if entry changed (SMACK-312)
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11827 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
a5693609b2
commit
e3962d15ae
2 changed files with 51 additions and 4 deletions
|
@ -852,10 +852,12 @@ public class Roster {
|
|||
}
|
||||
else {
|
||||
// If the entry was in then list then update its state with the new values
|
||||
entries.put(item.getUser(), entry);
|
||||
|
||||
// Keep note that an entry has been updated
|
||||
updatedEntries.add(item.getUser());
|
||||
RosterEntry oldEntry = entries.put(item.getUser(), entry);
|
||||
|
||||
// Keep note that an entry has been updated but only if it's different
|
||||
if (oldEntry == null || !oldEntry.equalsDeep(entry)) {
|
||||
updatedEntries.add(item.getUser());
|
||||
}
|
||||
}
|
||||
// If the roster entry belongs to any groups, remove it from the
|
||||
// list of unfiled entries.
|
||||
|
|
|
@ -181,6 +181,50 @@ public class RosterEntry {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether some other object is "equal to" this by comparing all members.
|
||||
* <p>
|
||||
* The {@link #equals(Object)} method returns <code>true</code> if the user JIDs are equal.
|
||||
*
|
||||
* @param obj the reference object with which to compare.
|
||||
* @return <code>true</code> if this object is the same as the obj argument; <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean equalsDeep(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RosterEntry other = (RosterEntry) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
}
|
||||
else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (status == null) {
|
||||
if (other.status != null)
|
||||
return false;
|
||||
}
|
||||
else if (!status.equals(other.status))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
}
|
||||
else if (!type.equals(other.type))
|
||||
return false;
|
||||
if (user == null) {
|
||||
if (other.user != null)
|
||||
return false;
|
||||
}
|
||||
else if (!user.equals(other.user))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static RosterPacket.Item toRosterItem(RosterEntry entry) {
|
||||
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
|
||||
item.setItemType(entry.getType());
|
||||
|
@ -191,4 +235,5 @@ public class RosterEntry {
|
|||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue