private void publishComment() {
    if (isPosting) {
      return;
    }

    if (TextUtils.isEmpty(etCommentContent.getText())) {
      //	    etCommentContent.setShakeAnimation();
      etCommentContent.requestFocus();
      return;
    }

    isPosting = true;
    PublishArticleCommentPostParams postParams = new PublishArticleCommentPostParams();
    postParams.articleId = targetArticle.getId();
    if (mCurrentReplyComment != null) {
      postParams.parentCommentId = mCurrentReplyComment.getId();
    }
    postParams.content = etCommentContent.getText().toString();

    AppServiceExtendImpl.getInstance()
        .publishArticleComment(
            postParams,
            new OnPublishArticleCommentResponseListener() {

              @Override
              public void onSuccess(ArticleComment comment) {
                // TODO Auto-generated method stub

                // 发布成功, 恢复原状
                etCommentContent.setText("");
                mCurrentReplyComment = null;
                layoutReply.setVisibility(View.GONE);
                // 隐藏表情 view
                findViewById(R.id.layout_emo).setVisibility(View.GONE);
                // 软键盘
                ActivityUtil.hideSoftInput(ArticleCommentsActivity.this);

                isPosting = false;
                mCommentsAdapter.add(comment);

                // 隐藏头部提示加载的textview
                tvLoading.setVisibility(View.GONE);
              }

              @Override
              public void onFailure(String errorMsg) {
                // TODO Auto-generated method stub
                ActivityUtil.show(ArticleCommentsActivity.this, errorMsg);
                isPosting = false;
              }
            });
  }
  private void init() {

    Object o = getIntent().getSerializableExtra("article");
    if (o != null) {
      targetArticle = (Article) o;
    } else {
      ActivityUtil.show(this, "没有指定帖子");
      finish();
    }

    TextView tvTopTitle =
        (TextView) findViewById(R.id.layout_nav_top).findViewById(R.id.tv_top_title);
    TextView tvTopAction =
        (TextView) findViewById(R.id.layout_nav_top).findViewById(R.id.tv_top_action);
    tvTopTitle.setText("查看帖子");
    tvTopTitle.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
          }
        });

    if (targetArticle.getUserId()
        == MyApplication.getInstance().getCurrentLoginedUser().getUserId()) {
      tvTopAction.setVisibility(View.VISIBLE);
      tvTopAction.setText("");
    } else {
      tvTopAction.setVisibility(View.GONE);
      tvTopAction.setText("");
    }

    // 输入框上面的回复谁布局容器
    layoutReply = findViewById(R.id.layout_article_comment_reply);
    layoutReply.setVisibility(View.GONE);
    // 回复 谁:
    tvReply = (TextView) findViewById(R.id.tv_article_comment_reply);
    // 取消回复 按钮
    tvReplyCancle = (TextView) findViewById(R.id.tv_article_comment_reply_cancle);
    tvReplyCancle.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mCurrentReplyComment = null;
            layoutReply.setVisibility(View.GONE);
            tvReply.setText("");
          }
        });

    tvShowEmo = (TextView) findViewById(R.id.tv_article_comment_emo);
    tvShowEmo.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // 显示或隐藏表情视图
            View view = findViewById(R.id.layout_emo);
            if (view.getVisibility() == View.VISIBLE) {
              view.setVisibility(View.GONE);
              //		    ActivityUtil.showSoftInputView(UserNewsCommentActivity.this,
              // etCommentContent);

            } else {
              view.setVisibility(View.VISIBLE);
              ActivityUtil.closeSoftInput(ArticleCommentsActivity.this, etCommentContent);
            }
          }
        });

    etCommentContent = (EmoticonsEditText) findViewById(R.id.et_article_comment_content);
    etCommentContent.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            View view = findViewById(R.id.layout_emo);
            view.setVisibility(View.GONE);
            ActivityUtil.showSoftInputView(ArticleCommentsActivity.this, etCommentContent);
          }
        });

    // 发布评论
    tvPublishComment = (TextView) findViewById(R.id.tv_article_comment_publish);

    tvPublishComment.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            publishComment();
          }
        });

    mListView = (me.himi.love.view.list.XListView) findViewById(R.id.listview_article_comments);
    // 使用代理 设置ImageLoader  在 ListView 滚动时不加载图片
    //	mNewsCommentListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(),
    // true, true));

    // 顶部的帖子布局容器

    RelativeLayout layoutFooterLoading =
        (RelativeLayout)
            LayoutInflater.from(this).inflate(R.layout.user_news_comment_loading, null);

    pbLoading = (ProgressBar) layoutFooterLoading.findViewById(R.id.pb_user_news_comment_loading);
    tvLoading = (TextView) layoutFooterLoading.findViewById(R.id.tv_user_news_comment_loading);

    // 底部提示加载中
    mListView.addFooterView(layoutFooterLoading);

    // 设置无数据时显示的view
    //	mNewsCommentListView.setEmptyView(v);

    mCommentsAdapter = new ArticleCommentsAdapter(this, new ArrayList<ArticleComment>());

    mListView.setAdapter(mCommentsAdapter);

    // 顶部帖子详细
    View v = createArticleView();
    mListView.addHeaderView(v);

    mListView.setPullLoadEnable(true);
    mListView.setPullRefreshEnable(false); // 因按评论时间升序,所以不提供刷新,只能加载更多
    mListView.pullRefreshing();

    mListView.setXListViewListener(
        new IXListViewListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            pageNumber = 1;
            loadArticleComments();
            tvLoading.setVisibility(View.GONE);
            pbLoading.setVisibility(View.GONE);
          }

          @Override
          public void onLoadMore() {
            // TODO Auto-generated method stub
            loadArticleComments();
          }
        });

    loadArticleComments();

    //
    mListView.setOnItemClickListener(this);

    // 默认先隐藏软键盘
    ActivityUtil.hideSoftInput(this);

    // 表情view
    initEmoView();
  }
  private View createArticleView() {

    View convertView = LayoutInflater.from(this).inflate(R.layout.article_item, null);

    final Article article = this.targetArticle;

    // 文章配图
    ImageView ivBackground = ViewHolder.get(convertView, R.id.iv_article_image);

    final ImageView ivFace = ViewHolder.get(convertView, R.id.iv_user_face);

    TextView tvNickname = ViewHolder.get(convertView, R.id.tv_user_nickname);

    TextView tvContent = ViewHolder.get(convertView, R.id.tv_secret_content); // 内容

    TextView tvTime = ViewHolder.get(convertView, R.id.tv_time); // 时间

    ImageView ivVip = ViewHolder.get(convertView, R.id.iv_vip);

    final ImageView ivLoves = ViewHolder.get(convertView, R.id.iv_likes); // 赞图标
    final TextView tvLoves = ViewHolder.get(convertView, R.id.tv_likes); // 赞次数
    TextView tvComments = ViewHolder.get(convertView, R.id.tv_comments); // 评论数

    tvLoves.setText(article.getLove() + "");
    tvComments.setText(article.getComments() + "");

    tvTime.setText(ActivityUtil.convertTimeToString(article.getCreateTime() * 1000L));

    // vip
    ivVip.setImageResource(article.getVip() != 0 ? R.drawable.vip : R.drawable.vipnot);
    tvNickname.setTextColor(
        getResources().getColor(article.getVip() != 0 ? R.color.c_vip : R.color.c_not_vip));
    //	ivVip.setVisibility(user.getVip() != 0 ? View.VISIBLE : View.GONE);

    if (article.getContentImageUrl().getSmallImageUrl() == null
        || article.getContentImageUrl().getSmallImageUrl().trim().length() == 0) {
      ivBackground.setVisibility(View.GONE);
    } else {
      ivBackground.setVisibility(View.VISIBLE);
      String imageUrl = article.getContentImageUrl().getSmallImageUrl();
      // 文章配图
      ImageLoader.getInstance()
          .displayImage(
              imageUrl,
              ivBackground,
              ImageLoaderOptions.normalOptions(),
              new ImageLoadingListener() {

                @Override
                public void onLoadingStarted(String arg0, View arg1) {
                  // TODO Auto-generated method stub

                }

                @Override
                public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
                  // TODO Auto-generated method stub

                }

                @Override
                public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
                  // TODO Auto-generated method stub
                  mCommentsAdapter.notifyDataSetChanged();
                }

                @Override
                public void onLoadingCancelled(String arg0, View arg1) {
                  // TODO Auto-generated method stub

                }
              });
    }

    // displayImage 会有刷新闪烁问题
    ImageLoader.getInstance()
        .displayImage(
            article.getFaceUrl().getSmallImageUrl(),
            ivFace,
            ImageLoaderOptions.circleOptions(),
            new ImageLoadingListener() {

              @Override
              public void onLoadingStarted(String arg0, View arg1) {
                // TODO Auto-generated method stub

              }

              @Override
              public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
                // TODO Auto-generated method stub

              }

              @Override
              public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
                // TODO Auto-generated method stub
                mCommentsAdapter.notifyDataSetChanged();
              }

              @Override
              public void onLoadingCancelled(String arg0, View arg1) {
                // TODO Auto-generated method stub

              }
            });

    tvNickname.setText(article.getNickname());

    tvContent.setText(article.getContent()); // 秘密的内容

    View love = ViewHolder.get(convertView, R.id.layout_likes);
    love.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            VoteArticleLovePostParams postParams = new VoteArticleLovePostParams();
            postParams.articleId = targetArticle.getId();
            AppServiceExtendImpl.getInstance()
                .loveArticle(
                    postParams,
                    new OnVoteArticleLoveResponseListener() {

                      @Override
                      public void onSuccess() {
                        // TODO Auto-generated method stub
                        tvLoves.setText(
                            Integer.parseInt(tvLoves.getText().toString().trim()) + 1 + "");
                        ivLoves.setBackgroundResource(R.drawable.player_collection_pressed);
                      }

                      @Override
                      public void onFailure(String errorMsg) {
                        // TODO Auto-generated method stub
                        showToast(errorMsg);
                      }
                    });
          }
        });
    // 分享
    View v = ViewHolder.get(convertView, R.id.iv_article_more);
    v.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            testShare();
          }
        });
    return convertView;
  }
  /** 加载评论 */
  private void loadArticleComments() {

    if (isRefreshing) {
      return;
    }

    isRefreshing = true;

    LoadArticleCommentsPostParams postParams = new LoadArticleCommentsPostParams();
    postParams.articleId = targetArticle.getId();
    postParams.page = pageNumber;
    postParams.pageSize = 20;

    AppServiceExtendImpl.getInstance()
        .loadArticleComments(
            postParams,
            new OnLoadArticleCommentsResponseListener() {

              @Override
              public void onSuccess(List<ArticleComment> comments) {

                pbLoading.setVisibility(View.GONE);

                if (comments.size() != 0) {
                  if (pageNumber == 1) { // 是刷新
                    mCommentsAdapter.getList().clear();
                  }
                  tvLoading.setVisibility(View.GONE);

                  mCommentsAdapter.addAll(comments);
                } else {
                  tvLoading.setVisibility(View.VISIBLE);
                  if (pageNumber == 1) {
                    if (mCommentsAdapter.getList().size() == 0) {
                      tvLoading.setText("暂无评论");
                    } else {
                      tvLoading.setText("暂无更多评论");
                    }
                  } else {
                    tvLoading.setText("暂无更多评论");
                  }
                }

                pageNumber++;

                isRefreshing = false;

                mListView.stopRefresh();
                mListView.stopLoadMore();
              }

              @Override
              public void onFailure(String errorMsg) {
                // TODO Auto-generated method stub
                ActivityUtil.show(ArticleCommentsActivity.this, errorMsg);

                pbLoading.setVisibility(View.GONE);
                tvLoading.setText("网络超时,请重试");

                mListView.stopRefresh();
                mListView.stopLoadMore();

                isRefreshing = false;
              }
            });
  }
  private void showMenu(final Article article, int pos, View v) {
    // TODO Auto-generated method stub
    if (null == pwMenuWin) {
      menuView = getLayoutInflater().inflate(R.layout.layout_review_menu, null);
      pwMenuWin =
          new PopupWindow(
              menuView,
              LinearLayout.LayoutParams.WRAP_CONTENT,
              LinearLayout.LayoutParams.WRAP_CONTENT,
              false);

      pwMenuWin.setContentView(menuView);
    }
    if (pwMenuWin.isShowing()) {
      pwMenuWin.dismiss();
    }

    int[] location = new int[2];
    v.getLocationOnScreen(location);
    pwMenuWin.showAtLocation(v, Gravity.NO_GRAVITY, (int) touchedX, (int) touchedY);
    //	pwMenuWin.showAtLocation(v, Gravity.NO_GRAVITY, (int) touchedX, location[1] + v.getHeight() /
    // 2);
    //	pwMenuWin.showAsDropDown(mListView.getChildAt(pos), 0, 0, Gravity.CENTER);
    //	pwMenuWin.showAsDropDown(v);

    final String url = me.himi.love.util.Constants.URL_ARTICLE_REVIEW;
    final RequestParams params = new RequestParams();
    params.put("article_id", article.getId());

    final AsyncHttpResponseHandler responseHandler =
        new AsyncHttpResponseHandler() {

          @Override
          public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            // TODO Auto-generated method stub
            showToast("操作成功");
            pwMenuWin.dismiss();
          }

          @Override
          public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            // TODO Auto-generated method stub
            showToast("操作失败");
            pwMenuWin.dismiss();
          }
        };

    // 允许通过
    menuView
        .findViewById(R.id.btn_review_allowpass)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                params.put("status", 1);
                HttpUtil.post(url, params, responseHandler);
              }
            });

    // 禁止通过
    menuView
        .findViewById(R.id.btn_review_notallowpass)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                params.put("status", 2);
                HttpUtil.post(url, params, responseHandler);
              }
            });

    // 保留
    menuView
        .findViewById(R.id.btn_review_cancle)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                //		pwMenuWin.dismiss();
                params.put("status", 0);
                HttpUtil.post(url, params, responseHandler);
              }
            });

    final TextView tvContent = (TextView) menuView.findViewById(R.id.tv_article_content);
    tvContent.setText(article.getContent());
  }