@Override
 public void run() {
   ((ScrollView) parentActivity.findViewById(R.id.content_scrollview))
       .scrollTo(
           0,
           GlobalConfig.getReadSavesRecord(
               currentCid,
               ((LinearLayout) parentActivity.findViewById(R.id.novel_content_layout))
                   .getMeasuredHeight()));
 }
    @Override
    protected void onPostExecute(Integer result) {
      if (result == -100) {
        if (from.equals(BookshelfFragment.fromid)) {
          Toast.makeText(
                  parentActivity,
                  getResources().getString(R.string.bookshelf_not_cached),
                  Toast.LENGTH_LONG)
              .show();

          new AlertDialog.Builder(parentActivity)
              .setTitle(getResources().getString(R.string.bookshelf_did_not_find_cache))
              .setMessage(getResources().getString(R.string.bookshelf_want_to_connect_to_Internet))
              .setPositiveButton(
                  "YES",
                  new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      if (pDialog != null) pDialog.dismiss();

                      // connect to the Internet to load
                      from = "";
                      List<NameValuePair> targVar = new ArrayList<NameValuePair>();
                      targVar.add(
                          Wenku8Interface.getNovelContent(
                              currentAid, currentCid, GlobalConfig.getFetchLanguage()));

                      final asyncNovelContentTask ast = new asyncNovelContentTask();
                      ast.execute(targVar);
                      return;
                    }
                  })
              .setNegativeButton(
                  "NO",
                  new android.content.DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      onBackPressed();
                    }
                  })
              .show();
        } else
          Toast.makeText(
                  parentActivity,
                  getResources().getString(R.string.network_error),
                  Toast.LENGTH_LONG)
              .show();
        if (pDialog != null) pDialog.dismiss();
        return;
      }

      // generate listview to contain the texts and images
      // ListView lv = (ListView) parentActivity
      // .findViewById(R.id.content_list);
      // if (lv == null) {
      // Log.e("MewX", "NovelReaderActivity ListView == null!");
      // return;
      // }
      // lv.setDivider(null);
      // lv.setAdapter(new NovelContentAdapter(parentActivity, nc));
      // pDialog.setProgress(nc.size());

      // The abandoned way - dynamically addign textview into layout
      LinearLayout layout = (LinearLayout) parentActivity.findViewById(R.id.novel_content_layout);

      for (int i = 0; i < nc.size(); i++) {
        if (pDialog != null) pDialog.setProgress(i);

        switch (nc.get(i).type) {
          case 't':
            TextView tempTV = new TextView(parentActivity);
            if (i == 0) {
              tempTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, GlobalConfig.getShowTextSize() + 6);
              Shader shader =
                  new LinearGradient(
                      0, 0, 0, tempTV.getTextSize(), 0xFF003399, 0xFF6699FF, Shader.TileMode.CLAMP);
              tempTV.getPaint().setShader(shader);
            } else {
              tempTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, GlobalConfig.getShowTextSize());
            }
            tempTV.setText(nc.get(i).content);
            tempTV.setPadding(
                GlobalConfig.getShowTextPaddingLeft(),
                GlobalConfig.getShowTextPaddingTop(),
                GlobalConfig.getShowTextPaddingRight(),
                0);
            layout.addView(tempTV);
            break;

          case 'i':
            final ImageView tempIV = new ImageView(parentActivity);
            tempIV.setClickable(true);
            tempIV.setAdjustViewBounds(true);
            tempIV.setScaleType(ScaleType.FIT_CENTER); // CENTER_INSIDE
            tempIV.setPadding(0, GlobalConfig.getShowTextPaddingTop(), 0, 0);
            tempIV.setImageResource(R.drawable.empty_cover); // default

            // async loader
            final String imgFileName = GlobalConfig.generateImageFileNameByURL(nc.get(i).content);
            final String path = GlobalConfig.getAvailableNovolContentImagePath(imgFileName);

            if (path != null) {
              ImageLoader.getInstance().displayImage("file://" + path, tempIV);

              tempIV.setOnClickListener(
                  new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      // TODO Auto-generated method stub
                      Intent intent = new Intent();
                      intent.setClass(parentActivity, NovelImageActivity.class);
                      intent.putExtra("path", path);
                      startActivity(intent);
                      parentActivity.overridePendingTransition(R.anim.in_from_right, R.anim.keep);
                    }
                  });
            } else {
              // define another asynctask to load image
              // need to access local var - tempIV
              class asyncDownloadImage extends AsyncTask<String, Integer, String> {
                @Override
                protected String doInBackground(String... params) {
                  GlobalConfig.saveNovelContentImage(params[0]);
                  String name = GlobalConfig.generateImageFileNameByURL(params[0]);
                  return GlobalConfig.getAvailableNovolContentImagePath(name);
                }

                @Override
                protected void onPostExecute(final String result) {
                  ImageLoader.getInstance().displayImage("file://" + result, tempIV);

                  tempIV.setOnClickListener(
                      new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          Intent intent = new Intent();
                          intent.setClass(parentActivity, NovelImageActivity.class);
                          intent.putExtra("path", result);
                          startActivity(intent);
                          parentActivity.overridePendingTransition(
                              R.anim.in_from_right, R.anim.keep);
                        }
                      });

                  return;
                }
              }
              asyncDownloadImage async = new asyncDownloadImage();
              async.execute(nc.get(i).content);
            }

            layout.addView(tempIV);
            break;
        }
      }

      // end loading dialog
      if (pDialog != null) pDialog.dismiss();

      // show dialog
      if (GlobalConfig.getReadSavesRecord(
              currentCid,
              ((LinearLayout) parentActivity.findViewById(R.id.novel_content_layout))
                  .getMeasuredHeight())
          > 100) {
        new AlertDialog.Builder(parentActivity)
            .setTitle(getResources().getString(R.string.novel_load))
            .setMessage(getResources().getString(R.string.novel_load_question))
            .setPositiveButton(
                "YES",
                new android.content.DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // set scroll view
                    Handler handler = new Handler();
                    handler.postDelayed(runnableScroll, 200);

                    Toast.makeText(
                            parentActivity,
                            "Scroll to = "
                                + GlobalConfig.getReadSavesRecord(
                                    currentCid,
                                    ((LinearLayout)
                                            parentActivity.findViewById(R.id.novel_content_layout))
                                        .getMeasuredHeight()),
                            Toast.LENGTH_SHORT)
                        .show();
                  }
                })
            .setNegativeButton("NO", null)
            .show();
      }

      return;
    }