Only read image-tag if it's a sub-element of the channel-tag
This commit is contained in:
parent
48f1cd2b3b
commit
85d1ed0520
|
@ -57,6 +57,15 @@ public class HandlerState {
|
|||
return second;
|
||||
}
|
||||
|
||||
public SyndElement getThirdTag() {
|
||||
SyndElement top = tagstack.pop();
|
||||
SyndElement second = tagstack.pop();
|
||||
SyndElement third = tagstack.peek();
|
||||
tagstack.push(second);
|
||||
tagstack.push(top);
|
||||
return third;
|
||||
}
|
||||
|
||||
public StringBuffer getContentBuf() {
|
||||
return contentBuf;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,12 @@ public class NSRSS20 extends Namespace {
|
|||
}
|
||||
|
||||
} else if (localName.equals(IMAGE)) {
|
||||
state.getFeed().setImage(new FeedImage());
|
||||
if (state.getTagstack().size() >= 1) {
|
||||
String parent = state.getTagstack().peek().getName();
|
||||
if (parent.equals(CHANNEL)) {
|
||||
state.getFeed().setImage(new FeedImage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new SyndElement(localName, this);
|
||||
}
|
||||
|
@ -83,6 +88,10 @@ public class NSRSS20 extends Namespace {
|
|||
String top = topElement.getName();
|
||||
SyndElement secondElement = state.getSecondTag();
|
||||
String second = secondElement.getName();
|
||||
String third = null;
|
||||
if (state.getTagstack().size() >= 3) {
|
||||
third = state.getThirdTag().getName();
|
||||
}
|
||||
|
||||
if (top.equals(GUID) && second.equals(ITEM)) {
|
||||
state.getCurrentItem().setItemIdentifier(content);
|
||||
|
@ -91,7 +100,7 @@ public class NSRSS20 extends Namespace {
|
|||
state.getCurrentItem().setTitle(content);
|
||||
} else if (second.equals(CHANNEL)) {
|
||||
state.getFeed().setTitle(content);
|
||||
} else if (second.equals(IMAGE)) {
|
||||
} else if (second.equals(IMAGE) && third != null && third.equals(CHANNEL)) {
|
||||
state.getFeed().getImage().setTitle(IMAGE);
|
||||
}
|
||||
} else if (top.equals(LINK)) {
|
||||
|
@ -103,7 +112,7 @@ public class NSRSS20 extends Namespace {
|
|||
} else if (top.equals(PUBDATE) && second.equals(ITEM)) {
|
||||
state.getCurrentItem().setPubDate(
|
||||
SyndDateUtils.parseRFC822Date(content));
|
||||
} else if (top.equals(URL) && second.equals(IMAGE)) {
|
||||
} else if (top.equals(URL) && second.equals(IMAGE) && third != null && third.equals(CHANNEL)) {
|
||||
state.getFeed().getImage().setDownload_url(content);
|
||||
} else if (localName.equals(DESCR)) {
|
||||
if (second.equals(CHANNEL)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ public class FeedHandlerTest extends AndroidTestCase {
|
|||
private static final String FEEDS_DIR = "testfeeds";
|
||||
|
||||
private static final String[] urls = {
|
||||
"http://podcast.hr-online.de/lateline/podcast.xml",
|
||||
"http://bitlove.org/nsemak/mikrodilettanten/feed",
|
||||
"http://bitlove.org/moepmoeporg/riotburnz/feed",
|
||||
"http://bitlove.org/moepmoeporg/schachcast/feed",
|
||||
|
|
Loading…
Reference in New Issue