Renamed methods

This commit is contained in:
daniel oeh 2012-10-27 22:36:35 +02:00
parent fb4ba95789
commit bd1b07150b
3 changed files with 33 additions and 6 deletions

View File

@ -143,6 +143,15 @@ public class Feed extends FeedFile {
return download_url;
}
}
/** Calls cacheDescriptions on all items. */
protected void cacheDescriptionsOfItems() {
if (items != null) {
for (FeedItem item : items) {
item.cacheDescriptions();
}
}
}
@Override
public int getTypeAsInt() {

View File

@ -25,10 +25,10 @@ public class FeedItem extends FeedComponent {
* only be set by the parser.
*/
private String contentEncoded;
private SoftReference<String> cachedDescription;
private SoftReference<String> cachedContentEncoded;
private String link;
private Date pubDate;
private FeedMedia media;
@ -41,6 +41,21 @@ public class FeedItem extends FeedComponent {
this.read = true;
}
/**
* Moves the 'description' and 'contentEncoded' field of feeditem to their
* SoftReference fields.
*/
protected void cacheDescriptions() {
if (description != null) {
cachedDescription = new SoftReference<String>(description);
}
if (contentEncoded != null) {
cachedContentEncoded = new SoftReference<String>(contentEncoded);
}
description = null;
contentEncoded = null;
}
/** Get the chapter that fits the position. */
public Chapter getCurrentChapter(int position) {
Chapter current = null;
@ -135,8 +150,8 @@ public class FeedItem extends FeedComponent {
public String getContentEncoded() {
if (contentEncoded == null && cachedContentEncoded != null) {
return cachedContentEncoded.get();
return cachedContentEncoded.get();
}
return contentEncoded;
}
@ -168,11 +183,11 @@ public class FeedItem extends FeedComponent {
public void setItemIdentifier(String itemIdentifier) {
this.itemIdentifier = itemIdentifier;
}
public void setCachedDescription(String d) {
cachedDescription = new SoftReference<String>(d);
}
public void setCachedContentEncoded(String c) {
cachedContentEncoded = new SoftReference<String>(c);
}

View File

@ -774,6 +774,7 @@ public class FeedManager {
PodDBAdapter adapter = new PodDBAdapter(context);
adapter.open();
adapter.setCompleteFeed(feed);
feed.cacheDescriptionsOfItems();
adapter.close();
}
});
@ -867,6 +868,7 @@ public class FeedManager {
public void setFeed(Feed feed, PodDBAdapter adapter) {
if (adapter != null) {
adapter.setFeed(feed);
feed.cacheDescriptionsOfItems();
} else {
Log.w(TAG, "Adapter in setFeed was null");
}
@ -914,6 +916,7 @@ public class FeedManager {
PodDBAdapter adapter = new PodDBAdapter(context);
adapter.open();
adapter.setFeed(feed);
feed.cacheDescriptionsOfItems();
adapter.close();
}
});