- super.onPostExecute(stringWriter);
- mProgressBar.setVisibility(View.GONE);
- mScrollView.setVisibility(View.VISIBLE);
- mTextView.setText(new String(stringWriter.getBuffer()));
+ final TextView textView = mTextViewReference.get();
+
+ if (textView != null) {
+ textView.setText(new String(stringWriter.getBuffer()));
+ textView.setVisibility(View.VISIBLE);
+ }
+
+ dismissLoadingDialog();
+ }
+
+ /**
+ * Show loading dialog
+ */
+ public void showLoadingDialog() {
+ // only once
+ Fragment frag = getActivity().getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
+ LoadingDialog loading = null;
+ if (frag == null) {
+ // Construct dialog
+ loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment));
+ FragmentManager fm = getActivity().getSupportFragmentManager();
+ FragmentTransaction ft = fm.beginTransaction();
+ loading.show(ft, DIALOG_WAIT_TAG);
+ } else {
+ loading = (LoadingDialog) frag;
+ loading.setShowsDialog(true);
+ }
+
+ }
+
+ /**
+ * Dismiss loading dialog
+ */
+ public void dismissLoadingDialog() {
+ final Fragment frag = getActivity().getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
+ if (frag != null) {
+ LoadingDialog loading = (LoadingDialog) frag;
+ loading.dismiss();
+ }