From 903a3d17f2055bdc5ba4f316419b158ce453bfda Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 7 Apr 2018 23:28:35 +0200 Subject: return contact and account.getServer() as String --- .../pixart/messenger/services/AvatarService.java | 2 +- .../services/ContactChooserTargetService.java | 2 +- .../messenger/services/NotificationService.java | 4 ++-- .../messenger/services/XmppConnectionService.java | 23 +++++++++++----------- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src/main/java/de/pixart/messenger/services') diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java index 4e3ed756b..96114727e 100644 --- a/src/main/java/de/pixart/messenger/services/AvatarService.java +++ b/src/main/java/de/pixart/messenger/services/AvatarService.java @@ -220,7 +220,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { final List users = mucOptions.getUsersRelevantForNameAndAvatar(); if (users.size() == 0) { Conversation c = mucOptions.getConversation(); - bitmap = getImpl(c.getName(), c.getJid().asBareJid().toString(), size); + bitmap = getImpl(c.getName().toString(), c.getJid().asBareJid().toString(), size); } else { bitmap = getImpl(users, size); } diff --git a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java index 53a7b6625..e05c719dc 100644 --- a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java +++ b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java @@ -46,7 +46,7 @@ public class ContactChooserTargetService extends ChooserTargetService implements final int pixel = (int) (48 * getResources().getDisplayMetrics().density); for (int i = 0; i < Math.min(conversations.size(), MAX_TARGETS); ++i) { final Conversation conversation = conversations.get(i); - final String name = conversation.getName(); + final String name = conversation.getName().toString(); final Icon icon = Icon.createWithBitmap(mXmppConnectionService.getAvatarService().get(conversation, pixel)); final float score = 1 - (1.0f / MAX_TARGETS) * i; final Bundle extras = new Bundle(); diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index ad6c9f518..64c168a1b 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -350,7 +350,7 @@ public class NotificationService { for (final ArrayList messages : notifications.values()) { if (messages.size() > 0) { conversation = messages.get(0).getConversation(); - final String name = conversation.getName(); + final String name = conversation.getName().toString(); SpannableString styledString; if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) { int count = messages.size(); @@ -389,7 +389,7 @@ public class NotificationService { final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService); if (messages.size() >= 1) { final Conversation conversation = messages.get(0).getConversation(); - final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName()); + final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName().toString()); mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService() .get(conversation, getPixel(64))); mBuilder.setContentTitle(conversation.getName()); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 6f6c4188b..5c19a9de2 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -65,6 +65,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -3753,42 +3754,40 @@ public class XmppConnectionService extends Service { } - public List getKnownHosts() { - final List hosts = new ArrayList<>(); + public Collection getKnownHosts() { + final Set hosts = new HashSet<>(); for (final Account account : getAccounts()) { - if (!hosts.contains(account.getServer().toString())) { - hosts.add(account.getServer().toString()); - } + hosts.add(account.getServer()); for (final Contact contact : account.getRoster().getContacts()) { if (contact.showInRoster()) { - final String server = contact.getServer().toString(); + final String server = contact.getServer(); if (server != null && !hosts.contains(server)) { hosts.add(server); } } } } - if (Config.DOMAIN_LOCK != null && !hosts.contains(Config.DOMAIN_LOCK)) { + if (Config.DOMAIN_LOCK != null) { hosts.add(Config.DOMAIN_LOCK); } - if (Config.MAGIC_CREATE_DOMAIN != null && !hosts.contains(Config.MAGIC_CREATE_DOMAIN)) { + if (Config.MAGIC_CREATE_DOMAIN != null) { hosts.add(Config.MAGIC_CREATE_DOMAIN); } return hosts; } - public List getKnownConferenceHosts() { - final ArrayList mucServers = new ArrayList<>(); + public Collection getKnownConferenceHosts() { + final Set mucServers = new HashSet<>(); for (final Account account : accounts) { if (account.getXmppConnection() != null) { final String server = account.getXmppConnection().getMucServer(); - if (server != null && !mucServers.contains(server)) { + if (server != null) { mucServers.add(server); } for (Bookmark bookmark : account.getBookmarks()) { final Jid jid = bookmark.getJid(); final String s = jid == null ? null : jid.getDomain(); - if (s != null && !mucServers.contains(s)) { + if (s != null) { mucServers.add(s); } } -- cgit v1.2.3