aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/parser
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-01-13 16:10:09 +0100
committersteckbrief <steckbrief@chefmail.de>2016-01-13 16:10:09 +0100
commit8644c4676a5fda9d642244ff70e72c5fe524a24d (patch)
treeaa3638db5eb30c25cbd250f675a5a1e61b2a99ab /src/main/java/de/thedevstack/conversationsplus/parser
parent0fe5ce481fe72d3821a93b2792d6ae16b04bec7d (diff)
Moved all avatar related work to AvatarService
- fetchAvatar, fetchAvatarPep, fetchAvatarVcard, checkForAvatar moved from XmppConnectionService to AvatarService - Several unused imports removed - XmppSendUtil introduced to enable presencePacket and iqPacket sending without using XmppConnectionService since the account has everything needed - UiUpdateHelper introduced to enable UI updates without using XmppConnectionService directly
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/parser')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java7
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java9
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java18
4 files changed, 21 insertions, 21 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
index c9efe3d7..fe6522a3 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
@@ -5,15 +5,11 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Contact;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
-import de.thedevstack.conversationsplus.xmpp.stanzas.MessagePacket;
public abstract class AbstractParser {
@@ -26,7 +22,7 @@ public abstract class AbstractParser {
/**
* Gets the timestamp from the 'delay' element.
* Refer to XEP-0203: Delayed Delivery for details. @link{http://xmpp.org/extensions/xep-0203.html}
- * @param packet the element to find the child element 'delay' in.
+ * @param element the element to find the child element 'delay' in.
* @return the time in milli seconds of the attribute 'stamp' of the
* element 'delay'. In case there is no 'delay' element or no 'stamp'
* attribute or the current time is less than the value of the 'stamp'
@@ -92,7 +88,7 @@ public abstract class AbstractParser {
}
}
- protected String avatarData(Element items) {
+ protected static String avatarData(Element items) {
Element item = items.findChild("item");
if (item == null) {
return null;
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
index 9df70c1e..fc764a88 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/IqParser.java
@@ -7,6 +7,7 @@ import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Contact;
+import de.thedevstack.conversationsplus.services.AvatarService;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.utils.Xmlns;
import de.thedevstack.conversationsplus.xml.Element;
@@ -50,14 +51,14 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
contact.parseSubscriptionFromElement(item);
}
}
- mXmppConnectionService.getAvatarService().clear(contact);
+ AvatarService.getInstance().clear(contact);
}
}
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();
}
- public String avatarData(final IqPacket packet) {
+ public static String avatarData(final IqPacket packet) {
final Element pubsub = packet.findChild("pubsub",
"http://jabber.org/protocol/pubsub");
if (pubsub == null) {
@@ -67,7 +68,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
if (items == null) {
return null;
}
- return super.avatarData(items);
+ return AbstractParser.avatarData(items);
}
@Override
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
index 721f1a23..85c38e12 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
@@ -14,6 +14,7 @@ import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.entities.MucOptions;
import de.thedevstack.conversationsplus.http.HttpConnectionManager;
+import de.thedevstack.conversationsplus.services.AvatarService;
import de.thedevstack.conversationsplus.services.MessageArchiveService;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.utils.AvatarUtil;
@@ -148,18 +149,18 @@ public class MessageParser extends AbstractParser implements
if (account.setAvatar(avatar.getFilename())) {
mXmppConnectionService.databaseBackend.updateAccount(account);
}
- mXmppConnectionService.getAvatarService().clear(account);
+ AvatarService.getInstance().clear(account);
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(from);
contact.setAvatar(avatar);
- mXmppConnectionService.getAvatarService().clear(contact);
+ AvatarService.getInstance().clear(contact);
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();
}
} else {
- mXmppConnectionService.fetchAvatar(account, avatar);
+ AvatarService.getInstance().fetchAvatar(account, avatar);
}
}
} else if ("http://jabber.org/protocol/nick".equals(node)) {
@@ -168,7 +169,7 @@ public class MessageParser extends AbstractParser implements
if (nick != null) {
Contact contact = account.getRoster().getContact(from);
contact.setPresenceName(nick.getContent());
- mXmppConnectionService.getAvatarService().clear(account);
+ AvatarService.getInstance().clear(account);
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateAccountUi();
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java
index ce52bbeb..8bc5ec89 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java
@@ -9,8 +9,10 @@ import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.MucOptions;
import de.thedevstack.conversationsplus.entities.Presences;
import de.thedevstack.conversationsplus.generator.PresenceGenerator;
+import de.thedevstack.conversationsplus.services.AvatarService;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.utils.AvatarUtil;
+import de.thedevstack.conversationsplus.utils.UiUpdateHelper;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.OnPresencePacketReceived;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
@@ -35,12 +37,12 @@ public class PresenceParser extends AbstractParser implements
mucOptions.processPacket(packet, mPgpEngine);
final ArrayList<MucOptions.User> tileUserAfter = new ArrayList<>(mucOptions.getUsers().subList(0,Math.min(mucOptions.getUsers().size(),5)));
if (!tileUserAfter.equals(tileUserBefore)) {
- mXmppConnectionService.getAvatarService().clear(conversation);
+ AvatarService.getInstance().clear(conversation);
}
if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUsers().size())) {
- mXmppConnectionService.updateConversationUi();
+ UiUpdateHelper.updateConversationUi();
} else if (mucOptions.online()) {
- mXmppConnectionService.updateMucRosterUi();
+ UiUpdateHelper.updateMucRosterUi();
}
}
}
@@ -61,12 +63,12 @@ public class PresenceParser extends AbstractParser implements
avatar.owner = from.toBareJid();
if (AvatarUtil.isAvatarCached(avatar)) {
if (contact.setAvatar(avatar)) {
- mXmppConnectionService.getAvatarService().clear(contact);
- mXmppConnectionService.updateConversationUi();
- mXmppConnectionService.updateRosterUi();
+ AvatarService.getInstance().clear(contact);
+ UiUpdateHelper.updateConversationUi();
+ UiUpdateHelper.updateRosterUi();
}
} else {
- mXmppConnectionService.fetchAvatar(account, avatar);
+ AvatarService.getInstance().fetchAvatar(account, avatar);
}
}
int sizeBefore = contact.getPresences().size();
@@ -96,7 +98,7 @@ public class PresenceParser extends AbstractParser implements
contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
}
- mXmppConnectionService.updateRosterUi();
+ UiUpdateHelper.updateRosterUi();
}
@Override