Implemented Asynchronous description loading in Itemdescriptionfragment
This commit is contained in:
parent
ff8a1219af
commit
6a4abe1e85
|
@ -1320,6 +1320,9 @@ public class FeedManager {
|
||||||
|
|
||||||
public void loadExtraInformationOfItem(final Context context,
|
public void loadExtraInformationOfItem(final Context context,
|
||||||
final FeedItem item, FeedManager.TaskCallback callback) {
|
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) {
|
dbExec.execute(new FeedManager.Task(new Handler(), callback) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -109,12 +109,20 @@ 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) {
|
||||||
|
FeedManager.getInstance().loadExtraInformationOfItem(getActivity(),
|
||||||
|
item, new FeedManager.TaskCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompletion() {
|
||||||
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);
|
||||||
} else {
|
} else {
|
||||||
webViewLoader.execute();
|
webViewLoader.execute();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Error in onViewCreated: Item was null");
|
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.loadData(url, "text/html", "utf-8");
|
||||||
webvDescription.loadDataWithBaseURL(null, data, "text/html",
|
webvDescription.loadDataWithBaseURL(null, data, "text/html",
|
||||||
"utf-8", "about:blank");
|
"utf-8", "about:blank");
|
||||||
|
if (getSherlockActivity() != null) {
|
||||||
getSherlockActivity()
|
getSherlockActivity()
|
||||||
.setSupportProgressBarIndeterminateVisibility(false);
|
.setSupportProgressBarIndeterminateVisibility(false);
|
||||||
|
}
|
||||||
if (AppConfig.DEBUG)
|
if (AppConfig.DEBUG)
|
||||||
Log.d(TAG, "Webview loaded");
|
Log.d(TAG, "Webview loaded");
|
||||||
webViewLoader = null;
|
webViewLoader = null;
|
||||||
|
@ -155,9 +165,11 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
if (getSherlockActivity() != null) {
|
||||||
getSherlockActivity()
|
getSherlockActivity()
|
||||||
.setSupportProgressBarIndeterminateVisibility(true);
|
.setSupportProgressBarIndeterminateVisibility(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
|
|
Loading…
Reference in New Issue