use of com.yiw.circledemo.spannable.CircleMovementMethod in project CircleDemo by Naoki2015.
the class ExpandTextView method setText.
public void setText(final CharSequence content) {
contentText.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
// 避免重复监听
contentText.getViewTreeObserver().removeOnPreDrawListener(this);
int linCount = contentText.getLineCount();
if (linCount > showLines) {
if (isExpand) {
contentText.setMaxLines(Integer.MAX_VALUE);
textPlus.setText("收起");
} else {
contentText.setMaxLines(showLines);
textPlus.setText("全文");
}
textPlus.setVisibility(View.VISIBLE);
} else {
textPlus.setVisibility(View.GONE);
}
//Log.d("onPreDraw", linCount + "");
return true;
}
});
contentText.setText(content);
contentText.setMovementMethod(new CircleMovementMethod(getResources().getColor(R.color.name_selector_color)));
}
use of com.yiw.circledemo.spannable.CircleMovementMethod in project CircleDemo by Naoki2015.
the class PraiseListView method notifyDataSetChanged.
public void notifyDataSetChanged() {
SpannableStringBuilder builder = new SpannableStringBuilder();
if (datas != null && datas.size() > 0) {
//添加点赞图标
builder.append(setImageSpan());
FavortItem item = null;
for (int i = 0; i < datas.size(); i++) {
item = datas.get(i);
if (item != null) {
builder.append(setClickableSpan(item.getUser().getName(), i));
if (i != datas.size() - 1) {
builder.append(", ");
}
}
}
}
setText(builder);
setMovementMethod(new CircleMovementMethod(itemSelectorColor));
}
use of com.yiw.circledemo.spannable.CircleMovementMethod 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