Set image owner when parsing feed

This commit is contained in:
daniel oeh 2014-10-20 22:51:26 +02:00
parent 2cd504b9d0
commit b5066d02b4
4 changed files with 10 additions and 6 deletions

View File

@ -13,10 +13,11 @@ public class FeedImage extends FeedFile implements PicassoImageResource {
protected String title;
protected FeedComponent owner;
public FeedImage(String download_url, String title) {
public FeedImage(FeedComponent owner, String download_url, String title) {
super(null, download_url, false);
this.download_url = download_url;
this.title = title;
this.owner = owner;
}
public FeedImage(long id, String title, String file_url,
@ -26,6 +27,10 @@ public class FeedImage extends FeedFile implements PicassoImageResource {
this.title = title;
}
public FeedImage() {
super();
}
@Override
public String getHumanReadableIdentifier() {
if (owner != null && owner.getHumanReadableIdentifier() != null) {
@ -40,10 +45,6 @@ public class FeedImage extends FeedFile implements PicassoImageResource {
return FEEDFILETYPE_FEEDIMAGE;
}
public FeedImage() {
super();
}
public String getTitle() {
return title;
}

View File

@ -29,11 +29,13 @@ public class NSITunes extends Namespace {
if (state.getCurrentItem() != null) {
// this is an items image
image.setTitle(state.getCurrentItem().getTitle()+IMAGE_TITLE);
image.setOwner(state.getCurrentItem());
state.getCurrentItem().setImage(image);
} else {
// this is the feed image
if (state.getFeed().getImage() == null) {
image.setOwner(state.getFeed());
state.getFeed().setImage(image);
}
}

View File

@ -68,6 +68,7 @@ public class NSRSS20 extends Namespace {
String parent = state.getTagstack().peek().getName();
if (parent.equals(CHANNEL)) {
state.getFeed().setImage(new FeedImage());
state.getFeed().getImage().setOwner(state.getFeed());
}
}
}

View File

@ -193,7 +193,7 @@ public class NSAtom extends Namespace {
SyndDateUtils.parseRFC3339Date(content));
}
} else if (top.equals(IMAGE)) {
state.getFeed().setImage(new FeedImage(content, null));
state.getFeed().setImage(new FeedImage(state.getFeed(), content, null));
}
}