From d44debab6726edbac07901a2b94a07f2ef4771ee Mon Sep 17 00:00:00 2001 From: steckbrief Date: Fri, 15 Jan 2016 21:57:36 +0100 Subject: Introducing some specialized IqPacketGenerators - IqPacketGenerator - PubSubPacketGenerator - AvatarPacketGenerator --- .../conversationsplus/services/AvatarService.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/de/thedevstack/conversationsplus/services') diff --git a/src/main/java/de/thedevstack/conversationsplus/services/AvatarService.java b/src/main/java/de/thedevstack/conversationsplus/services/AvatarService.java index 63e94c03..1cbda222 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/AvatarService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/AvatarService.java @@ -23,7 +23,6 @@ import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.ListItem; import de.thedevstack.conversationsplus.entities.MucOptions; import de.thedevstack.conversationsplus.generator.IqGenerator; -import de.thedevstack.conversationsplus.parser.IqParser; import de.thedevstack.conversationsplus.persistance.DatabaseBackend; import de.thedevstack.conversationsplus.ui.UiCallback; import de.thedevstack.conversationsplus.utils.AvatarUtil; @@ -33,6 +32,8 @@ import de.thedevstack.conversationsplus.utils.UiUpdateHelper; import de.thedevstack.conversationsplus.utils.XmppSendUtil; import de.thedevstack.conversationsplus.xml.Element; import de.thedevstack.conversationsplus.xmpp.OnIqPacketReceived; +import de.thedevstack.conversationsplus.xmpp.avatar.AvatarPacketGenerator; +import de.thedevstack.conversationsplus.xmpp.avatar.AvatarPacketParser; import de.thedevstack.conversationsplus.xmpp.pep.Avatar; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; @@ -323,13 +324,13 @@ public class AvatarService { callback.error(R.string.error_saving_avatar, avatar); return; } - final IqPacket packet = IqGenerator.publishAvatar(avatar); + final IqPacket packet = AvatarPacketGenerator.generatePublishAvatarPacket(avatar); XmppSendUtil.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket result) { if (result.getType() == IqPacket.TYPE.RESULT) { - final IqPacket packet = IqGenerator.publishAvatarMetadata(avatar); + final IqPacket packet = AvatarPacketGenerator.generatePublishAvatarMetadataPacket(avatar); XmppSendUtil.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override @@ -385,7 +386,7 @@ public class AvatarService { } private void fetchAvatarPep(final Account account, final Avatar avatar, final UiCallback callback) { - IqPacket packet = IqGenerator.retrievePepAvatar(avatar); + IqPacket packet = AvatarPacketGenerator.generateRetrieveAvatarPacket(avatar); XmppSendUtil.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override @@ -396,7 +397,7 @@ public class AvatarService { final String ERROR = account.getJid().toBareJid() + ": fetching avatar for " + avatar.owner + " failed "; if (result.getType() == IqPacket.TYPE.RESULT) { - avatar.image = IqParser.avatarData(result); + avatar.image = AvatarPacketParser.parseAvatarData(result); if (avatar.image != null) { if (AvatarUtil.save(avatar)) { if (account.getJid().toBareJid().equals(avatar.owner)) { @@ -472,7 +473,7 @@ public class AvatarService { } public void checkForAvatar(Account account, final UiCallback callback) { - IqPacket packet = IqGenerator.retrieveAvatarMetaData(null); + IqPacket packet = AvatarPacketGenerator.generateRetrieveAvatarMetadataPacket(null); XmppSendUtil.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override -- cgit v1.2.3