aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities/Roster.java
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-08 21:13:24 +0100
committerlookshe <github@lookshe.org>2016-03-08 21:13:24 +0100
commit74d6d10cb76b7440f57db193a3c38e476206969c (patch)
tree665b7787c0f7bcb6d759e849972fa9658e84423f /src/main/java/de/thedevstack/conversationsplus/entities/Roster.java
parent7be757de90fb71042b79b88a76cd36fc07b2ee87 (diff)
parentf051dd0bcdbd35d101420fb1f75f33a565a1e0f8 (diff)
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/Roster.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Roster.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Roster.java b/src/main/java/de/thedevstack/conversationsplus/entities/Roster.java
index b1cb78b4..ec1a9426 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Roster.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Roster.java
@@ -9,7 +9,7 @@ import de.thedevstack.conversationsplus.xmpp.jid.Jid;
public class Roster {
final Account account;
- final HashMap<String, Contact> contacts = new HashMap<>();
+ final HashMap<Jid, Contact> contacts = new HashMap<>();
private String version = null;
public Roster(Account account) {
@@ -21,7 +21,7 @@ public class Roster {
return null;
}
synchronized (this.contacts) {
- Contact contact = contacts.get(jid.toBareJid().toString());
+ Contact contact = contacts.get(jid.toBareJid());
if (contact != null && contact.showInRoster()) {
return contact;
} else {
@@ -32,15 +32,13 @@ public class Roster {
public Contact getContact(final Jid jid) {
synchronized (this.contacts) {
- final Jid bareJid = jid.toBareJid();
- if (contacts.containsKey(bareJid.toString())) {
- return contacts.get(bareJid.toString());
- } else {
- Contact contact = new Contact(bareJid);
+ if (!contacts.containsKey(jid.toBareJid())) {
+ Contact contact = new Contact(jid.toBareJid());
contact.setAccount(account);
- contacts.put(bareJid.toString(), contact);
+ contacts.put(contact.getJid().toBareJid(), contact);
return contact;
}
+ return contacts.get(jid.toBareJid());
}
}
@@ -80,7 +78,7 @@ public class Roster {
contact.setAccount(account);
contact.setOption(Contact.Options.IN_ROSTER);
synchronized (this.contacts) {
- contacts.put(contact.getJid().toBareJid().toString(), contact);
+ contacts.put(contact.getJid().toBareJid(), contact);
}
}