summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Young <consult.awy@gmail.com>2017-04-05 15:52:49 (GMT)
committerAlan Young <consult.awy@gmail.com>2017-04-05 15:52:49 (GMT)
commit0b496cbffef4d75d07b2e9709328c7d6b172afd7 (patch)
tree6b51476b18f9e52e7de64f2d90fb0aa0acb8e630 /src
parentc20ff48f2c55c9b48a8fb181a3c3fdb9921bd054 (diff)
downloadstroke-0b496cbffef4d75d07b2e9709328c7d6b172afd7.zip
stroke-0b496cbffef4d75d07b2e9709328c7d6b172afd7.tar.bz2
Fix PresenceOracle initialization of PriorityQueue with initial size 0.
Change-Id: I624ede83351e2901272173f775d4f098743183b3
Diffstat (limited to 'src')
-rw-r--r--src/com/isode/stroke/presence/PresenceOracle.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com/isode/stroke/presence/PresenceOracle.java b/src/com/isode/stroke/presence/PresenceOracle.java
index e983d51..f1710a6 100644
--- a/src/com/isode/stroke/presence/PresenceOracle.java
+++ b/src/com/isode/stroke/presence/PresenceOracle.java
@@ -199,10 +199,14 @@ public class PresenceOracle {
* @return The relevant presence.
*/
public static Presence getActivePresence(Collection<? extends Presence> presences) {
+
+ PresenceAccountCmp comparator = new PresenceAccountCmp();
+ int size = presences.size();
+ if (size < 1) size = 1;
- PriorityQueue<Presence> online = new PriorityQueue<Presence>(presences.size(),new PresenceAccountCmp());
- PriorityQueue<Presence> away = new PriorityQueue<Presence>(presences.size(),new PresenceAccountCmp());
- PriorityQueue<Presence> offline = new PriorityQueue<Presence>(presences.size(),new PresenceAccountCmp());
+ PriorityQueue<Presence> online = new PriorityQueue<Presence>(size, comparator);
+ PriorityQueue<Presence> away = new PriorityQueue<Presence>(size, comparator);
+ PriorityQueue<Presence> offline = new PriorityQueue<Presence>(size, comparator);
for (Presence presence : presences) {
switch (presence.getShow()) {