Search in sources :

Example 6 with CommentItem

use of com.yiw.circledemo.bean.CommentItem in project CircleDemo by Naoki2015.

the class CommentListView method getView.

private View getView(final int position) {
    if (layoutInflater == null) {
        layoutInflater = LayoutInflater.from(getContext());
    }
    View convertView = layoutInflater.inflate(R.layout.item_comment, null, false);
    TextView commentTv = (TextView) convertView.findViewById(R.id.commentTv);
    final CircleMovementMethod circleMovementMethod = new CircleMovementMethod(itemSelectorColor, itemSelectorColor);
    final CommentItem bean = mDatas.get(position);
    String name = bean.getUser().getName();
    String id = bean.getId();
    String toReplyName = "";
    if (bean.getToReplyUser() != null) {
        toReplyName = bean.getToReplyUser().getName();
    }
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(setClickableSpan(name, bean.getUser().getId()));
    if (!TextUtils.isEmpty(toReplyName)) {
        builder.append(" 回复 ");
        builder.append(setClickableSpan(toReplyName, bean.getToReplyUser().getId()));
    }
    builder.append(": ");
    //转换表情字符
    String contentBodyStr = bean.getContent();
    builder.append(UrlUtils.formatUrlString(contentBodyStr));
    commentTv.setText(builder);
    commentTv.setMovementMethod(circleMovementMethod);
    commentTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (circleMovementMethod.isPassToTv()) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(position);
                }
            }
        }
    });
    commentTv.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (circleMovementMethod.isPassToTv()) {
                if (onItemLongClickListener != null) {
                    onItemLongClickListener.onItemLongClick(position);
                }
                return true;
            }
            return false;
        }
    });
    return convertView;
}
Also used : CommentItem(com.yiw.circledemo.bean.CommentItem) CircleMovementMethod(com.yiw.circledemo.spannable.CircleMovementMethod) TextView(android.widget.TextView) SpannableString(android.text.SpannableString) TextView(android.widget.TextView) View(android.view.View) SpannableStringBuilder(android.text.SpannableStringBuilder)

Aggregations

CommentItem (com.yiw.circledemo.bean.CommentItem)6 View (android.view.View)2 CircleItem (com.yiw.circledemo.bean.CircleItem)2 SuppressLint (android.annotation.SuppressLint)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SpannableString (android.text.SpannableString)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 TextView (android.widget.TextView)1 ImagePagerActivity (com.yiw.circledemo.activity.ImagePagerActivity)1 CircleViewHolder (com.yiw.circledemo.adapter.viewholder.CircleViewHolder)1 ImageViewHolder (com.yiw.circledemo.adapter.viewholder.ImageViewHolder)1 URLViewHolder (com.yiw.circledemo.adapter.viewholder.URLViewHolder)1 VideoViewHolder (com.yiw.circledemo.adapter.viewholder.VideoViewHolder)1 CommentConfig (com.yiw.circledemo.bean.CommentConfig)1 FavortItem (com.yiw.circledemo.bean.FavortItem)1 PhotoInfo (com.yiw.circledemo.bean.PhotoInfo)1 User (com.yiw.circledemo.bean.User)1 CircleMovementMethod (com.yiw.circledemo.spannable.CircleMovementMethod)1 GlideCircleTransform (com.yiw.circledemo.utils.GlideCircleTransform)1 CircleVideoView (com.yiw.circledemo.widgets.CircleVideoView)1