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

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

View File

@ -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,7 +150,7 @@ public class FeedItem extends FeedComponent {
public String getContentEncoded() {
if (contentEncoded == null && cachedContentEncoded != null) {
return cachedContentEncoded.get();
return cachedContentEncoded.get();
}
return contentEncoded;

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();
}
});