コード例 #1
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // 这里是什么问题呢?
    position = position - mListView.getHeaderViewsCount();
    if (position < 0 || position >= this.mCommentsAdapter.getList().size()) {
      return;
    }

    ArticleComment comment = this.mCommentsAdapter.getList().get(position);
    //	// 不能回复自己
    //	if (comment.getUserId() == MyApplication.getInstance().getCurrentLoginedUser().getUserId()) {
    //	    return;
    //	}
    mCurrentReplyComment = comment;
    layoutReply.setVisibility(View.VISIBLE);
    tvReply.setText("回复 " + comment.getNickname());
  }
コード例 #2
0
  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;
              }
            });
  }