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;
}
Aggregations