From 2602d6405f53e9f3923dcb941b9f68e0df1f593a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 12 Jan 2015 14:39:52 -0800 Subject: Fix bio, etc not being parsed correctly --- .../dsub/service/parser/ArtistInfoParser.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/service/parser/ArtistInfoParser.java b/src/github/daneren2005/dsub/service/parser/ArtistInfoParser.java index 5b8dc796..5c3d2412 100644 --- a/src/github/daneren2005/dsub/service/parser/ArtistInfoParser.java +++ b/src/github/daneren2005/dsub/service/parser/ArtistInfoParser.java @@ -16,6 +16,7 @@ package github.daneren2005.dsub.service.parser; import android.content.Context; +import android.util.Log; import org.xmlpull.v1.XmlPullParser; @@ -28,6 +29,7 @@ import github.daneren2005.dsub.domain.ArtistInfo; import github.daneren2005.dsub.util.ProgressListener; public class ArtistInfoParser extends AbstractParser { + private static final String TAG = ArtistInfo.class.getSimpleName(); public ArtistInfoParser(Context context, int instance) { super(context, instance); @@ -40,20 +42,13 @@ public class ArtistInfoParser extends AbstractParser { List artists = new ArrayList(); List missingArtists = new ArrayList(); + String tagName = null; int eventType; do { eventType = nextParseEvent(); if (eventType == XmlPullParser.START_TAG) { - String name = getElementName(); - if ("biography".equals(name)) { - info.setBiography(getText()); - } else if ("musicBrainzId".equals(name)) { - info.setMusicBrainzId(getText()); - } else if ("lastFmUrl".equals(name)) { - info.setLastFMUrl(getText()); - } else if ("largeImageUrl".equals(name)) { - info.setImageUrl(getText()); - } else if ("similarArtist".equals(name)) { + tagName = getElementName(); + if ("similarArtist".equals(tagName)) { String id = get("id"); if(id.equals("-1")) { missingArtists.add(get("name")); @@ -64,9 +59,19 @@ public class ArtistInfoParser extends AbstractParser { artist.setStarred(get("starred") != null); artists.add(artist); } - } else if ("error".equals(name)) { + } else if ("error".equals(tagName)) { handleError(); } + } else if(eventType == XmlPullParser.TEXT) { + if ("biography".equals(tagName) && info.getBiography() == null) { + info.setBiography(getText()); + } else if ("musicBrainzId".equals(tagName) && info.getMusicBrainzId() == null) { + info.setMusicBrainzId(getText()); + } else if ("lastFmUrl".equals(tagName) && info.getLastFMUrl() == null) { + info.setLastFMUrl(getText()); + } else if ("largeImageUrl".equals(tagName) && info.getImageUrl() == null) { + info.setImageUrl(getText()); + } } } while (eventType != XmlPullParser.END_DOCUMENT); -- cgit v1.2.3