Parse avatar ID from downloaded Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 7 Dec 2011 06:22:39 +0000 (07:22 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 7 Dec 2011 06:22:39 +0000 (07:22 +0100)
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java

index b085ade..d8b924f 100644 (file)
@@ -332,6 +332,8 @@ public class SoneDownloader extends AbstractService {
                Integer profileBirthYear = Numbers.safeParseInteger(profileXml.getValue("birth-year", null));
                Profile profile = new Profile().setFirstName(profileFirstName).setMiddleName(profileMiddleName).setLastName(profileLastName);
                profile.setBirthDay(profileBirthDay).setBirthMonth(profileBirthMonth).setBirthYear(profileBirthYear);
+               /* avatar is processed after images are loaded. */
+               String avatarId = profileXml.getValue("avatar", null);
 
                /* parse profile fields. */
                SimpleXML profileFieldsXml = profileXml.getNode("fields");
@@ -495,6 +497,11 @@ public class SoneDownloader extends AbstractService {
                        }
                }
 
+               /* process avatar. */
+               if (avatarId != null) {
+                       sone.setAvatar(core.getImage(avatarId, false));
+               }
+
                /* okay, apparently everything was parsed correctly. Now import. */
                /* atomic setter operation on the Sone. */
                synchronized (sone) {