Implemented Asynchronous description loading in Itemdescriptionfragment

This commit is contained in:
daniel oeh 2012-10-27 21:51:29 +02:00
parent ff8a1219af
commit 6a4abe1e85
2 changed files with 25 additions and 10 deletions

View File

@ -1320,6 +1320,9 @@ public class FeedManager {
public void loadExtraInformationOfItem(final Context context,
final FeedItem item, FeedManager.TaskCallback callback) {
if (AppConfig.DEBUG)
Log.d(TAG,
"Loading extra information of item with id " + item.getId());
dbExec.execute(new FeedManager.Task(new Handler(), callback) {
@Override

View File

@ -109,12 +109,20 @@ public class ItemDescriptionFragment extends SherlockFragment {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (item != null) {
FeedManager.getInstance().loadExtraInformationOfItem(getActivity(),
item, new FeedManager.TaskCallback() {
@Override
public void onCompletion() {
webViewLoader = createLoader();
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);
} else {
webViewLoader.execute();
}
}
});
} else {
Log.e(TAG, "Error in onViewCreated: Item was null");
}
@ -145,8 +153,10 @@ public class ItemDescriptionFragment extends SherlockFragment {
// /webvDescription.loadData(url, "text/html", "utf-8");
webvDescription.loadDataWithBaseURL(null, data, "text/html",
"utf-8", "about:blank");
if (getSherlockActivity() != null) {
getSherlockActivity()
.setSupportProgressBarIndeterminateVisibility(false);
}
if (AppConfig.DEBUG)
Log.d(TAG, "Webview loaded");
webViewLoader = null;
@ -155,9 +165,11 @@ public class ItemDescriptionFragment extends SherlockFragment {
@Override
protected void onPreExecute() {
super.onPreExecute();
if (getSherlockActivity() != null) {
getSherlockActivity()
.setSupportProgressBarIndeterminateVisibility(true);
}
}
@Override
protected Void doInBackground(Void... params) {