diff options
author | lookshe <github@lookshe.org> | 2016-02-16 11:41:54 +0100 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-02-16 11:41:54 +0100 |
commit | 1e40764b20a08170f8e4bfe1f1ae1559111f2961 (patch) | |
tree | 1791a3870361f37c3c34c299d075f56ed4a6e2c2 /src/main/java/eu/siacs/conversations/entities/Presences.java | |
parent | a049aff638f27b68f08c753d42ef0fc2847b96cb (diff) | |
parent | d58d822215708cc0d9c841872abab448bf290e4c (diff) |
Merge tag '1.9.4' into trz/merge_1.9.4trz/merge_1.9.4
Conflicts:
build.gradle
src/main/java/eu/siacs/conversations/generator/PresenceGenerator.java
src/main/java/eu/siacs/conversations/parser/PresenceParser.java
src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
src/main/res/values/arrays.xml
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/Presences.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Presences.java | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index 4729a11b..813eda7a 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -1,29 +1,21 @@ package eu.siacs.conversations.entities; +import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; -import java.util.Map.Entry; import eu.siacs.conversations.xml.Element; public class Presences { + private final Hashtable<String, Presence> presences = new Hashtable<>(); - public static final int CHAT = -1; - public static final int ONLINE = 0; - public static final int AWAY = 1; - public static final int XA = 2; - public static final int DND = 3; - public static final int OFFLINE = 4; - - private final Hashtable<String, Integer> presences = new Hashtable<>(); - - public Hashtable<String, Integer> getPresences() { + public Hashtable<String, Presence> getPresences() { return this.presences; } - public void updatePresence(String resource, int status) { + public void updatePresence(String resource, Presence presence) { synchronized (this.presences) { - this.presences.put(resource, status); + this.presences.put(resource, presence); } } @@ -39,32 +31,10 @@ public class Presences { } } - public int getMostAvailableStatus() { - int status = OFFLINE; + public Presence getMostAvailablePresence() { synchronized (this.presences) { - Iterator<Entry<String, Integer>> it = presences.entrySet().iterator(); - while (it.hasNext()) { - Entry<String, Integer> entry = it.next(); - if (entry.getValue() < status) - status = entry.getValue(); - } - } - return status; - } - - public static int parseShow(Element show) { - if ((show == null) || (show.getContent() == null)) { - return Presences.ONLINE; - } else if (show.getContent().equals("away")) { - return Presences.AWAY; - } else if (show.getContent().equals("xa")) { - return Presences.XA; - } else if (show.getContent().equals("chat")) { - return Presences.CHAT; - } else if (show.getContent().equals("dnd")) { - return Presences.DND; - } else { - return Presences.OFFLINE; + if (presences.size() < 1) { return null; } + return Collections.min(presences.values()); } } |