From 9ec29bb1dcf664fea606105b7e700641a4b44ae4 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Thu, 29 Sep 2016 11:58:17 +0200 Subject: Fixes FS#29: Own Avatar not loaded --- .../thedevstack/conversationsplus/parser/PresenceParser.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java index f575aaac..e86e657e 100644 --- a/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java +++ b/src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import de.thedevstack.android.logcat.Logging; +import de.thedevstack.conversationsplus.persistance.DatabaseBackend; import de.thedevstack.conversationsplus.utils.AvatarUtil; import de.thedevstack.conversationsplus.utils.UiUpdateHelper; @@ -182,14 +183,19 @@ public class PresenceParser extends AbstractParser implements final String resource = from.isBareJid() ? "" : from.getResourcepart(); contact.setPresenceName(packet.findChildContent("nick", "http://jabber.org/protocol/nick")); Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update")); - if (avatar != null && !contact.isSelf()) { + if (avatar != null && (!contact.isSelf() || null == account.getAvatar())) { avatar.owner = from.toBareJid(); if (AvatarUtil.isAvatarCached(avatar)) { - if (contact.setAvatar(avatar)) { + if (avatar.owner.equals(account.getJid().toBareJid())) { + account.setAvatar(avatar.getFilename()); + DatabaseBackend.getInstance().updateAccount(account); + AvatarService.getInstance().clear(account); + UiUpdateHelper.updateAccountUi(); + } else if (contact.setAvatar(avatar)) { AvatarService.getInstance().clear(contact); - UiUpdateHelper.updateConversationUi(); UiUpdateHelper.updateRosterUi(); } + UiUpdateHelper.updateConversationUi(); } else { AvatarService.getInstance().fetchAvatar(account, avatar); } -- cgit v1.2.3