Save references to description and contentEncoded in description

fragment
This commit is contained in:
daniel oeh 2012-11-16 20:40:39 +01:00
parent 6214026be8
commit 7ca2f559d1
1 changed files with 15 additions and 6 deletions

View File

@ -33,6 +33,9 @@ public class ItemDescriptionFragment extends SherlockFragment {
private FeedItem item; private FeedItem item;
private AsyncTask<Void, Void, Void> webViewLoader; private AsyncTask<Void, Void, Void> webViewLoader;
private String descriptionRef;
private String contentEncodedRef;
public static ItemDescriptionFragment newInstance(FeedItem item) { public static ItemDescriptionFragment newInstance(FeedItem item) {
ItemDescriptionFragment f = new ItemDescriptionFragment(); ItemDescriptionFragment f = new ItemDescriptionFragment();
@ -109,12 +112,17 @@ public class ItemDescriptionFragment extends SherlockFragment {
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) {
if (item.getDescription() == null && item.getContentEncoded() == null) { if (item.getDescription() == null
&& item.getContentEncoded() == null) {
Log.i(TAG, "Loading data"); Log.i(TAG, "Loading data");
FeedManager.getInstance().loadExtraInformationOfItem( FeedManager.getInstance().loadExtraInformationOfItem(
getActivity(), item, new FeedManager.TaskCallback() { getActivity(), item, new FeedManager.TaskCallback() {
@Override @Override
public void onCompletion(Cursor result) { public void onCompletion(Cursor result) {
if (item.getDescription() == null
&& item.getContentEncoded() == null) {
Log.e(TAG, "No description found");
}
startLoader(); startLoader();
} }
}); });
@ -134,6 +142,8 @@ public class ItemDescriptionFragment extends SherlockFragment {
@SuppressLint("NewApi") @SuppressLint("NewApi")
private void startLoader() { private void startLoader() {
contentEncodedRef = item.getContentEncoded();
descriptionRef = item.getDescription();
webViewLoader = createLoader(); webViewLoader = createLoader();
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -185,12 +195,11 @@ public class ItemDescriptionFragment extends SherlockFragment {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Loading Webview"); Log.d(TAG, "Loading Webview");
data = ""; data = "";
if (item.getContentEncoded() == null if (contentEncodedRef == null
&& item.getDescription() != null) { && descriptionRef != null) {
data = item.getDescription(); data = descriptionRef;
} else { } else {
data = StringEscapeUtils.unescapeHtml4(item data = StringEscapeUtils.unescapeHtml4(contentEncodedRef);
.getContentEncoded());
} }
data = WEBVIEW_STYLE + data; data = WEBVIEW_STYLE + data;