/**
  * fetch data as weibo dose
  *
  * @param count max count to fetch
  * @param parentid consult_id value
  * @param firstid if want to fetch previous data, use firstid, -1 means ignore this arg
  * @param lastid if want to fetch following data, use lastid, -1 means ignore this arg
  * @param index -1 means load more, 0 means fetch the latest data, positive means insert new data
  */
 public void fetchData(int count, long parentid, long lastid, boolean scrollEnd) {
   if (!lastRequestInProgress()) {
     requestId++;
     request = new Request(Request.GetConsu, true);
     request.setParam("parent_id", parentid + "");
     request.setParam("count", count + "");
     request.setParam("order", "1");
     if (lastid > -1) {
       request.setParam("last_id", lastid + "");
     }
     request.asyncRequest(this, requestId, scrollEnd);
   } else {
     loadingEnd();
   }
 }
  private void sendNow(final String postT, final String postC, final File upload) {
    UI.hideInputMethod();
    findViewById(R.id.subforum_submit).setEnabled(false);
    final Request request = new Request(Request.SubmitConsu);
    request.setParam("subject", postT);
    request.setParam("content", postC);
    request.setParam(
        "parent_id",
        mPID
            + ""); // TODO to indicate this is a new subject a just a sub response to a parent
                   // subject
    if (upload != null) {
      request.setSoTimeout(30000);
      request.setFile("plant_photo", upload);
    }

    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("正在发表提问");
    pd.setCanceledOnTouchOutside(false);
    pd.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            request.shutdown();
            findViewById(R.id.subforum_submit).setEnabled(true);
          }
        });
    pd.show();

    request.asyncRequest(
        new Request.ResponseListener() {
          @Override
          public void onResp(int id, Resp resp, Object... obj) {
            if (resp != null) {
              if (resp.success) {
                UI.toast("评论成功");
                isUpdated = true;
                // finish();
                mChildCount++;
                adapter.notifyDataSetChanged();
                onLoadMore(true);
                if (mLoadingView.getVisibility() != View.VISIBLE) {
                  mLoadingView.clearAnimation();
                  AnimUtils.DropIn.startAnimation(mLoadingView, 300);
                }
                postContent.setText("");
              } else {
                UI.toast("回帖失败");
              }
              pd.dismiss();
            }
            findViewById(R.id.subforum_submit).setEnabled(true);
          }

          @Override
          public void onErr(int id, String err, int httpCode, Object... obj) {
            pd.dismiss();
            UI.toast(err);
            findViewById(R.id.subforum_submit).setEnabled(true);
          }
        },
        0);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (position == 0) {
        if (topicView == null) {
          topicView = View.inflate(UI.getActivity(), R.layout.forum_item, null);
          topicView.setBackgroundColor(0xddffffff);
          topicView.setPadding(0, 0, 0, 0);
          convertView = topicView;
          JSONObjectExt json = parentObj;

          String subject = json.getString("Subject", "");
          String content = json.getString("Content", "");
          String time = json.getString("Timestamp", "");
          String photourl = json.getString("PhotoUrl", null);
          TextView tv = (TextView) convertView.findViewById(R.id.forum_subject);
          tv.setText(subject);
          tv = (TextView) convertView.findViewById(R.id.forum_content);
          tv.setText(content);
          tv = (TextView) convertView.findViewById(R.id.forum_time);
          tv.setText(time);

          final ImageView iv = (ImageView) convertView.findViewById(R.id.forum_image);

          if (photourl == null) {
            topicView.findViewById(R.id.forum_image_frame).setVisibility(View.GONE);
          } else {
            // photourl = Request.HOST + photourl;
            photourl = Request.getImageUrl(photourl, 0);
            final Uri uri = Uri.parse(photourl);
            topicView.findViewById(R.id.forum_image_frame).setVisibility(View.VISIBLE);
            Bitmap bitmap = null;
            bitmap =
                imageManager.loadImage(
                    new HttpImageManager.LoadRequest(
                        uri,
                        iv,
                        new HttpImageManager.OnLoadResponseListener() {

                          @Override
                          public void onLoadResponse(LoadRequest r, final Bitmap data) {}

                          @Override
                          public void onLoadProgress(
                              LoadRequest r, long totalContentSize, long loadedContentSize) {}

                          @Override
                          public void onLoadError(LoadRequest r, Throwable e) {
                            iv.setImageResource(R.color.transparent);
                          }

                          @Override
                          public boolean onBeforeSetImageBitmap(ImageView v, Bitmap data) {
                            showBitmapForView(v, data);
                            return false;
                          }
                        }),
                    true);
            if (bitmap != null) {
              showBitmapForView(iv, bitmap);
            }
          }
        }
        convertView = topicView;
        TextView tv = (TextView) convertView.findViewById(R.id.forum_child_count);
        tv.setText(mChildCount + "条回复");
        return convertView;
      }

      final DataItem g = (DataItem) getItem(position);
      if (convertView == null || convertView == topicView) {
        convertView = View.inflate(UI.getActivity(), R.layout.forum_feedback_item, null);
      }
      // animation begin ---------------
      if (position == Math.max(0, getCount() - mCount) && !mReachEnd) {
        onLoadMore(false);
      }
      // animation end --------------

      JSONObjectExt json = g.json;

      String content = json.getString("Content", "");

      TextView tv = (TextView) convertView.findViewById(R.id.subitem_content);
      tv.setText(content);
      tv = (TextView) convertView.findViewById(R.id.subitem_time);
      tv.setText(g.date);

      // View divider = convertView.findViewById(R.id.subitem_divider);

      /*if (position != 1) {
      	divider.setVisibility(View.VISIBLE);
      } else {
      	divider.setVisibility(View.GONE);
      }*/

      return convertView;
    }
 private boolean lastRequestInProgress() {
   if (request != null && request.isOnFetching()) {
     return true;
   }
   return false;
 }