mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Added cachedDescription and cachedContentEncoded
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package de.danoeh.antennapod.feed;
|
package de.danoeh.antennapod.feed;
|
||||||
|
|
||||||
|
import java.lang.ref.SoftReference;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -11,11 +12,23 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class FeedItem extends FeedComponent {
|
public class FeedItem extends FeedComponent {
|
||||||
|
|
||||||
/** The id/guid that can be found in the rss/atom feed. Might not be set.*/
|
/** The id/guid that can be found in the rss/atom feed. Might not be set. */
|
||||||
private String itemIdentifier;
|
private String itemIdentifier;
|
||||||
private String title;
|
private String title;
|
||||||
|
/**
|
||||||
|
* The description of a feeditem. This field should only be set by the
|
||||||
|
* parser.
|
||||||
|
*/
|
||||||
private String description;
|
private String description;
|
||||||
|
/**
|
||||||
|
* The content of the content-encoded tag of a feeditem. This field should
|
||||||
|
* only be set by the parser.
|
||||||
|
*/
|
||||||
private String contentEncoded;
|
private String contentEncoded;
|
||||||
|
|
||||||
|
private SoftReference<String> cachedDescription;
|
||||||
|
private SoftReference<String> cachedContentEncoded;
|
||||||
|
|
||||||
private String link;
|
private String link;
|
||||||
private Date pubDate;
|
private Date pubDate;
|
||||||
private FeedMedia media;
|
private FeedMedia media;
|
||||||
@ -60,11 +73,12 @@ public class FeedItem extends FeedComponent {
|
|||||||
public Chapter getCurrentChapter() {
|
public Chapter getCurrentChapter() {
|
||||||
return getCurrentChapter(media.getPosition());
|
return getCurrentChapter(media.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the value that uniquely identifies this FeedItem.
|
/**
|
||||||
* If the itemIdentifier attribute is not null, it will be returned.
|
* Returns the value that uniquely identifies this FeedItem. If the
|
||||||
* Else it will try to return the title. If the title is not given, it will
|
* itemIdentifier attribute is not null, it will be returned. Else it will
|
||||||
* use the link of the entry.
|
* try to return the title. If the title is not given, it will use the link
|
||||||
|
* of the entry.
|
||||||
* */
|
* */
|
||||||
public String getIdentifyingValue() {
|
public String getIdentifyingValue() {
|
||||||
if (itemIdentifier != null) {
|
if (itemIdentifier != null) {
|
||||||
@ -85,6 +99,9 @@ public class FeedItem extends FeedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
if (description == null && cachedDescription != null) {
|
||||||
|
return cachedDescription.get();
|
||||||
|
}
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +146,10 @@ public class FeedItem extends FeedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getContentEncoded() {
|
public String getContentEncoded() {
|
||||||
|
if (contentEncoded == null && cachedContentEncoded != null) {
|
||||||
|
return cachedContentEncoded.get();
|
||||||
|
|
||||||
|
}
|
||||||
return contentEncoded;
|
return contentEncoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,5 +181,12 @@ public class FeedItem extends FeedComponent {
|
|||||||
this.itemIdentifier = itemIdentifier;
|
this.itemIdentifier = itemIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCachedDescription(String d) {
|
||||||
|
cachedDescription = new SoftReference<String>(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCachedContentEncoded(String c) {
|
||||||
|
cachedContentEncoded = new SoftReference<String>(c);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1331,9 +1331,9 @@ public class FeedManager {
|
|||||||
adapter.open();
|
adapter.open();
|
||||||
Cursor extraCursor = adapter.getExtraInformationOfItem(item);
|
Cursor extraCursor = adapter.getExtraInformationOfItem(item);
|
||||||
if (extraCursor.moveToFirst()) {
|
if (extraCursor.moveToFirst()) {
|
||||||
item.setDescription(extraCursor
|
item.setCachedDescription(extraCursor
|
||||||
.getString(PodDBAdapter.IDX_FI_EXTRA_DESCRIPTION));
|
.getString(PodDBAdapter.IDX_FI_EXTRA_DESCRIPTION));
|
||||||
item.setContentEncoded(extraCursor
|
item.setCachedContentEncoded(extraCursor
|
||||||
.getString(PodDBAdapter.IDX_FI_EXTRA_CONTENT_ENCODED));
|
.getString(PodDBAdapter.IDX_FI_EXTRA_CONTENT_ENCODED));
|
||||||
}
|
}
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
|||||||
@ -104,25 +104,23 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
FeedManager.getInstance().loadExtraInformationOfItem(getActivity(),
|
if (item.getDescription() == null && item.getDescription() == null) {
|
||||||
item, new FeedManager.TaskCallback() {
|
Log.i(TAG, "Loading data");
|
||||||
|
FeedManager.getInstance().loadExtraInformationOfItem(
|
||||||
@Override
|
getActivity(), item, new FeedManager.TaskCallback() {
|
||||||
public void onCompletion() {
|
@Override
|
||||||
webViewLoader = createLoader();
|
public void onCompletion() {
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
startLoader();
|
||||||
webViewLoader
|
|
||||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
} else {
|
|
||||||
webViewLoader.execute();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
} else {
|
||||||
|
Log.i(TAG, "Using cached data");
|
||||||
|
startLoader();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Error in onViewCreated: Item was null");
|
Log.e(TAG, "Error in onViewCreated: Item was null");
|
||||||
}
|
}
|
||||||
@ -133,6 +131,16 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
private void startLoader() {
|
||||||
|
webViewLoader = createLoader();
|
||||||
|
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||||
|
webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
} else {
|
||||||
|
webViewLoader.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private AsyncTask<Void, Void, Void> createLoader() {
|
private AsyncTask<Void, Void, Void> createLoader() {
|
||||||
return new AsyncTask<Void, Void, Void>() {
|
return new AsyncTask<Void, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user