com.blankj.utilcode.util.SpanUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.SpanUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReplyView.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
private SpannableStringBuilder getSpannableReplyContent(String content){

        String input = content.replaceAll("<br>","")
                                .replace("@\n", "");

        String regex =  "<a href=\"/member/\\w+\">(\\w+)</a>" +
                        "|<a target=\"_blank\" href=\"(http[^\"]+)\" [^>]+>[^>]+>" +
                        "|<img src=\"(http[^\"]+)\" [^>]+>";

        Matcher matcher = Pattern.compile(regex).matcher(input);
        String[] split = input.split(regex);
        SpanUtils spanUtils = new SpanUtils();

        int index=0;

        while (matcher.find()){
            if (split.length != 0){
                spanUtils.append(split[index++]).setForegroundColor(mColorText);
            }
            if (matcher.group(1)!=null){
                spanUtils.append("@" + matcher.group(1))
                        .setClickSpan(new ReplyAtMemberClickSpan(matcher.group(1)));
            }else if (matcher.group(2) != null){
                spanUtils.append(matcher.group(2))
                        .setClickSpan(new LinkClickSpan(matcher.group(2)));
            }else if (matcher.group(3) != null){
                spanUtils.appendImage(R.drawable.ic_launcher_round)
                        .setClickSpan(new ImageClickSpan(matcher.group(3)));
            }
        }
        if (index != split.length){
            spanUtils.append(split[index]);
        }
        return spanUtils.create();
    }
 
Example #2
Source File: FeedbackActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void initViews() {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("反馈");

    mTvTip.setText(new SpanUtils().append("你也可直接发邮件至")
            .append(mContext.getResources().getString(R.string.my_email))
            .setBold()
            .append("(点击复制)")
            .create());
    mTvTip.setOnClickListener(this);
}